WO2022205934A1 - Disparity map optimization method and apparatus, and electronic device and computer-readable storage medium - Google Patents

Disparity map optimization method and apparatus, and electronic device and computer-readable storage medium Download PDF

Info

Publication number
WO2022205934A1
WO2022205934A1 PCT/CN2021/130994 CN2021130994W WO2022205934A1 WO 2022205934 A1 WO2022205934 A1 WO 2022205934A1 CN 2021130994 W CN2021130994 W CN 2021130994W WO 2022205934 A1 WO2022205934 A1 WO 2022205934A1
Authority
WO
WIPO (PCT)
Prior art keywords
disparity map
image
gradient
initial disparity
abscissa direction
Prior art date
Application number
PCT/CN2021/130994
Other languages
French (fr)
Chinese (zh)
Inventor
郑子华
Original Assignee
北京迈格威科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京迈格威科技有限公司 filed Critical 北京迈格威科技有限公司
Publication of WO2022205934A1 publication Critical patent/WO2022205934A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N13/00Stereoscopic video systems; Multi-view video systems; Details thereof
    • H04N13/10Processing, recording or transmission of stereoscopic or multi-view image signals
    • H04N13/106Processing image signals
    • H04N13/122Improving the 3D impression of stereoscopic images by modifying image signal contents, e.g. by filtering or adding monoscopic depth cues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N13/00Stereoscopic video systems; Multi-view video systems; Details thereof
    • H04N13/10Processing, recording or transmission of stereoscopic or multi-view image signals
    • H04N13/106Processing image signals
    • H04N13/128Adjusting depth or disparity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N13/00Stereoscopic video systems; Multi-view video systems; Details thereof
    • H04N2013/0074Stereoscopic image analysis
    • H04N2013/0081Depth or disparity estimation from stereoscopic image signals

Definitions

  • the present application belongs to the field of image processing, and in particular relates to a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium.
  • the disparity map between the first image and the second image can be calculated, so that a series of back-end applications can be performed based on the obtained disparity, such as dual-camera refocusing and dense reconstruction of multiple images. (MVS, Multi View System) etc.
  • conventional guided filtering techniques are generally used to optimize the disparity map, such as WLS (Weighted Least-Squares), FGS (Fast Global Smooth), and the like.
  • WLS Weighted Least-Squares
  • FGS Fast Global Smooth
  • conventional guided filtering techniques basically only the smoothness of the input image before and after filtering is considered. If the disparity map is used as the input image, and the disparity map itself has certain errors, after guided filtering, in addition to smoothing the pixel values of the errors, the pixel values of other normal areas of the disparity map will be destroyed. , resulting in error diffusion.
  • the present application provides a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium.
  • the smoothing range is constrained, so as to ensure the disparity value of the optimized disparity map and The accuracy of the range.
  • Some embodiments of the present application provide a disparity map optimization method, the method may include: acquiring a first image, a second image and an initial disparity map corresponding to the first image and the second image, the The first image and the second image are two images obtained from different shooting angles for the same shooting scene; the energy equation for guiding filtering is determined according to the initial disparity map, the first image and the second image , the energy equation includes a data item and a smoothing term; the initial disparity map is guided and filtered according to the energy equation to obtain an optimized disparity map.
  • the data item and smoothing term included in the energy equation used for conducting the guided filtering may be based on the initial disparity map, the first image, and the second image used in stereo matching. so that the smooth term is affected by the gradient of the first image in the abscissa direction and the ordinate direction, and also by the gradient of the second image in the abscissa direction and the ordinate direction.
  • the first image and the The degree of matching between the second images constrains the smoothing term, so that the smoothing term can be controlled to smooth the areas that should be smoothed in the initial disparity map, and ignore the areas that should not be smoothed to prevent errors from spreading to normal areas to ensure optimization
  • the accuracy of the disparity values and the accuracy of the range in the disparity map
  • the data item E data is determined according to the first image and the second image, and the data item E data is determined according to the initial disparity map.
  • performing guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map may include: according to the energy equation, calculating the gradient d x of the initial disparity map in the abscissa direction; the optimized disparity map is obtained by superimposing the initial disparity map d and the gradient d x of the initial disparity map in the abscissa direction.
  • the method may further include: judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule; , and the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map.
  • the method may further include: when the judgment is no, performing the following steps until the gradient d x of the current initial disparity map in the abscissa direction satisfies After the preset rule, the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map:
  • the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current iteration The number of times satisfies the second threshold.
  • the guide map of the guide filter may be the first image.
  • a disparity map optimization apparatus may include: an acquisition module, a determination module, and a guided filtering module.
  • the acquisition module may be configured to acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image, and the first image and the second image may be for the same shooting scene, two images obtained through different shooting angles;
  • the determining module may be configured to determine an equation for conducting guided filtering according to the initial disparity map, the first image and the second image, the energy equation A data item and a smoothing item may be included;
  • the guided filtering module may be configured to perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  • the determining module may be configured to: determine the data item E data according to the first image and the second image;
  • the smooth term E data is determined from the initial disparity map;
  • is the weight of the smooth item and the data item, and the data item may constitute a constraint effect on the smooth item.
  • I 1 (x) is the first image
  • I 2 (x+d) is the second image
  • d is the initial disparity map
  • x is the abscissa of any point in the first image
  • d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively
  • w x and w y are smoothing weights.
  • the guided filtering module may be configured to: according to the energy equation, calculate the gradient d x of the initial disparity map in the abscissa direction ; By superimposing the initial disparity map d and the gradient d x of the initial disparity map in the abscissa direction, the optimized disparity map is obtained.
  • the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge that the current initial disparity map is in the abscissa direction Whether the gradient d x of the current initial disparity map satisfies the preset rule; the execution module may be configured to determine the optimized disparity corresponding to the gradient d x of the current initial disparity map in the abscissa direction when the judgment module judges that it is yes The picture shows the final disparity map.
  • the apparatus may further include a judgment module and an execution module, and the judgment module may be used to judge the gradient of the current initial disparity map in the abscissa direction Whether d x satisfies the preset rule; the execution module may be configured to perform the following process when the judgment module judges no, until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule , and then determine the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction as the final disparity map:
  • the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current initial disparity map The number of iterations satisfies the second threshold.
  • the guide map of the guide filter may be the first image.
  • the electronic device may include: a memory and a processor, the memory is connected to the processor; the memory is used for storing a program; the processor invokes the storage
  • the program stored in the memory is used to execute some of the above-mentioned embodiments of the present application and/or the methods provided in combination with any possible implementation manner of some of the above-mentioned embodiments.
  • Still other embodiments of the present application provide a non-volatile computer-readable storage medium (hereinafter referred to as a computer-readable storage medium), where a computer program can be stored on the computer-readable storage medium, and the computer program is executed by a computer
  • a computer program can be stored on the computer-readable storage medium, and the computer program is executed by a computer
  • FIG. 1 shows a schematic diagram of the effect of the existing guided filtering.
  • FIG. 2 shows a flowchart of a disparity map optimization method provided by an embodiment of the present application.
  • FIG. 3 shows a structural block diagram of a disparity map optimization apparatus provided by an embodiment of the present application.
  • FIG. 4 shows a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Icons 100-electronic device; 110-processor; 120-memory; 400-disparity map optimization device, 410-acquisition module; 420-determination module; 430-guide filtering module.
  • the defect existing in optimizing the disparity map for the existing guided filtering technology (during the optimization process, the pixel values of other normal regions of the disparity map are destroyed, thereby causing error diffusion) is the applicant's experience and practice and The results obtained after careful study, therefore, the discovery process of the above-mentioned defects and the solutions proposed for the above-mentioned defects in the following embodiments of the present application should be regarded as contributions made by the applicant to the present application.
  • the embodiments of the present application provide a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium.
  • the smoothing range is constrained, thereby ensuring the optimized disparity map. Disparity values and the accuracy of the range.
  • the technology can be implemented by corresponding software, hardware and combination of software and hardware.
  • the embodiments of the present application are described in detail below.
  • two camera modules arranged at different positions such as dual-camera modules of a mobile phone or other point-and-shoot equipment, are used for the same shooting scene (
  • the two images obtained by photographing the object) may be referred to as the first image and the second image, respectively.
  • the first image and the second image may be images obtained by the two camera modules arranged on the left and right for the same object, wherein the camera module on the left
  • the image captured by the group is the left image
  • the image captured by the camera module on the right is the right image
  • the first image and the second image can be arranged up and down respectively.
  • the images captured by the two camera modules of the above are for the same object, wherein, the image captured by the upper camera module is the upper image, and the image captured by the lower camera module is the lower image.
  • mapping relationship between the first image and the second image
  • a disparity map between the first image and the second image can be obtained according to the coordinates between the pixel points having the mapping relationship.
  • the second image and the occluded area in the second image can be mapped out through the first image and the disparity map.
  • the above-mentioned disparity map can also be used in other application scenarios, for example, the above-mentioned disparity map can be used for stereo matching.
  • the essence of guided filtering is to smooth the input image.
  • the error may be caused by the existence of a certain occlusion area in the first image and/or the second image, or it may be due to the process of stereo matching, There is an error in the matching process between the first image and the second image), then the region with the error will also be weakened.
  • One of the weakening processes is: after setting the pixel value of the error region to 0, then taking the average pixel value of the pixel value of the error region and the local normal region adjacent to the error region, and then taking the error
  • the pixel values of the area and the local normal area are modified to the above average pixel values.
  • the existing parallax map processing technology cannot correctly process the pixel values of the regions where the error exists in the parallax map.
  • the left area in FIG. 1 is the disparity map before guided filtering
  • the right area in FIG. 1 is the disparity map after guided filtering.
  • Area A in Figure 1 is a local area where there is an error in the disparity map before guided filtering. In this local area, the borders of leaves are blurred and need to be guided and filtered to make them sharper and clearer.
  • Area B in Figure 1 is the local area corresponding to area A in the disparity map after guided filtering. In this local area, although the boundary of leaves becomes sharp and clear, the boundary of leaves can be clearly seen from area B. The pixel values of the black areas outside are corrupted by the pixel values of the gray borders.
  • An embodiment of the present application provides a disparity map optimization method.
  • the method constrains the smoothing range, thereby ensuring the disparity value of the optimized disparity map. and the accuracy of the range. The steps involved will be described below with reference to FIG. 2 .
  • Step S110 Acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image.
  • the first image and the second image may be two images captured at the same time by camera modules arranged in different positions for the same shooting scene.
  • calculation may be performed according to the first image and the second image, so as to obtain the initial disparity map.
  • an initial disparity map may be calculated based on the first image and the second image through a stereo matching algorithm.
  • stereo matching algorithm it is not within the scope of consideration of the embodiments of the present application, and correspondingly, the embodiments of the present application do not limit it.
  • a confidence map corresponding to the initial disparity map can also be obtained, and the confidence map is used to represent where there is an error in the corresponding disparity map, so as to facilitate subsequent evaluation of the initial disparity map after optimization.
  • the optimized effect of the optimized disparity map can also be obtained, and the confidence map is used to represent where there is an error in the corresponding disparity map, so as to facilitate subsequent evaluation of the initial disparity map after optimization.
  • Step S120 Determine an energy equation for guiding filtering according to the initial disparity map, the first image and the second image, where the energy equation may include a data item and a smoothing item.
  • the guided filtering technology adopted in the embodiments of the present application may implement guided filtering according to an energy equation; the energy equation includes a data item and a smoothing item.
  • the data items and smoothing terms of the guided filtering solutions provided by the embodiments of the present application are no longer simply associated with the input disparity map, but also exist with the first image and the second image. and the data item constitutes a constraint on the smoothing item, so that when the smoothing item acts on the initial disparity map, it is no longer smoothing any area of the initial disparity map, but smoothing the area that should be smoothed in the initial disparity map.
  • the data item E data may be determined according to the first image and the second image
  • the smoothing item E data may be determined according to the initial disparity map
  • the data item E data and the smoothing item E smooth Determine the energy equation E.
  • the data item may be composed in a matching manner, and the erroneous parallax can be corrected under the premise of maintaining the accuracy of the parallax.
  • I 1 (x) is the expression of the first image
  • I 2 (x+d) is the expression of the second image
  • d is the initial disparity map.
  • is the weight of the smooth item and the data item, which is preset by the staff, and the size of ⁇ can be adjusted according to the actual situation. It is worth pointing out that the size of ⁇ can be positively correlated with the degree of smoothness.
  • d x is the gradient of the initial disparity map in the abscissa direction
  • dy is the gradient of the initial disparity map in the ordinate direction
  • the initial values of d x and dy are preset by the staff, and d x and dy can be Adjust according to the actual situation. In general, the smaller the gradient, the smoother it is.
  • the direction of the coordinate axis of the abscissa is the direction of the center line of the two camera modules.
  • the direction of the coordinate axis of the abscissa can be the vertical direction;
  • the coordinate axis direction of the abscissa can be the horizontal direction.
  • the coordinate axis direction of the ordinate may be perpendicular to the coordinate axis direction of the abscissa.
  • w x is the smoothing weight in the abscissa direction
  • w y is the smoothing weight in the ordinate direction.
  • a guide map is required to guide smoothing.
  • the size of the smoothing weights w x , w y is controlled by the guide map.
  • the first image may be directly determined as a guide image.
  • the sizes of w x and w y are determined according to the first image.
  • other images, such as the second image may also be used as the guide image, which is not limited here.
  • Step S130 Perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  • the process of conducting guided filtering on the initial disparity map is the process of solving dx in the energy equation.
  • step S130 may include:
  • I 1x is the gradient of the first image in the abscissa direction
  • I 1y is the gradient of the first image in the ordinate direction.
  • delta is the first smoothing constraint parameter (exponential type)
  • EPSLON is the second smoothing constraint parameter (constant type).
  • the first smoothing constraint parameter and the second smoothing constraint parameter are used to constrain the above-mentioned smoothing term E smooth , and control the influence of the gradient of the guide image on the smoothing term E smooth . So far, w x and w y can be considered as known quantities.
  • I 2 (x+d,y) ⁇ I 1 (x,y) I 2 (x,y) ⁇ I 1 (x,y)+I 2xdx +I 2y dy.
  • I 2x is the gradient derivative of the second image in the abscissa direction
  • I 2y is the gradient derivative of the second image in the ordinate direction.
  • the gradient d x in the abscissa direction for the disparity map is only affected by the gradient of the first image.
  • d x is affected by the gradient of the first image in the abscissa and ordinate directions, and is also affected by the gradient of the second image in the abscissa and ordinate directions, Therefore, the degree of matching between the first image and the second image imposes constraints on dx , so that the degree of matching between the first image and the second image also imposes constraints on the smooth term E smooth including dx , so that it is possible to control
  • the smoothing term (the smoothing term is used to weaken the pixels in the image) smoothes the areas that should be smoothed in the initial disparity map, and ignores the areas that should not be smoothed; at the same time, the data item E data contains the first image and the first image.
  • the data item can also correct the error area in the initial disparity map to ensure The accuracy of the disparity value and the accuracy of the range in the optimized disparity map d'.
  • the solution process of d x may be limited, so as to further ensure the accuracy of the disparity map finally obtained.
  • the accuracy of the final disparity map can be ensured by the following methods:
  • the solution process can be restricted by judging whether the current solution to d x satisfies the preset rules
  • the optimized disparity map d′ corresponding to the currently obtained d x can be directly determined as the final disparity map
  • A3 Otherwise, perform the following steps 1 to 4 until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compare the gradient d x of the current initial disparity map in the abscissa direction with the current initial disparity map.
  • the corresponding optimized disparity map is determined as the final disparity map:
  • Step 1 Update the initial disparity map according to the optimized disparity map to obtain the current disparity map
  • Step 2 Calculate the gradient d x of the current disparity map in the abscissa direction according to the energy equation
  • Step 3 By superimposing the initial disparity map d and the gradient dx of the current initial disparity map in the abscissa direction, an optimized disparity map corresponding to the gradient dx of the current initial disparity map in the abscissa direction is obtained. ;
  • Step 4 Return to the step of judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule.
  • the above-mentioned preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, that is, the gradient d x of the initial disparity map in the abscissa direction is sufficient After it is small, it can be considered that the preset rules are satisfied.
  • the gradient d x of the initial disparity map in the abscissa direction indicates that there is a difference between the corresponding optimized disparity map obtained by solving d x in the previous time and the corresponding optimized disparity map obtained by solving d x this time.
  • the difference is small enough that the disparity map is getting closer and closer to the true value of the guide map. Therefore, the above smoothing process is smoothing according to the true value of the guide map, not according to the ideal state, so that the smoothing term can be controlled.
  • the areas that should be smoothed in the initial disparity map are smoothed, and the areas that should not be smoothed are ignored to ensure the accuracy of the disparity values and the accuracy of the value range in the final disparity map.
  • the above-mentioned preset rule may also be: the number of iterations currently used for the calculation of d x reaches the second threshold.
  • an embodiment of the present application further provides a disparity map optimization apparatus 400.
  • the disparity map optimization apparatus 400 may include: an acquisition module 410, a determination module 420, and a guided filtering module 430.
  • the acquisition module 410 may be configured to acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image, and the first image and the second image may be for the same Shooting scene, two images obtained from different shooting angles;
  • the determining module 420 may be configured to determine an energy equation for guided filtering according to the initial disparity map, the first image, and the second image, the energy equation may include a data term and a smoothing term;
  • the guided filtering module 430 may be configured to perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  • is the weight of the smooth item and the data item, and the data item may constitute a constraint effect on the smooth item.
  • I 1 (x) is the first image
  • I 2 (x+d) is the second image
  • d is the initial disparity map
  • x is the abscissa of any point in the first image
  • d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively
  • w x and w y are smoothing weights.
  • the guided filtering module 430 may be configured to: calculate the gradient d x of the initial disparity map in the abscissa direction according to the energy equation; d is superimposed with the gradient d x of the initial disparity map in the abscissa direction to obtain the optimized disparity map.
  • the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule ; the execution module may be configured to determine the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction as the final disparity map when the judgment module judges yes.
  • the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule
  • the execution module can be configured to perform the following process when the judgment module judges that it is no, until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compares it with the current
  • the optimized disparity map corresponding to the gradient d x of the initial disparity map in the abscissa direction is determined as the final disparity map: update the initial disparity map according to the optimized disparity map to obtain the current disparity map; According to the energy equation, calculate the gradient d x of the current disparity map in the abscissa direction; by superimposing the initial disparity map d and the gradient d x of the current initial disparity map in the abscissa direction, to obtain The optimized disparity map
  • the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current number of iterations satisfies the second threshold.
  • the guided image of the guided filtering may be the first image.
  • an embodiment of the present application further provides a computer-readable storage medium, where a computer program may be stored thereon, and when the computer program is run by a computer, the steps included in the above disparity map optimization method are executed.
  • an embodiment of the present application further provides an electronic device 100 for implementing the disparity map optimization method and apparatus of the embodiment of the present application.
  • the electronic device 100 may be provided with computing capability, and may perform guided filtering on the acquired image.
  • the electronic device 100 may be, but is not limited to, a personal computer (Personal computer, PC), a smart phone, a tablet computer, a Mobile Internet Device (Mobile Internet Device, MID), a personal digital assistant, a server, and other devices.
  • the server may be, but not limited to, a network server, a database server, a cloud server, and the like.
  • the electronic device 100 may include: a processor 110 and a memory 120 .
  • the components and structures of the electronic device 100 shown in FIG. 4 are only exemplary and not restrictive, and the electronic device 100 may also have other components and structures as required.
  • the electronic device 100 may further include a display screen for presenting the guided filtered results to the user.
  • the processor 110 , the memory 120 and other components that may appear in the electronic device 100 are directly or indirectly electrically connected to each other to realize data transmission or interaction.
  • the processor 110, the memory 120, and other possible components may be electrically connected to each other through one or more communication buses or signal lines.
  • the memory 120 may be configured to store a program, for example, a program corresponding to a disparity map optimization method or a disparity map optimization apparatus that will appear later.
  • the disparity map optimization apparatus may include at least one software function module that may be stored in the memory 120 in the form of software or firmware.
  • the software function modules included in the disparity map optimization apparatus may also be solidified in an operating system (operating system, OS) of the electronic device 100 .
  • OS operating system
  • the processor 110 may be configured to execute executable modules stored in the memory 120, such as software function modules or computer programs included in the disparity map optimization apparatus. After receiving the execution instruction, the processor 110 may execute a computer program, for example, execute: acquiring a first image, a second image, and an initial disparity map corresponding to the first image and the second image, the first image and the second image.
  • the image and the second image are two images captured by camera modules located at different positions at the same time for the same shooting scene; determined according to the initial disparity map, the first image and the second image
  • An energy equation used for guiding filtering the energy equation includes a data item and a smoothing term; guiding filtering is performed on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  • any embodiment of the present application may be applied to the processor 110 or implemented by the processor 110 .
  • the disparity map optimization method, device, electronic device, and computer-readable storage medium proposed in the embodiments of the present application, when the initial disparity map is guided filtering, the data items included in the energy equation used to perform the guided filtering And the smooth item is determined according to the initial disparity map, the first image and the second image used in stereo matching, and the data item constitutes a constraint on the smooth item, so that the smooth item is affected by the abscissa and ordinate of the first image.
  • the influence of the gradient in the direction is also affected by the gradient of the second image in the abscissa direction and the ordinate direction. Therefore, the degree of matching between the first image and the second image imposes constraints on the smoothing term, so that the smoothing can be controlled.
  • the item smoothes the areas that should be smoothed in the initial disparity map, and ignores the areas that should not be smoothed, so as to prevent errors from spreading to normal areas, so as to ensure the accuracy of the disparity values and the accuracy of the value range in the optimized disparity map.
  • each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which may contain one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by dedicated hardware-based systems that perform the specified functions or actions, Alternatively, it may be implemented in a combination of dedicated hardware and computer instructions.
  • each functional module in each embodiment of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
  • the functions are implemented in the form of software function modules and sold or used as independent products, they may be stored in a computer-readable storage medium.
  • the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the related technology or the part of the technical solution.
  • the computer software product is stored in a storage medium, including several
  • the instructions are used to cause a computer device (which may be a personal computer, a notebook computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .
  • the present application discloses a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium.
  • the method includes: acquiring a first image, a second image and an initial disparity map corresponding to the first image and the second image; An energy equation for conducting guided filtering, the energy equation including a data item and a smoothing term; performing guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  • the error can be prevented from spreading to the normal area, so as to ensure the accuracy of the disparity value and the accuracy of the value range in the optimized disparity map.
  • the disparity map optimization method, apparatus, electronic device and computer-readable storage medium of the present application are reproducible and can be applied in various industrial applications.
  • the disparity map optimization method of the present application can be applied to the field of image processing.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Processing (AREA)

Abstract

The present application relates to the field of image processing and relates to a disparity map optimization method and apparatus, and an electronic device and a computer-readable storage medium. The method comprises: obtaining a first image, a second image, and an initial disparity map corresponding to the first image and the second image; according to the initial disparity map, the first image, and the second image, determining an energy equation used for guiding filtering, the energy equation comprising a data item and a smooth item; and performing guiding filtering on the initial disparity map according to the energy equation, and obtaining an optimized disparity map. By means of the method, errors can be prevented from diffusing to a normal area, such that the accuracy of a disparity value and the accuracy of a value domain in the optimized disparity map are ensured.

Description

视差图优化方法、装置、电子设备及计算机可读存储介质Disparity map optimization method, apparatus, electronic device, and computer-readable storage medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2021年3月31日提交中国国家知识产权局的申请号为202110353871.1、名称为“视差图优化方法、装置、电子设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110353871.1 and the title "Disparity Map Optimization Method, Apparatus, Electronic Device and Computer-readable Storage Medium" filed with the State Intellectual Property Office of China on March 31, 2021, which The entire contents of this application are incorporated by reference.
技术领域technical field
本申请属于图像处理领域,具体涉及视差图优化方法、装置、电子设备及计算机可读存储介质。The present application belongs to the field of image processing, and in particular relates to a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium.
背景技术Background technique
在立体匹配算法中,可以计算出第一图像与第二图像之间的视差图,以便后续可以基于所得到的视图差进行一系列的后端应用,例如双摄重新聚焦、多图像的密集重建(MVS,Multi View System)等。In the stereo matching algorithm, the disparity map between the first image and the second image can be calculated, so that a series of back-end applications can be performed based on the obtained disparity, such as dual-camera refocusing and dense reconstruction of multiple images. (MVS, Multi View System) etc.
出于立体匹配的效率、执行立体匹配的设备的性能等众多因素的影响,在一些技术方案中,直接经过立体匹配算法得到的视差图中存在较多的误差区域(例如边界不清晰、边界粗糙、图像上有噪声等),从而导致视差图无法直接应用到后续的应用场景,因此,有对视差图进行优化处理的需求。Due to the influence of many factors such as the efficiency of stereo matching and the performance of the device performing stereo matching, in some technical solutions, there are many error areas (such as unclear boundaries, rough boundaries, etc.) in the disparity map obtained directly through the stereo matching algorithm. , there is noise on the image, etc.), so that the disparity map cannot be directly applied to subsequent application scenarios. Therefore, there is a need to optimize the disparity map.
在现有的视差图优化方法中,一般采用常规的引导滤波技术对视差图进行优化,例如WLS(Weighted Least-Squares),FGS(Fast Global Smooth)等。然而,对于常规的引导滤波技术而言,基本上都只考虑滤波前后的输入图像的平滑程度。若以视差图作为输入图像,且视差图本身就存在一定的误差,那么在经过引导滤波后,除了误差的像素值被平滑外,反而还会导致视差图的其他正常区域的像素值遭到破坏,从而导致误差扩散。In the existing disparity map optimization methods, conventional guided filtering techniques are generally used to optimize the disparity map, such as WLS (Weighted Least-Squares), FGS (Fast Global Smooth), and the like. However, for conventional guided filtering techniques, basically only the smoothness of the input image before and after filtering is considered. If the disparity map is used as the input image, and the disparity map itself has certain errors, after guided filtering, in addition to smoothing the pixel values of the errors, the pixel values of other normal areas of the disparity map will be destroyed. , resulting in error diffusion.
发明内容SUMMARY OF THE INVENTION
鉴于此,本申请提供了视差图优化方法、装置、电子设备及计算机可读存储介质,在对视差图进行优化时,对平滑的范围进行约束,从而保证优化后的视差图的视差值以及值域的准确性。In view of this, the present application provides a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium. When optimizing the disparity map, the smoothing range is constrained, so as to ensure the disparity value of the optimized disparity map and The accuracy of the range.
本申请的实施例是这样实现的:The embodiments of the present application are implemented as follows:
本申请的一些实施例提供了一种视差图优化方法,所述方法可以包括:获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像为针对同一拍摄场景、通过不同拍摄角度获取的两幅图像;根据所述初始视差图、第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程包括数据项及平滑项;根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。Some embodiments of the present application provide a disparity map optimization method, the method may include: acquiring a first image, a second image and an initial disparity map corresponding to the first image and the second image, the The first image and the second image are two images obtained from different shooting angles for the same shooting scene; the energy equation for guiding filtering is determined according to the initial disparity map, the first image and the second image , the energy equation includes a data item and a smoothing term; the initial disparity map is guided and filtered according to the energy equation to obtain an optimized disparity map.
在上述过程中,在对初始视差图进行引导滤波时,用于进行引导滤波的能量方程所包括的数据项以及平滑项可以根据立体匹配时所采用的初始视差图、第一图像以及第二图像来进行确定从而使得平滑项受到第一图像在横坐标方向以及纵坐标方向上的梯度的影响,还受到第二图像在横坐标方向以及纵坐标方向上的梯度的影响,因此,第一图像与第二图像之间的匹配程度对平滑项造成约束,从而可以控制平滑项对初始视差图中应该被平滑的区域进行平滑,且忽略不该平滑的区域,避免误差扩散到正常区域,以保证优化后的视差图中视差值的准确性和值域的准确性。In the above process, when conducting guided filtering on the initial disparity map, the data item and smoothing term included in the energy equation used for conducting the guided filtering may be based on the initial disparity map, the first image, and the second image used in stereo matching. so that the smooth term is affected by the gradient of the first image in the abscissa direction and the ordinate direction, and also by the gradient of the second image in the abscissa direction and the ordinate direction. Therefore, the first image and the The degree of matching between the second images constrains the smoothing term, so that the smoothing term can be controlled to smooth the areas that should be smoothed in the initial disparity map, and ignore the areas that should not be smoothed to prevent errors from spreading to normal areas to ensure optimization The accuracy of the disparity values and the accuracy of the range in the disparity map.
结合本申请的一些实施例,在一种可能的实施方式中,所述根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程可以包括:根据所述第一图像及所述第二图像确定出所述数据项E data;根据所述初始视差图确定出所述平滑项E data;基于公式E=min(E data+αE smooth),确定所述能量方程E;其中,α为所述平滑项与所述数据项的权重,所述数据项对所述平滑项构成约束作用。 With reference to some embodiments of the present application, in a possible implementation manner, the determining an energy equation for conducting guided filtering according to the initial disparity map, the first image, and the second image may include: according to The data item E data is determined from the first image and the second image; the smoothing item E data is determined according to the initial disparity map; based on the formula E=min(E data +αE smooth ), the The energy equation E; wherein, α is the weight of the smooth item and the data item, and the data item constitutes a constraint effect on the smooth item.
结合本申请的一些实施例,在一种可能的实施方式中,所述根据所述第一图像及所述第二图像确定出所述数据项E data以及所述根据所述初始视差图确定出所述平滑项E data可以包括:基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定所述数据项E data;基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定所述平滑项E smooth;其中,I 1(x)为所述第一图像,I 2(x+d)为所述第二图像,d为所述初始视差图,x为所述第一图像中的任意点的横坐标,d x、d y为所述初始视差图分别在横坐标方向上的梯度以及在纵坐标方向上的梯度,w x、w y为平滑权重。 With reference to some embodiments of the present application, in a possible implementation manner, the data item E data is determined according to the first image and the second image, and the data item E data is determined according to the initial disparity map. The smoothing item E data may include: determining the data item E data based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx; based on the formula E smooth =∫w x ( d x ) 2 +w y ( dy ) 2 dx, determine the smoothing term E smooth ; wherein, I 1 (x) is the first image, I 2 (x+d) is the second image, d is the initial disparity map, x is the abscissa of any point in the first image, dx and dy are the gradients of the initial disparity map in the abscissa direction and the ordinate direction respectively , w x and w y are smoothing weights.
结合本申请的一些实施例,在一种可能的实施方式中,所述根据所述能量方程对所述初始视差图进行引导滤波而得到优化后的视差图可以包括:根据所述能量方程,计算所述初始视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与所述初始视差图在横坐标方向上的梯度d x相叠加,获得所述优化后的视差图。 With reference to some embodiments of the present application, in a possible implementation manner, performing guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map may include: according to the energy equation, calculating the gradient d x of the initial disparity map in the abscissa direction; the optimized disparity map is obtained by superimposing the initial disparity map d and the gradient d x of the initial disparity map in the abscissa direction.
结合本申请的一些实施例,在一种可能的实施方式中,所述方法还可以包括:判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;在判断为是时,确定与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图为最终的视差图。 With reference to some embodiments of the present application, in a possible implementation manner, the method may further include: judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule; , and the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map.
结合本申请的一些实施例,在一种可能的实施方式中,所述方法还可以包括:在判断为否时,执行以下步骤,直至当前的初始视差图在横坐标方向上的梯度d x满足所述预设规 则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为所述最终的视差图: With reference to some embodiments of the present application, in a possible implementation manner, the method may further include: when the judgment is no, performing the following steps until the gradient d x of the current initial disparity map in the abscissa direction satisfies After the preset rule, the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map:
根据所述优化后的视差图更新所述初始视差图,得到当前的视差图;根据所述能量方程,计算所述当前的视差图在横坐标方向上的d x;通过将所述初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图;返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足所述预设规则的步骤。 Update the initial disparity map according to the optimized disparity map to obtain the current disparity map; calculate the d x of the current disparity map in the abscissa direction according to the energy equation; d is superimposed with the gradient d x of the current initial disparity map in the abscissa direction to obtain an optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction; return to judge the current initial disparity map The step of whether the gradient d x in the abscissa direction satisfies the preset rule.
通过该方式,可以进一步的保证最终得到的视差图的准确性。In this way, the accuracy of the finally obtained disparity map can be further guaranteed.
结合本申请的一些实施例,在一种可能的实施方式中,所述预设规则可以为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,和/或当前的迭代次数满足第二阈值。 With reference to some embodiments of the present application, in a possible implementation, the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current iteration The number of times satisfies the second threshold.
结合本申请的一些实施例,在一种可能的实施方式中,所述引导滤波的引导图可以为所述第一图像。With reference to some embodiments of the present application, in a possible implementation manner, the guide map of the guide filter may be the first image.
本申请的另一些实施例提供了一种视差图优化装置,所述装置可以包括:获取模块、确定模块以及引导滤波模块。获取模块可以配置成用于获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像可以为针对同一拍摄场景、通过不同拍摄角度获取的两幅图像;确定模块可以配置成用于根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的方程,所述能量方程可以包括数据项及平滑项;引导滤波模块可以配置成用于根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。Other embodiments of the present application provide a disparity map optimization apparatus, and the apparatus may include: an acquisition module, a determination module, and a guided filtering module. The acquisition module may be configured to acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image, and the first image and the second image may be for the same shooting scene, two images obtained through different shooting angles; the determining module may be configured to determine an equation for conducting guided filtering according to the initial disparity map, the first image and the second image, the energy equation A data item and a smoothing item may be included; the guided filtering module may be configured to perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
结合本申请的另一些实施例,在一种可能的实施方式中,所述确定模块可以配置成用于:根据所述第一图像及所述第二图像确定出所述数据项E data;根据所述初始视差图确定出所述平滑项E data;基于公式E=min(E data+αE smooth),确定所述能量方程E; With reference to other embodiments of the present application, in a possible implementation manner, the determining module may be configured to: determine the data item E data according to the first image and the second image; The smooth term E data is determined from the initial disparity map; the energy equation E is determined based on the formula E=min(E data +αE smooth );
其中,α为所述平滑项与所述数据项的权重,所述数据项可以对所述平滑项构成约束作用。Wherein, α is the weight of the smooth item and the data item, and the data item may constitute a constraint effect on the smooth item.
结合本申请的另一些实施例,在一种可能的实施方式中,所述确定模块可以配置成用于:基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定所述数据项E data;基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定所述平滑项E smoothWith reference to other embodiments of the present application, in a possible implementation manner, the determining module may be configured to: based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx, the data item E data is determined; based on the formula E smooth =∫w x (d x ) 2 +w y (d y ) 2 dx, the smoothing item E smooth is determined;
其中,I 1(x)为所述第一图像,I 2(x+d)为所述第二图像,d为所述初始视差图,x为所 述第一图像中的任意点的横坐标,d x、d y为所述初始视差图分别在横坐标方向上的梯度以及在纵坐标方向上的梯度,w x、w y为平滑权重。 Wherein, I 1 (x) is the first image, I 2 (x+d) is the second image, d is the initial disparity map, and x is the abscissa of any point in the first image , d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively, and w x and w y are smoothing weights.
结合本申请的另一些实施例,在一种可能的实施方式中,所述引导滤波模块可以配置成用于:根据所述能量方程,计算所述初始视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与所述初始视差图在横坐标方向上的梯度d x相叠加,获得所述优化后的视差图。 With reference to other embodiments of the present application, in a possible implementation, the guided filtering module may be configured to: according to the energy equation, calculate the gradient d x of the initial disparity map in the abscissa direction ; By superimposing the initial disparity map d and the gradient d x of the initial disparity map in the abscissa direction, the optimized disparity map is obtained.
结合本申请的另一些实施例,在一种可能的实施方式中,所述装置还可以包括判断模块以及执行模块,所述判断模块可以配置成用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;所述执行模块可以配置成用于在所述判断模块判断为是时确定与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图为最终的视差图。 With reference to other embodiments of the present application, in a possible implementation manner, the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge that the current initial disparity map is in the abscissa direction Whether the gradient d x of the current initial disparity map satisfies the preset rule; the execution module may be configured to determine the optimized disparity corresponding to the gradient d x of the current initial disparity map in the abscissa direction when the judgment module judges that it is yes The picture shows the final disparity map.
结合本申请的另一些实施例,在一种可能的实施方式中,所述装置还可以包括判断模块以及执行模块,所述判断模块可以用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;所述执行模块可以用于在所述判断模块判断为否时执行以下过程,直至当前的初始视差图在横坐标方向上的梯度d x满足所述预设规则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为所述最终的视差图: With reference to other embodiments of the present application, in a possible implementation manner, the apparatus may further include a judgment module and an execution module, and the judgment module may be used to judge the gradient of the current initial disparity map in the abscissa direction Whether d x satisfies the preset rule; the execution module may be configured to perform the following process when the judgment module judges no, until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule , and then determine the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction as the final disparity map:
根据所述优化后的视差图更新所述初始视差图,得到当前的视差图;根据所述能量方程,计算所述当前的视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图;返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则的步骤。 Update the initial disparity map according to the optimized disparity map to obtain the current disparity map; calculate the gradient d x of the current disparity map in the abscissa direction according to the energy equation; Figure d is superimposed with the gradient d x of the current initial disparity map in the abscissa direction to obtain an optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction; return to judge the current initial disparity The step of whether the gradient d x of the graph in the abscissa direction satisfies the preset rules.
结合本申请的另一些实施例,在一种可能的实施方式中,所述预设规则可以为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,和/或当前的迭代次数满足第二阈值。 With reference to other embodiments of the present application, in a possible implementation manner, the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current initial disparity map The number of iterations satisfies the second threshold.
结合本申请的另一些实施例,在一种可能的实施方式中,所述引导滤波的引导图可以为所述第一图像。With reference to other embodiments of the present application, in a possible implementation manner, the guide map of the guide filter may be the first image.
本申请的又一些实施例提供了一种电子设备,所述电子设备可以包括:存储器和处理器,所述存储器和所述处理器连接;所述存储器用于存储程序;所述处理器调用存储于所述存储器中的程序,以执行本申请的上述一些实施例和/或结合上述一些实施例的任一种可 能的实施方式提供的方法。Still other embodiments of the present application provide an electronic device, the electronic device may include: a memory and a processor, the memory is connected to the processor; the memory is used for storing a program; the processor invokes the storage The program stored in the memory is used to execute some of the above-mentioned embodiments of the present application and/or the methods provided in combination with any possible implementation manner of some of the above-mentioned embodiments.
本申请的再一些实施例提供了一种非易失性计算机可读取存储介质(以下简称计算机可读存储介质),计算机可读存储介质上可以存储有计算机程序,所述计算机程序被计算机运行时可以执行本申请的上述一些实施例和/或结合上述一些实施例的任一种可能的实施方式提供的方法。Still other embodiments of the present application provide a non-volatile computer-readable storage medium (hereinafter referred to as a computer-readable storage medium), where a computer program can be stored on the computer-readable storage medium, and the computer program is executed by a computer The above-mentioned embodiments of the present application and/or the methods provided in combination with any possible implementation manner of the above-mentioned embodiments can be executed.
本申请的其他特征和优点将在随后的说明书阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请实施例而了解。本申请的目的和其他优点可通过在所写的说明书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present application will be set forth in the description which follows, and, in part, will be apparent from the description, or may be learned by practice of the embodiments of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and drawings.
附图说明Description of drawings
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。通过附图所示,本申请的上述及其它目的、特征和优势将更加清晰。在全部附图中相同的附图标记指示相同的部分。并未刻意按实际尺寸等比例缩放绘制附图,重点在于示出本申请的主旨。In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the accompanying drawings required in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some implementations of the present application. For example, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort. The above and other objects, features and advantages of the present application will be more apparent from the accompanying drawings. The same reference numerals refer to the same parts throughout the drawings. The drawings are not intentionally scaled to actual size, and the emphasis is on illustrating the subject matter of the present application.
图1示出现有的引导滤波的效果示意图。FIG. 1 shows a schematic diagram of the effect of the existing guided filtering.
图2示出本申请实施例提供的一种视差图优化方法的流程图。FIG. 2 shows a flowchart of a disparity map optimization method provided by an embodiment of the present application.
图3示出本申请实施例提供的一种视差图优化装置的结构框图。FIG. 3 shows a structural block diagram of a disparity map optimization apparatus provided by an embodiment of the present application.
图4示出本申请实施例提供的一种电子设备的结构示意图。FIG. 4 shows a schematic structural diagram of an electronic device provided by an embodiment of the present application.
图标:100-电子设备;110-处理器;120-存储器;400-视差图优化装置、410-获取模块;420-确定模块;430-引导滤波模块。Icons: 100-electronic device; 110-processor; 120-memory; 400-disparity map optimization device, 410-acquisition module; 420-determination module; 430-guide filtering module.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本申请的描述中诸如“第一”、“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that like numerals and letters refer to like items in the following figures, so once an item is defined in one figure, it does not require further definition and explanation in subsequent figures. Meanwhile, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Moreover, the term "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, whereby a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not expressly listed, Or also include elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
再者,本申请中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。Furthermore, the term "and/or" in this application is only an association relationship to describe related objects, indicating that there can be three kinds of relationships, for example, A and/or B, it can mean that A exists alone, and A and B exist at the same time. B, there are three cases of B alone.
此外,针对现有的引导滤波技术对视差图进行优化时所存在的缺陷(优化过程中,使得视差图的其他正常区域的像素值遭到破坏,从而导致误差扩散)是申请人在经过实践并仔细研究后得出的结果,因此,上述缺陷的发现过程以及在下文中本申请实施例针对上述缺陷所提出的解决方案,都应该被认定为申请人对本申请做出的贡献。In addition, the defect existing in optimizing the disparity map for the existing guided filtering technology (during the optimization process, the pixel values of other normal regions of the disparity map are destroyed, thereby causing error diffusion) is the applicant's experience and practice and The results obtained after careful study, therefore, the discovery process of the above-mentioned defects and the solutions proposed for the above-mentioned defects in the following embodiments of the present application should be regarded as contributions made by the applicant to the present application.
为了解决上述问题,本申请实施例提供了视差图优化方法、装置、电子设备及计算机可读存储介质,在对视差图进行优化时,对平滑的范围进行约束,从而保证优化后的视差图的视差值以及值域的准确性。In order to solve the above problems, the embodiments of the present application provide a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium. When optimizing the disparity map, the smoothing range is constrained, thereby ensuring the optimized disparity map. Disparity values and the accuracy of the range.
该技术可采用相应的软件、硬件以及软硬结合的方式实现。以下对本申请实施例进行详细介绍。The technology can be implemented by corresponding software, hardware and combination of software and hardware. The embodiments of the present application are described in detail below.
下面将针对本申请所提供的视差图优化方法进行介绍。The following will introduce the disparity map optimization method provided by this application.
在本申请实施例中,两个设置在不同位置的相机模组,例如可以是手机或其他点射设备的双摄模组,在同一时间或者间隔较短的前后两个时刻,针对同一拍摄场景(对象)进行拍摄所得到的两张图像可以分别称之为第一图像以及第二图像。In the embodiment of the present application, two camera modules arranged at different positions, such as dual-camera modules of a mobile phone or other point-and-shoot equipment, are used for the same shooting scene ( The two images obtained by photographing the object) may be referred to as the first image and the second image, respectively.
可以理解,由于两个相机模组的设置位置不同,因此,第一图像与第二图像所对应的拍摄角度也不同。It can be understood that since the installation positions of the two camera modules are different, the shooting angles corresponding to the first image and the second image are also different.
其中,当上述两个不同的相机模组呈左右排列关系时,第一图像与第二图像可以分别为左右排列的两个相机模组针对同一对象拍摄得到的图像,其中,由左边的相机模组拍摄得到的图像为左图,由右边的相机模组拍摄得到的图像为右图;当上述两个不同的相机模组呈上下排列关系时,第一图像与第二图像可以分别为上下排列的两个相机模组针对同一对象拍摄得到的图像,其中,由上边的相机模组拍摄得到的图像为上图,由下边的相机模组拍摄得到的图像为下图。Wherein, when the above-mentioned two different camera modules are arranged in a left-right relationship, the first image and the second image may be images obtained by the two camera modules arranged on the left and right for the same object, wherein the camera module on the left The image captured by the group is the left image, and the image captured by the camera module on the right is the right image; when the above two different camera modules are arranged in an up-down relationship, the first image and the second image can be arranged up and down respectively. The images captured by the two camera modules of the above are for the same object, wherein, the image captured by the upper camera module is the upper image, and the image captured by the lower camera module is the lower image.
在本申请实施例中,第一图像与第二图像之间存在一定的映射关系,根据具有映射关系的像素点之间的坐标可以获取第一图像与第二图像之间的视差图。In the embodiment of the present application, there is a certain mapping relationship between the first image and the second image, and a disparity map between the first image and the second image can be obtained according to the coordinates between the pixel points having the mapping relationship.
值得指出的是,在第一图像与视差图已知的前提下,可以通过第一图像与视差图,映射出第二图像以及第二图像中被遮挡的区域。It is worth noting that, on the premise that the first image and the disparity map are known, the second image and the occluded area in the second image can be mapped out through the first image and the disparity map.
当然,在一些实施方式中,上述视差图也可以用于其他应用场景,例如可以通过上述视差图用于进行立体匹配。Of course, in some embodiments, the above-mentioned disparity map can also be used in other application scenarios, for example, the above-mentioned disparity map can be used for stereo matching.
在进行立体匹配时,若过多地注重匹配效率,可能导致经过立体匹配得到的视差图中存在误差区域,因此需要通过引导滤波技术对视差图进行优化。When performing stereo matching, if too much attention is paid to matching efficiency, it may lead to an error area in the disparity map obtained through stereo matching. Therefore, it is necessary to optimize the disparity map through guided filtering technology.
引导滤波的本质是对输入图像进行平滑处理。在此基础上,若作为输入图像的视差图本身就存在误差(误差可能是由于第一图像和/或第二图像中存在一定的遮挡区域导致,也可能是由于在进行立体匹配的过程中,第一图像与第二图像之间的匹配过程存在误差),那么将会导致存在误差的区域也被弱化。The essence of guided filtering is to smooth the input image. On this basis, if there is an error in the disparity map used as the input image (the error may be caused by the existence of a certain occlusion area in the first image and/or the second image, or it may be due to the process of stereo matching, There is an error in the matching process between the first image and the second image), then the region with the error will also be weakened.
其中的一种弱化的过程为:将存在误差的区域的像素值置0后,再将误差的区域和与该误差的区域相邻的局部正常区域的像素值取平均像素值,然后将存在误差的区域以及局部正常区域的像素值修改为上述平均像素值。One of the weakening processes is: after setting the pixel value of the error region to 0, then taking the average pixel value of the pixel value of the error region and the local normal region adjacent to the error region, and then taking the error The pixel values of the area and the local normal area are modified to the above average pixel values.
如此操作后,虽然误差的区域被弱化,但是与误差的区域相邻的正常区域的像素值也被迫发生改变,从而会导致误差扩散到正常的区域。即现有的视差图处理技术不能正确地处理视差图中存在误差的区域的像素值。After doing so, although the error area is weakened, the pixel values of the normal area adjacent to the error area are also forced to change, which will cause the error to spread to the normal area. That is, the existing parallax map processing technology cannot correctly process the pixel values of the regions where the error exists in the parallax map.
如图1所示,在图1中的左侧区域为引导滤波之前的视差图,在图1中右侧区域为经过引导滤波后的视差图。As shown in FIG. 1 , the left area in FIG. 1 is the disparity map before guided filtering, and the right area in FIG. 1 is the disparity map after guided filtering.
图1中的A区域为经过引导滤波之前的视差图中存在误差的局部区域,在该局部区域中,树叶的边界较为模糊,需要经过引导滤波使之变得更为锐利、更为清晰。图1中的B区域为经过引导滤波之后的视差图中与A区域对应的局部区域,在该局部区域中,虽然树叶的边界变得锐利、清晰,但是从B区域中可以明显看出树叶边界之外的黑色区域的像素值被灰色的边界的像素值破坏。Area A in Figure 1 is a local area where there is an error in the disparity map before guided filtering. In this local area, the borders of leaves are blurred and need to be guided and filtered to make them sharper and clearer. Area B in Figure 1 is the local area corresponding to area A in the disparity map after guided filtering. In this local area, although the boundary of leaves becomes sharp and clear, the boundary of leaves can be clearly seen from area B. The pixel values of the black areas outside are corrupted by the pixel values of the gray borders.
为了避免上述问题,请参阅图2,本申请实施例提供一种视差图优化方法,该方法在对视差图进行优化时,对平滑的范围进行约束,从而保证优化后的视差图的视差值以及值域的准确性。下面将结合图2对其所包含的步骤进行说明。In order to avoid the above problem, please refer to FIG. 2 . An embodiment of the present application provides a disparity map optimization method. When optimizing the disparity map, the method constrains the smoothing range, thereby ensuring the disparity value of the optimized disparity map. and the accuracy of the range. The steps involved will be described below with reference to FIG. 2 .
步骤S110:获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图。Step S110: Acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image.
其中,第一图像与第二图像可以为设置在不同位置的相机模组在同一时间针对同一拍摄场景所拍摄得到的两幅图像。Wherein, the first image and the second image may be two images captured at the same time by camera modules arranged in different positions for the same shooting scene.
对于本申请实施例而言,在获取到第一图像以及第二图像后,可以根据第一图像以及第二图像进行计算,从而得到初始视差图。For the embodiment of the present application, after the first image and the second image are acquired, calculation may be performed according to the first image and the second image, so as to obtain the initial disparity map.
当视差图应用于立体匹配场景时,可以通过立体匹配算法来基于第一图像以及第二图像计算初始视差图。至于采用何种立体匹配算法来计算初始视差图,不在本申请实施例的考虑范围之内,相应的,本申请实施例也不对其进行限制。When the disparity map is applied to a stereo matching scene, an initial disparity map may be calculated based on the first image and the second image through a stereo matching algorithm. As for which stereo matching algorithm is used to calculate the initial disparity map, it is not within the scope of consideration of the embodiments of the present application, and correspondingly, the embodiments of the present application do not limit it.
当然,在一些实施方式中,还可以获取与初始视差图对应的置信度图,该置信度图用于表征对应的视差图中哪里存在误差,从而便于后续在对初始视差图进行优化后,评估优化后的视差图的优化效果。Of course, in some embodiments, a confidence map corresponding to the initial disparity map can also be obtained, and the confidence map is used to represent where there is an error in the corresponding disparity map, so as to facilitate subsequent evaluation of the initial disparity map after optimization. The optimized effect of the optimized disparity map.
步骤S120:根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程可以包括数据项及平滑项。Step S120: Determine an energy equation for guiding filtering according to the initial disparity map, the first image and the second image, where the energy equation may include a data item and a smoothing item.
本申请实施例所采用的引导滤波技术可以根据能量方程来实现引导滤波;能量方程中包括数据项以及平滑项。The guided filtering technology adopted in the embodiments of the present application may implement guided filtering according to an energy equation; the energy equation includes a data item and a smoothing item.
区别于现有的引导滤波方案的是,本申请实施例所提供的引导滤波方案的数据项以及平滑项不再单纯地只与输入的视差图存在关联,还与第一图像以及第二图像存在关联,且数据项对平滑项构成约束作用,以便平滑项作用到初始视差图时,不再是对初始视差图的任意区域进行平滑,而是针对初始视差图的应该被平滑的区域进行平滑。Different from the existing guided filtering solutions, the data items and smoothing terms of the guided filtering solutions provided by the embodiments of the present application are no longer simply associated with the input disparity map, but also exist with the first image and the second image. and the data item constitutes a constraint on the smoothing item, so that when the smoothing item acts on the initial disparity map, it is no longer smoothing any area of the initial disparity map, but smoothing the area that should be smoothed in the initial disparity map.
可选的,在一些实施方式中,可以根据第一图像以及第二图像确定出数据项E data,根据初始视差图确定出平滑项E data,然后再根据数据项E data以及平滑项E smooth,确定出能量方程E。 Optionally, in some embodiments, the data item E data may be determined according to the first image and the second image, the smoothing item E data may be determined according to the initial disparity map, and then according to the data item E data and the smoothing item E smooth , Determine the energy equation E.
例如,可以基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定数据项E data。该数据项可以是以匹配的方式组成,能够保持视差的准确性的前提下,矫正错误的视差。例如,可以基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定平滑项E smooth,平滑项起到引导滤波的作用。 For example, the data item E data may be determined based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx. The data item may be composed in a matching manner, and the erroneous parallax can be corrected under the premise of maintaining the accuracy of the parallax. For example, the smoothing term E smooth may be determined based on the formula E smooth =∫w x (d x ) 2 +w y (d y ) 2 dx, and the smoothing term plays a role of guiding filtering.
再例如,可以基于公式E=min(E data+αE smooth),确定能量方程E。 For another example, the energy equation E may be determined based on the formula E=min(E data +αE smooth ).
其中,I 1(x)为第一图像的表达式,I 2(x+d)为第二图像的表达式。 Wherein, I 1 (x) is the expression of the first image, and I 2 (x+d) is the expression of the second image.
d为初始视差图。d is the initial disparity map.
α为平滑项与数据项的权重,由工作人员预先设置,且可以根据实际情况对α的大小进行调整。值得指出的是,α的大小可以与平滑程度呈正相关关系。α is the weight of the smooth item and the data item, which is preset by the staff, and the size of α can be adjusted according to the actual situation. It is worth pointing out that the size of α can be positively correlated with the degree of smoothness.
d x为初始视差图在横坐标方向上的梯度,d y为初始视差图在纵坐标方向上的梯度,且d x与d y的初始数值由工作人员预先设置,且d x与d y可以根据实际情况进行调整。一般而言,梯度越小,越平滑。 d x is the gradient of the initial disparity map in the abscissa direction, dy is the gradient of the initial disparity map in the ordinate direction, and the initial values of d x and dy are preset by the staff, and d x and dy can be Adjust according to the actual situation. In general, the smaller the gradient, the smoother it is.
其中,横坐标的坐标轴方向取两个相机模组的中心连线方向,例如两个相机模组呈上下排布时,横坐标的坐标轴方向可以为竖直方向;再例如两个相机模组呈左右排布时,横坐标的坐标轴方向可以为水平方向。The direction of the coordinate axis of the abscissa is the direction of the center line of the two camera modules. For example, when the two camera modules are arranged up and down, the direction of the coordinate axis of the abscissa can be the vertical direction; When the groups are arranged left and right, the coordinate axis direction of the abscissa can be the horizontal direction.
纵坐标的坐标轴方向可以与横坐标的坐标轴方向垂直。The coordinate axis direction of the ordinate may be perpendicular to the coordinate axis direction of the abscissa.
w x为横坐标方向上的平滑权重,w y为纵坐标方向上的平滑权重。 w x is the smoothing weight in the abscissa direction, and w y is the smoothing weight in the ordinate direction.
在进行引导滤波时,需要一张引导图引导平滑。平滑权重w x、w y的大小受到引导图的 控制。在一些实施方式中,可以直接将第一图像确定为引导图。在这种实施方式下,w x、w y的大小根据第一图像来确定。当然,在其他实施方式中,也可以采用其他的图像,例如第二图像作为引导图,此处不做过多限定。 When conducting guided filtering, a guide map is required to guide smoothing. The size of the smoothing weights w x , w y is controlled by the guide map. In some embodiments, the first image may be directly determined as a guide image. In this embodiment, the sizes of w x and w y are determined according to the first image. Of course, in other embodiments, other images, such as the second image, may also be used as the guide image, which is not limited here.
x为第一图像中的任意点的横坐标;min表征能量方程最小化。x is the abscissa of any point in the first image; min represents the minimization of the energy equation.
步骤S130:根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。Step S130: Perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
在本申请实施例中,当两个相机模组呈上下排布时,主要是针对图像的列方向上进行优化,当两个相机模组呈左右排布时,主要是针对图像的行方向上进行优化,因此,对初始视差图进行引导滤波的过程,即是对能量方程中的d x进行求解的过程。 In the embodiment of the present application, when the two camera modules are arranged up and down, the optimization is mainly performed for the column direction of the image, and when the two camera modules are arranged left and right, the optimization is mainly performed for the row direction of the image. Optimization, therefore, the process of conducting guided filtering on the initial disparity map is the process of solving dx in the energy equation.
在一些实施例中,步骤S130可以包括:In some embodiments, step S130 may include:
根据能量方程,计算初始视差图d在横坐标方向上的梯度d xAccording to the energy equation, calculate the gradient d x of the initial disparity map d in the abscissa direction;
通过将初始视差图d与初始视差图在横坐标方向上的梯度d x相叠加,即d′=d+d x,获得所述优化后的视差图d′。 The optimized disparity map d' is obtained by superimposing the initial disparity map d and the gradient dx of the initial disparity map in the abscissa direction, that is, d'=d+ dx .
下面将针对求解d x的过程进行介绍。 The following will introduce the process of solving dx .
(1)假设平滑权重w x、w y的表达式如下: (1) Suppose the expressions of the smoothing weights w x and w y are as follows:
w x=exp(-delta*I 1x)+EPSLON; w x =exp(-delta*I 1x )+EPSLON;
w y=exp(-delta*I 1y)+EPSLON。 w y =exp(-delta*I 1y )+EPSLON.
其中,I 1x为第一图像在横坐标方向上的梯度,I 1y为第一图像在纵坐标方向上的梯度。 Wherein, I 1x is the gradient of the first image in the abscissa direction, and I 1y is the gradient of the first image in the ordinate direction.
delta为第一平滑约束参数(指数类型),EPSLON为第二平滑约束参数(常数类型)。第一平滑约束参数与第二平滑约束参数用于约束上述平滑项E smooth,控制引导图的梯度对平滑项E smooth的影响。至此,可以将w x、w y认为是已知量。 delta is the first smoothing constraint parameter (exponential type), and EPSLON is the second smoothing constraint parameter (constant type). The first smoothing constraint parameter and the second smoothing constraint parameter are used to constrain the above-mentioned smoothing term E smooth , and control the influence of the gradient of the guide image on the smoothing term E smooth . So far, w x and w y can be considered as known quantities.
(2)对能量方程进行改写:(2) Rewrite the energy equation:
(d)=min∫((I 2(x+d,y)-I 1(x,y)) 2+α(w x(d x) 2+w y(d y) 2))dx。 (d)=min∫((I 2 (x+d,y)−I 1 (x,y)) 2 +α(w x (d x ) 2 +w y (d y ) 2 ))dx.
(3)将改写后的能量方程进行泰勒展开:(3) Taylor expansion of the rewritten energy equation:
I 2(x+d,y)-I 1(x,y)=I 2(x,y)-I 1(x,y)+I 2xdx+I 2ydy。 I 2 (x+d,y)−I 1 (x,y)=I 2 (x,y)−I 1 (x,y)+I 2xdx +I 2y dy.
其中,I 2x为第二图像在横坐标方向上的梯度导数,I 2y为第二图像在纵坐标方向上的梯度导数。 Wherein, I 2x is the gradient derivative of the second image in the abscissa direction, and I 2y is the gradient derivative of the second image in the ordinate direction.
进一步的,上述公式可以调整为如下形式:Further, the above formula can be adjusted to the following form:
min∫((I 2(x,y)-I 1(x,y)+I 2xdx+I 2ydy) 2+α(w x(d x) 2+w y(d y) 2))dx,以方便对d x以及对d y进行求导。 min∫((I 2 (x,y)-I 1 (x,y)+I 2x dx+I 2y dy) 2 +α(w x (d x ) 2 +w y (d y ) 2 ))dx , to facilitate the derivation of d x and dy .
(4)对min∫((I 2(x,y)-I 1(x,y)+I 2xdx+I 2ydy) 2+α(w x(d x) 2+w y(d y) 2))dx中的d x以及d y求一阶导,并令求导结果为0,得到如下的方程组: (4) For min∫((I 2 (x,y)-I 1 (x,y)+I 2x dx+I 2y dy) 2 +α(w x (d x ) 2 +w y (d y ) 2 )) Calculate the first derivative of d x and d y in dx, and set the derivation result to 0 to obtain the following equation system:
Figure PCTCN2021130994-appb-000001
Figure PCTCN2021130994-appb-000001
上述方程组为典型的关于d x以及d y的线性方程,可以重写为以下方程组: The above equation system is a typical linear equation about d x and d y , which can be rewritten as the following equation system:
Figure PCTCN2021130994-appb-000002
Figure PCTCN2021130994-appb-000002
(5)将重写后的方程组调整为Ax=b的矩阵形式,得到如下线性矩阵方程组:(5) Adjust the rewritten equation system to the matrix form of Ax=b, and obtain the following linear matrix equation system:
Figure PCTCN2021130994-appb-000003
Figure PCTCN2021130994-appb-000003
(6)采用现有的方式对上述线性矩阵方程组进行求解,例如采用高斯-赛德尔迭代法(Gauss–Seidel method)、雅克比法(Jacobi method)、逐次超松弛迭代法(SORmethod),从而得到初始视差图在横坐标方向上的梯度d x(6) Solve the above-mentioned linear matrix equation system by using the existing method, such as Gauss-Seidel method, Jacobi method, and successive over-relaxation iterative method (SOR method), so as to Obtain the gradient d x of the initial disparity map in the abscissa direction.
在得到d x后,可以基于公式d′=d+d x,得到针对初始视差图d进行优化后的视差图d′。 After d x is obtained, the disparity map d ′ optimized for the initial disparity map d can be obtained based on the formula d′=d+d x .
在传统的引导滤波方案中,对于视差图在横坐标方向上的梯度d x只受到第一图像梯度的影响。在本申请的上述对于d x的求解过程中,d x受到第一图像在横坐标、纵坐标方向上的梯度的影响,还受到第二图像在横坐标、纵坐标方向上的梯度的影响,因此,第一图像与第二图像之间的匹配程度对d x造成约束,从而使得第一图像与第二图像之间的匹配程度对包括d x的平滑项E smooth也造成约束,从而可以控制平滑项(平滑项用于对图像中的像素进行弱化处理)对初始视差图中应该被平滑的区域进行平滑,且忽略不该平滑的区域;同时,数据项E data中存在第一图像与第二图像之间的匹配关系(体现在数据项E data中的I 2(x+d)-I 1(x)),因此,数据项还可以对初始视差图中的误差区域进行纠正,以保证优化后的视差图d′中视差值的准确性和值域的准确性。 In the traditional guided filtering scheme, the gradient d x in the abscissa direction for the disparity map is only affected by the gradient of the first image. In the above-mentioned solution process for d x of the present application, d x is affected by the gradient of the first image in the abscissa and ordinate directions, and is also affected by the gradient of the second image in the abscissa and ordinate directions, Therefore, the degree of matching between the first image and the second image imposes constraints on dx , so that the degree of matching between the first image and the second image also imposes constraints on the smooth term E smooth including dx , so that it is possible to control The smoothing term (the smoothing term is used to weaken the pixels in the image) smoothes the areas that should be smoothed in the initial disparity map, and ignores the areas that should not be smoothed; at the same time, the data item E data contains the first image and the first image. The matching relationship between the two images (I 2 (x+d)-I 1 (x) in the data item E data ), therefore, the data item can also correct the error area in the initial disparity map to ensure The accuracy of the disparity value and the accuracy of the range in the optimized disparity map d'.
在一些可选的实施方式中,为了尽可能地保证视差图的准确性,可以对d x的求解过程进行限制,从而进一步地确保最终得到的视差图的准确性。 In some optional embodiments, in order to ensure the accuracy of the disparity map as much as possible, the solution process of d x may be limited, so as to further ensure the accuracy of the disparity map finally obtained.
具体的,在一些实施方式中,可以通过如下方式来确保最终得到的视差图的准确性:Specifically, in some embodiments, the accuracy of the final disparity map can be ensured by the following methods:
A1:可以通过判断当前对d x的求解是否满足预设规则来对求解过程进行限制; A1: The solution process can be restricted by judging whether the current solution to d x satisfies the preset rules;
A2:在当前对d x的求解满足预设规则时,可以直接将与当前得到的d x所对应的优化后的视差图d′确定为最终的视差图; A2: When the current solution to d x satisfies the preset rule, the optimized disparity map d′ corresponding to the currently obtained d x can be directly determined as the final disparity map;
A3:否则,执行以下步骤1至步骤4,直至当前的初始视差图在横坐标方向上的梯度d x满足预设规则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为最终的视差图: A3: Otherwise, perform the following steps 1 to 4 until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compare the gradient d x of the current initial disparity map in the abscissa direction with the current initial disparity map. The corresponding optimized disparity map is determined as the final disparity map:
步骤1:根据优化后的视差图更新初始视差图,得到当前的视差图;Step 1: Update the initial disparity map according to the optimized disparity map to obtain the current disparity map;
步骤2:根据能量方程,计算当前的视差图在横坐标方向上的梯度d xStep 2: Calculate the gradient d x of the current disparity map in the abscissa direction according to the energy equation;
步骤3:通过将初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图; Step 3: By superimposing the initial disparity map d and the gradient dx of the current initial disparity map in the abscissa direction, an optimized disparity map corresponding to the gradient dx of the current initial disparity map in the abscissa direction is obtained. ;
步骤4:返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则的步骤。 Step 4: Return to the step of judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule.
其中,在一些实施方式中,上述预设规则可以为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,即,使得初始视差图在横坐标方向上的梯度d x足够小后,即可认为满足预设规则。 Wherein, in some embodiments, the above-mentioned preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, that is, the gradient d x of the initial disparity map in the abscissa direction is sufficient After it is small, it can be considered that the preset rules are satisfied.
当初始视差图在横坐标方向上的梯度d x足够小时,说明前一次求解d x所得到的对应的优化后的视差图与本次求解d x所得到的对应的优化后的视差图之间的区别足够小,使得视差图越来越趋近于引导图的真实值,因此,上述平滑过程是按照引导图的真实值在进行平滑,不是按照理想状态在进行平滑,从而可以控制平滑项对初始视差图中应该被平滑的区域进行平滑,且忽略不该平滑的区域,以保证最终得到的视差图中视差值的准确性和值域的准确性。 When the gradient d x of the initial disparity map in the abscissa direction is sufficiently small, it indicates that there is a difference between the corresponding optimized disparity map obtained by solving d x in the previous time and the corresponding optimized disparity map obtained by solving d x this time. The difference is small enough that the disparity map is getting closer and closer to the true value of the guide map. Therefore, the above smoothing process is smoothing according to the true value of the guide map, not according to the ideal state, so that the smoothing term can be controlled. The areas that should be smoothed in the initial disparity map are smoothed, and the areas that should not be smoothed are ignored to ensure the accuracy of the disparity values and the accuracy of the value range in the final disparity map.
在一些实施方式中,上述预设规则还可以为:当前对于d x的计算所使用的迭代次数达到第二阈值。 In some embodiments, the above-mentioned preset rule may also be: the number of iterations currently used for the calculation of d x reaches the second threshold.
如图3所示,本申请实施例还提供一种视差图优化装置400,视差图优化装置400可以 包括:获取模块410、确定模块420以及引导滤波模块430。As shown in FIG. 3 , an embodiment of the present application further provides a disparity map optimization apparatus 400. The disparity map optimization apparatus 400 may include: an acquisition module 410, a determination module 420, and a guided filtering module 430.
获取模块410可以配置成用于获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像可以为针对同一拍摄场景、通过不同拍摄角度获取的两幅图像;The acquisition module 410 may be configured to acquire a first image, a second image, and an initial disparity map corresponding to the first image and the second image, and the first image and the second image may be for the same Shooting scene, two images obtained from different shooting angles;
确定模块420可以配置成用于根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程可以包括数据项及平滑项;The determining module 420 may be configured to determine an energy equation for guided filtering according to the initial disparity map, the first image, and the second image, the energy equation may include a data term and a smoothing term;
引导滤波模块430可以配置成用于根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。The guided filtering module 430 may be configured to perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
在一种可能的实施方式中,所述确定模块420可以配置成用于:根据所述第一图像及所述第二图像确定出所述数据项E data;根据所述初始视差图确定出所述平滑项E data;基于公式E=min(E data+αE smooth),确定所述能量方程E; In a possible implementation manner, the determining module 420 may be configured to: determine the data item E data according to the first image and the second image; determine the data item E data according to the initial disparity map the smoothing term E data ; based on the formula E=min(E data +αE smooth ), determine the energy equation E;
其中,α为所述平滑项与所述数据项的权重,所述数据项可以对所述平滑项构成约束作用。Wherein, α is the weight of the smooth item and the data item, and the data item may constitute a constraint effect on the smooth item.
在一种可能的实施方式中,所述确定模块420可以配置成用于:基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定所述数据项E data;基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定所述平滑项E smoothIn a possible implementation manner, the determining module 420 may be configured to: determine the data item E based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx data ; based on the formula E smooth =∫w x (d x ) 2 +w y (d y ) 2 dx, determine the smoothing term E smooth ;
其中,I 1(x)为所述第一图像,I 2(x+d)为所述第二图像,d为所述初始视差图,x为所述第一图像中的任意点的横坐标,d x、d y为所述初始视差图分别在横坐标方向上的梯度以及在纵坐标方向上的梯度,w x、w y为平滑权重。 Wherein, I 1 (x) is the first image, I 2 (x+d) is the second image, d is the initial disparity map, and x is the abscissa of any point in the first image , d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively, and w x and w y are smoothing weights.
在一种可能的实施方式中,所述引导滤波模块430可以配置成用于:根据所述能量方程,计算所述初始视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与所述初始视差图在横坐标方向上的梯度d x相叠加,获得所述优化后的视差图。 In a possible implementation manner, the guided filtering module 430 may be configured to: calculate the gradient d x of the initial disparity map in the abscissa direction according to the energy equation; d is superimposed with the gradient d x of the initial disparity map in the abscissa direction to obtain the optimized disparity map.
在一种可能的实施方式中,所述装置还可以包括判断模块以及执行模块,所述判断模块可以配置成用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;所述执行模块可以配置成用于在所述判断模块判断为是时确定与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图为最终的视差图。 In a possible implementation manner, the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule ; the execution module may be configured to determine the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction as the final disparity map when the judgment module judges yes.
在一种可能的实施方式中,所述装置还可以包括判断模块以及执行模块,所述判断模块可以配置成用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;所 述执行模块可以配置成用于在所述判断模块判断为否时执行以下过程,直至当前的初始视差图在横坐标方向上的梯度d x满足所述预设规则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为所述最终的视差图:根据所述优化后的视差图更新所述初始视差图,得到当前的视差图;根据所述能量方程,计算所述当前的视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图;返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则的步骤。 In a possible implementation manner, the apparatus may further include a judgment module and an execution module, and the judgment module may be configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule The execution module can be configured to perform the following process when the judgment module judges that it is no, until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compares it with the current The optimized disparity map corresponding to the gradient d x of the initial disparity map in the abscissa direction is determined as the final disparity map: update the initial disparity map according to the optimized disparity map to obtain the current disparity map; According to the energy equation, calculate the gradient d x of the current disparity map in the abscissa direction; by superimposing the initial disparity map d and the gradient d x of the current initial disparity map in the abscissa direction, to obtain The optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction; return to the step of judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule.
在一种可能的实施方式中,所述预设规则可以为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,和/或当前的迭代次数满足第二阈值。 In a possible implementation manner, the preset rule may be: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current number of iterations satisfies the second threshold.
在一种可能的实施方式中,所述引导滤波的引导图可以为所述第一图像。In a possible implementation manner, the guided image of the guided filtering may be the first image.
本申请实施例所提供的视差图优化装置400的实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。The realization principle and the technical effect of the parallax map optimization device 400 provided by the embodiment of the present application are the same as those of the foregoing method embodiments. For brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments. .
此外,本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质上可以存储有计算机程序,该计算机程序被计算机运行时,执行如上述的视差图优化方法所包含的步骤。In addition, an embodiment of the present application further provides a computer-readable storage medium, where a computer program may be stored thereon, and when the computer program is run by a computer, the steps included in the above disparity map optimization method are executed.
此外,请参看图4,本申请实施例还提供一种用于实现本申请实施例的视差图优化方法、装置的电子设备100。In addition, referring to FIG. 4 , an embodiment of the present application further provides an electronic device 100 for implementing the disparity map optimization method and apparatus of the embodiment of the present application.
电子设备100可以提供具备计算能力,可以对获取到的图像进行引导滤波。The electronic device 100 may be provided with computing capability, and may perform guided filtering on the acquired image.
可选的,电子设备100可以是、但不限于个人电脑(Personal computer,PC)、智能手机、平板电脑、移动上网设备(Mobile Internet Device,MID)、个人数字助理、服务器等设备。其中,服务器可以是、但不限于网络服务器、数据库服务器、云端服务器等。Optionally, the electronic device 100 may be, but is not limited to, a personal computer (Personal computer, PC), a smart phone, a tablet computer, a Mobile Internet Device (Mobile Internet Device, MID), a personal digital assistant, a server, and other devices. The server may be, but not limited to, a network server, a database server, a cloud server, and the like.
其中,电子设备100可以包括:处理器110、存储器120。The electronic device 100 may include: a processor 110 and a memory 120 .
应当注意,图4所示的电子设备100的组件和结构只是示例性的,而非限制性的,根据需要,电子设备100也可以具有其他组件和结构。例如,在一些情况下,电子设备100还可以包括显示屏,用于向用户展示引导滤波后的结果。It should be noted that the components and structures of the electronic device 100 shown in FIG. 4 are only exemplary and not restrictive, and the electronic device 100 may also have other components and structures as required. For example, in some cases, the electronic device 100 may further include a display screen for presenting the guided filtered results to the user.
处理器110、存储器120以及其他可能出现于电子设备100中的组件相互之间直接或间接地电性连接,以实现数据的传输或交互。例如,处理器110、存储器120以及其他可能出现的组件相互之间可以通过一条或多条通讯总线或信号线实现电性连接。The processor 110 , the memory 120 and other components that may appear in the electronic device 100 are directly or indirectly electrically connected to each other to realize data transmission or interaction. For example, the processor 110, the memory 120, and other possible components may be electrically connected to each other through one or more communication buses or signal lines.
存储器120可以配置成用于存储程序,例如存储有后文出现的视差图优化方法对应的 程序或者后文出现的视差图优化装置。可选的,当存储器120内存储有视差图优化装置时,视差图优化装置可以包括至少一个可以以软件或固件(firmware)的形式存储于存储器120中的软件功能模块。The memory 120 may be configured to store a program, for example, a program corresponding to a disparity map optimization method or a disparity map optimization apparatus that will appear later. Optionally, when the disparity map optimization apparatus is stored in the memory 120, the disparity map optimization apparatus may include at least one software function module that may be stored in the memory 120 in the form of software or firmware.
可选的,视差图优化装置所包括的软件功能模块也可以固化在电子设备100的操作系统(operating system,OS)中。Optionally, the software function modules included in the disparity map optimization apparatus may also be solidified in an operating system (operating system, OS) of the electronic device 100 .
处理器110可以配置成用于执行存储器120中存储的可执行模块,例如视差图优化装置包括的软件功能模块或计算机程序。当处理器110在接收到执行指令后,可以执行计算机程序,例如执行:获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像为设置在不同位置的相机模组在同一时间针对同一拍摄场景所拍摄得到的两幅图像;根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程包括数据项及平滑项;根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。The processor 110 may be configured to execute executable modules stored in the memory 120, such as software function modules or computer programs included in the disparity map optimization apparatus. After receiving the execution instruction, the processor 110 may execute a computer program, for example, execute: acquiring a first image, a second image, and an initial disparity map corresponding to the first image and the second image, the first image and the second image. The image and the second image are two images captured by camera modules located at different positions at the same time for the same shooting scene; determined according to the initial disparity map, the first image and the second image An energy equation used for guiding filtering, the energy equation includes a data item and a smoothing term; guiding filtering is performed on the initial disparity map according to the energy equation to obtain an optimized disparity map.
当然,本申请任一实施例所揭示的方法都可以应用于处理器110中,或者由处理器110实现。Certainly, the method disclosed in any embodiment of the present application may be applied to the processor 110 or implemented by the processor 110 .
综上所述,本申请实施例提出的视差图优化方法、装置、电子设备及计算机可读存储介质,在对初始视差图进行引导滤波时,用于进行引导滤波的能量方程所包括的数据项以及平滑项根据立体匹配时所采用的初始视差图、第一图像以及第二图像来进行确定,且数据项对平滑项构成约束作用,从而使得平滑项受到第一图像在横坐标方向以及纵坐标方向上的梯度的影响,还受到第二图像在横坐标方向以及纵坐标方向上的梯度的影响,因此,第一图像与第二图像之间的匹配程度对平滑项造成约束,从而可以控制平滑项对初始视差图中应该被平滑的区域进行平滑,且忽略不该平滑的区域,避免误差扩散到正常区域,以保证优化后的视差图中视差值的准确性和值域的准确性。To sum up, the disparity map optimization method, device, electronic device, and computer-readable storage medium proposed in the embodiments of the present application, when the initial disparity map is guided filtering, the data items included in the energy equation used to perform the guided filtering And the smooth item is determined according to the initial disparity map, the first image and the second image used in stereo matching, and the data item constitutes a constraint on the smooth item, so that the smooth item is affected by the abscissa and ordinate of the first image. The influence of the gradient in the direction is also affected by the gradient of the second image in the abscissa direction and the ordinate direction. Therefore, the degree of matching between the first image and the second image imposes constraints on the smoothing term, so that the smoothing can be controlled. The item smoothes the areas that should be smoothed in the initial disparity map, and ignores the areas that should not be smoothed, so as to prevent errors from spreading to normal areas, so as to ensure the accuracy of the disparity values and the accuracy of the value range in the optimized disparity map.
需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. For the same and similar parts among the various embodiments, refer to each other Can.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分可以包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程 图中的每个方框、以及框图和/或流程图中的方框的组合可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may also be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architectures, functions and possible implementations of apparatuses, methods and computer program products according to various embodiments of the present application. operate. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which may contain one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by dedicated hardware-based systems that perform the specified functions or actions, Alternatively, it may be implemented in a combination of dedicated hardware and computer instructions.
另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。In addition, each functional module in each embodiment of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
所述功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、笔记本电脑、服务器、或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software function modules and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the related technology or the part of the technical solution. The computer software product is stored in a storage medium, including several The instructions are used to cause a computer device (which may be a personal computer, a notebook computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited to this. should be covered within the scope of protection of this application.
工业实用性Industrial Applicability
本申请公开了视差图优化方法、装置、电子设备及计算机可读存储介质。该方法包括:获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图;根据所述初始视差图、第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程包括数据项及平滑项;根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。通过该方法,可以避免误差扩散到正常区域,以保证优化后的视差图中视差值的准确性和值域的准确性。The present application discloses a disparity map optimization method, apparatus, electronic device, and computer-readable storage medium. The method includes: acquiring a first image, a second image and an initial disparity map corresponding to the first image and the second image; An energy equation for conducting guided filtering, the energy equation including a data item and a smoothing term; performing guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map. Through this method, the error can be prevented from spreading to the normal area, so as to ensure the accuracy of the disparity value and the accuracy of the value range in the optimized disparity map.
此外,可以理解的是,本申请的视差图优化方法、装置、电子设备及计算机可读存储介质是可以重现的,并且可以应用在多种工业应用中。例如,本申请的视差图优化方法可以应用于进行图像处理的领域。In addition, it can be understood that the disparity map optimization method, apparatus, electronic device and computer-readable storage medium of the present application are reproducible and can be applied in various industrial applications. For example, the disparity map optimization method of the present application can be applied to the field of image processing.

Claims (18)

  1. 一种视差图优化方法,其特征在于,所述方法包括:A disparity map optimization method, characterized in that the method comprises:
    获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像为针对同一拍摄场景、通过不同拍摄角度获取的两幅图像;Obtain a first image, a second image, and an initial disparity map corresponding to the first image and the second image, where the first image and the second image are obtained from different shooting angles for the same shooting scene two images;
    根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程包括数据项及平滑项;determining an energy equation for guided filtering from the initial disparity map, the first image, and the second image, the energy equation including a data term and a smoothing term;
    根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。Guide filtering is performed on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程包括:The method according to claim 1, wherein the determining an energy equation for conducting guided filtering according to the initial disparity map, the first image and the second image comprises:
    根据所述第一图像及所述第二图像确定出所述数据项E dataDetermine the data item E data according to the first image and the second image;
    根据所述初始视差图确定出所述平滑项E datadetermining the smoothing term E data according to the initial disparity map;
    基于公式E=min(E data+αE smooth),确定所述能量方程E; Based on the formula E=min(E data +αE smooth ), determine the energy equation E;
    其中,α为所述平滑项与所述数据项的权重,所述数据项对所述平滑项构成约束作用。Wherein, α is the weight of the smooth item and the data item, and the data item constitutes a constraint effect on the smooth item.
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述第一图像及所述第二图像确定出所述数据项E data以及所述根据所述初始视差图确定出所述平滑项E data包括: The method according to claim 2, wherein the data item E data is determined according to the first image and the second image and the smoothing item is determined according to the initial disparity map E data includes:
    基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定所述数据项E dataThe data item E data is determined based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx;
    基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定所述平滑项E smoothThe smoothing term E smooth is determined based on the formula E smooth =∫w x (d x ) 2 +w y (d y ) 2 dx;
    其中,I 1(x)为所述第一图像,I 2(x+d)为所述第二图像,d为所述初始视差图,x为所述第一图像中的任意点的横坐标,d x、d y为所述初始视差图分别在横坐标方向上的梯度以及在纵坐标方向上的梯度,w x、w y为平滑权重。 Wherein, I 1 (x) is the first image, I 2 (x+d) is the second image, d is the initial disparity map, and x is the abscissa of any point in the first image , d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively, and w x and w y are smoothing weights.
  4. 根据权利要求1至3中的任一项所述的方法,其特征在于,所述根据所述能量方程对所述初始视差图进行引导滤波而得到优化后的视差图包括:The method according to any one of claims 1 to 3, wherein the obtaining an optimized disparity map by performing guided filtering on the initial disparity map according to the energy equation comprises:
    根据所述能量方程,计算所述初始视差图在横坐标方向上的梯度d xAccording to the energy equation, calculate the gradient d x of the initial disparity map in the abscissa direction;
    通过将所述初始视差图d与所述初始视差图在横坐标方向上的梯度d x相叠加,获得所述优化后的视差图。 The optimized disparity map is obtained by superimposing the initial disparity map d and the gradient dx of the initial disparity map in the abscissa direction.
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:The method according to claim 4, wherein the method further comprises:
    判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则; Determine whether the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule;
    在判断为是时,确定与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图为最终的视差图。 When the judgment is yes, the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, wherein the method further comprises:
    在判断为否时,执行以下步骤,直至当前的初始视差图在横坐标方向上的梯度d x满足 所述预设规则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为所述最终的视差图: When it is judged to be no, perform the following steps until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compare the gradient d x of the current initial disparity map in the abscissa direction with the current initial disparity map d x The corresponding optimized disparity map is determined as the final disparity map:
    根据所述优化后的视差图更新所述初始视差图,得到当前的视差图;Update the initial disparity map according to the optimized disparity map to obtain the current disparity map;
    根据所述能量方程,计算所述当前的视差图在横坐标方向上的d xAccording to the energy equation, calculate the d x of the current disparity map in the abscissa direction;
    通过将所述初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图; By superimposing the initial disparity map d and the gradient d x of the current initial disparity map in the abscissa direction, an optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is obtained;
    返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足所述预设规则的步骤。 Return to the step of judging whether the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule.
  7. 根据权利要求5或6所述的方法,其特征在于,所述预设规则为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,和/或当前的迭代次数满足第二阈值。 The method according to claim 5 or 6, wherein the preset rule is: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current number of iterations satisfies the first threshold Two thresholds.
  8. 根据权利要求1至7中的任一项所述的方法,其特征在于,所述引导滤波的引导图为所述第一图像。The method according to any one of claims 1 to 7, wherein the guide map of the guide filter is the first image.
  9. 一种视差图优化装置,其特征在于,所述装置包括:A disparity map optimization device, characterized in that the device comprises:
    获取模块,所述获取模块配置成用于获取第一图像、第二图像及与所述第一图像和所述第二图像对应的初始视差图,所述第一图像与所述第二图像为针对同一拍摄场景、通过不同拍摄角度获取的两幅图像;an acquisition module, the acquisition module is configured to acquire a first image, a second image and an initial disparity map corresponding to the first image and the second image, the first image and the second image are Two images obtained from different shooting angles for the same shooting scene;
    确定模块,所述确定模块配置成用于根据所述初始视差图、所述第一图像及所述第二图像确定用于进行引导滤波的能量方程,所述能量方程包括数据项及平滑项;a determination module configured to determine an energy equation for guided filtering based on the initial disparity map, the first image, and the second image, the energy equation including a data term and a smoothing term;
    引导滤波模块,所述引导滤波模块配置成用于根据所述能量方程对所述初始视差图进行引导滤波,得到优化后的视差图。A guided filtering module configured to perform guided filtering on the initial disparity map according to the energy equation to obtain an optimized disparity map.
  10. 根据权利要求9所述的装置,其特征在于,所述确定模块配置成用于:根据所述第一图像及所述第二图像确定出所述数据项E data;根据所述初始视差图确定出所述平滑项E data;基于公式E=min(E data+αE smooth),确定所述能量方程E; The device according to claim 9, wherein the determining module is configured to: determine the data item E data according to the first image and the second image; determine according to the initial disparity map The smoothing term E data is obtained; based on the formula E=min(E data +αE smooth ), the energy equation E is determined;
    其中,α为所述平滑项与所述数据项的权重,所述数据项对所述平滑项构成约束作用。Wherein, α is the weight of the smooth item and the data item, and the data item constitutes a constraint effect on the smooth item.
  11. 根据权利要求10所述的装置,其特征在于,所述确定模块配置成用于:基于公式E data=∫(I 2(x+d)-I 1(x)) 2dx,确定所述数据项E data;基于公式E smooth=∫w x(d x) 2+w y(d y) 2dx,确定所述平滑项E smoothThe apparatus of claim 10, wherein the determining module is configured to: determine the data based on the formula E data =∫(I 2 (x+d)-I 1 (x)) 2 dx term E data ; based on the formula E smooth =∫w x (d x ) 2 +w y (d y ) 2 dx, determine the smoothing term E smooth ;
    其中,I 1(x)为所述第一图像,I 2(x+d)为所述第二图像,d为所述初始视差图,x为所述第一图像中的任意点的横坐标,d x、d y为所述初始视差图分别在横坐标方向上的梯度以及在纵坐标方向上的梯度,w x、w y为平滑权重。 Wherein, I 1 (x) is the first image, I 2 (x+d) is the second image, d is the initial disparity map, and x is the abscissa of any point in the first image , d x and dy are the gradient of the initial disparity map in the abscissa direction and the gradient in the ordinate direction, respectively, and w x and w y are smoothing weights.
  12. 根据权利要求9至11中的任一项所述的装置,其特征在于,所述引导滤波模块配置成用于:根据所述能量方程,计算所述初始视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与所述初始视差图在横坐标方向上的梯度d x相叠加,获得所述优化后的视差图。 The apparatus according to any one of claims 9 to 11, wherein the guided filtering module is configured to: calculate the gradient d of the initial disparity map in the abscissa direction according to the energy equation x ; the optimized disparity map is obtained by superimposing the initial disparity map d and the gradient dx of the initial disparity map in the abscissa direction.
  13. 根据权利要求12所述的装置,其特征在于,所述装置还包括:The apparatus of claim 12, wherein the apparatus further comprises:
    判断模块,所述判断模块配置成用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则;以及 a judgment module configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule; and
    执行模块,所述执行模块配置成用于在所述判断模块判断为是时确定与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图为最终的视差图。 An execution module, the execution module is configured to determine the optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction as the final disparity map when the judgment module judges yes.
  14. 根据权利要求12所述的装置,其特征在于,所述装置还包括:The apparatus of claim 12, wherein the apparatus further comprises:
    判断模块,所述判断模块配置成用于判断当前的初始视差图在横坐标方向上的梯度d x是否满足预设规则; a judgment module, the judgment module is configured to judge whether the gradient d x of the current initial disparity map in the abscissa direction satisfies a preset rule;
    执行模块,所述执行模块配置成用于在所述判断模块判断为否时执行以下过程,直至当前的初始视差图在横坐标方向上的梯度d x满足所述预设规则后,再将与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图确定为所述最终的视差图: An execution module, the execution module is configured to perform the following process when the judgment module judges no, until the gradient d x of the current initial disparity map in the abscissa direction satisfies the preset rule, and then compares the The optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction is determined as the final disparity map:
    根据所述优化后的视差图更新所述初始视差图,得到当前的视差图;根据所述能量方程,计算所述当前的视差图在横坐标方向上的梯度d x;通过将所述初始视差图d与当前的初始视差图在横坐标方向上的梯度d x相叠加,获得与当前的初始视差图在横坐标方向上的梯度d x对应的优化后的视差图;返回判断当前的初始视差图在横坐标方向上的梯度d x是否满足所述预设规则的步骤。 Update the initial disparity map according to the optimized disparity map to obtain the current disparity map; calculate the gradient d x of the current disparity map in the abscissa direction according to the energy equation; Figure d is superimposed with the gradient d x of the current initial disparity map in the abscissa direction to obtain an optimized disparity map corresponding to the gradient d x of the current initial disparity map in the abscissa direction; return to judge the current initial disparity The step of whether the gradient d x of the graph in the abscissa direction satisfies the preset rule.
  15. 根据权利要求13或14所述的装置,其特征在于,所述预设规则为:当前的初始视差图在横坐标方向上的梯度d x小于第一阈值,和/或当前的迭代次数满足第二阈值。 The device according to claim 13 or 14, wherein the preset rule is: the gradient d x of the current initial disparity map in the abscissa direction is smaller than the first threshold, and/or the current number of iterations satisfies the first threshold Two thresholds.
  16. 根据权利要求9至15中的任一项所述的装置,其特征在于,所述引导滤波的引导图为所述第一图像。The apparatus according to any one of claims 9 to 15, wherein the guide map of the guide filter is the first image.
  17. 一种电子设备,其特征在于,所述电子设备包括:存储器和处理器,所述存储器和所述处理器连接;An electronic device, characterized in that the electronic device comprises: a memory and a processor, and the memory is connected to the processor;
    所述存储器用于存储程序;the memory is used to store programs;
    所述处理器调用存储于所述存储器中的程序,以执行根据权利要求1至8中的任一项 所述的方法。The processor invokes a program stored in the memory to perform the method according to any one of claims 1 to 8.
  18. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被计算机运行时执行根据权利要求1至8中的任一项所述的方法。A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and the computer program executes the method according to any one of claims 1 to 8 when the computer program is run by a computer.
PCT/CN2021/130994 2021-03-31 2021-11-16 Disparity map optimization method and apparatus, and electronic device and computer-readable storage medium WO2022205934A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110353871.1A CN113395504B (en) 2021-03-31 2021-03-31 Disparity map optimization method and device, electronic equipment and computer-readable storage medium
CN202110353871.1 2021-03-31

Publications (1)

Publication Number Publication Date
WO2022205934A1 true WO2022205934A1 (en) 2022-10-06

Family

ID=77617630

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/130994 WO2022205934A1 (en) 2021-03-31 2021-11-16 Disparity map optimization method and apparatus, and electronic device and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN113395504B (en)
WO (1) WO2022205934A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113395504B (en) * 2021-03-31 2023-04-04 北京迈格威科技有限公司 Disparity map optimization method and device, electronic equipment and computer-readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103226821A (en) * 2013-04-27 2013-07-31 山西大学 Stereo matching method based on disparity map pixel classification correction optimization
CN104966303A (en) * 2015-07-21 2015-10-07 兰州理工大学 Disparity map refinement method based on Markov random field
CN105046696A (en) * 2015-07-06 2015-11-11 湖南优象科技有限公司 Image matching method based on deep planar constraint graph cut optimization
CN113395504A (en) * 2021-03-31 2021-09-14 北京迈格威科技有限公司 Disparity map optimization method and device, electronic equipment and computer-readable storage medium

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103366354B (en) * 2012-03-27 2016-09-07 富士通株式会社 Method and system for stereo matching
US10074158B2 (en) * 2014-07-08 2018-09-11 Qualcomm Incorporated Systems and methods for stereo depth estimation using global minimization and depth interpolation
CN105654493B (en) * 2015-12-30 2018-11-02 哈尔滨工业大学 A kind of affine constant binocular solid Matching power flow of improved optics and parallax optimization method
JP6991700B2 (en) * 2016-04-28 2022-01-12 キヤノン株式会社 Information processing equipment, information processing method, program
US10839535B2 (en) * 2016-07-19 2020-11-17 Fotonation Limited Systems and methods for providing depth map information
CN107170000B (en) * 2017-04-18 2019-09-10 武汉市工程科学技术研究院 Stereopsis dense Stereo Matching method based on the optimization of global block
CN107564045B (en) * 2017-07-14 2020-06-16 天津大学 Stereo matching method based on gradient domain guided filtering
CN110148181A (en) * 2019-04-25 2019-08-20 青岛康特网络科技有限公司 A kind of general binocular solid matching process
CN110473217B (en) * 2019-07-25 2022-12-06 沈阳工业大学 Binocular stereo matching method based on Census transformation
CN111402152B (en) * 2020-03-10 2023-10-24 北京迈格威科技有限公司 Processing method and device of disparity map, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103226821A (en) * 2013-04-27 2013-07-31 山西大学 Stereo matching method based on disparity map pixel classification correction optimization
CN105046696A (en) * 2015-07-06 2015-11-11 湖南优象科技有限公司 Image matching method based on deep planar constraint graph cut optimization
CN104966303A (en) * 2015-07-21 2015-10-07 兰州理工大学 Disparity map refinement method based on Markov random field
CN113395504A (en) * 2021-03-31 2021-09-14 北京迈格威科技有限公司 Disparity map optimization method and device, electronic equipment and computer-readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
YUN TING, LIANG XIAO, WU HUI-ZHONG: " Images Matching Approach Based on Moving Boundaries and Energy Function Optimization", JOURNAL OF SYSTEM SIMULATION, GAI-KAN BIANJIBU , BEIJING, CN, vol. 21, no. 4, 1 February 2009 (2009-02-01), CN , pages 988 - 992, XP055974686, ISSN: 1004-731X, DOI: 10.16182/j.cnki.joss.2009.04.038 *

Also Published As

Publication number Publication date
CN113395504B (en) 2023-04-04
CN113395504A (en) 2021-09-14

Similar Documents

Publication Publication Date Title
CN113486797B (en) Unmanned vehicle position detection method, unmanned vehicle position detection device, unmanned vehicle position detection equipment, storage medium and vehicle
CN108154526B (en) Image alignment of burst mode images
US10187546B2 (en) Method and device for correcting document image captured by image pick-up device
CN108830780B (en) Image processing method and device, electronic device and storage medium
CN109753971B (en) Correction method and device for distorted text lines, character recognition method and device
CN111368717B (en) Line-of-sight determination method, line-of-sight determination device, electronic apparatus, and computer-readable storage medium
US20130170736A1 (en) Disparity estimation depth generation method
WO2021179590A1 (en) Disparity map processing method and apparatus, computer device and storage medium
JP6615917B2 (en) Real-time video enhancement method, terminal, and non-transitory computer-readable storage medium
WO2015106700A1 (en) Method and apparatus for implementing image denoising
WO2017206444A1 (en) Method and device for detecting imaging difference, and computer storage medium
TWI668669B (en) Object tracking system and method thereof
US20140132822A1 (en) Multi-resolution depth-from-defocus-based autofocus
CN112348763A (en) Image enhancement method, device, electronic equipment and medium
CN111126108A (en) Training method and device of image detection model and image detection method and device
WO2022205934A1 (en) Disparity map optimization method and apparatus, and electronic device and computer-readable storage medium
CN115660945A (en) Coordinate conversion method and device, electronic equipment and storage medium
CN113888438A (en) Image processing method, device and storage medium
CN110689565B (en) Depth map determination method and device and electronic equipment
CN107392882A (en) A kind of method of the unzoned lens PSF iteration optimization initial values based on Corner Detection
CN108961293B (en) Background subtraction method, device, equipment and storage medium
CN108780572A (en) The method and device of image rectification
CN116485645A (en) Image stitching method, device, equipment and storage medium
CN111738085B (en) System construction method and device for realizing automatic driving simultaneous positioning and mapping
CN113628192B (en) Image blur detection method, apparatus, device, storage medium, and program product

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21934570

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 16/02/2024)