A method and apparatus for optimizing focal volume based on prior information
Through the focus volume optimization method based on prior information, outliers in the focus volume are detected and removed, which solves the problem of difficulty in improving the depth map accuracy in the existing technology and achieves a more efficient depth map optimization effect.
Patent Information
- Application Number
- CN202410284295.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-13
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-03-13
AI Technical Summary
Existing technologies have the problems of incomplete noise reduction and excessive smoothing when improving depth map accuracy. Especially in unstructured complex surfaces and weak texture areas, the depth map optimization effect is limited.
Through the focus volume optimization method based on prior information, multi-layer images between the imaging system and the reconstructed object are obtained, a three-dimensional grayscale matrix and a focus volume matrix are generated, abnormal point detection and optimization are performed, and the focus volume is removed using the curve difference method outliers in the image to improve the accuracy of the depth map.
It effectively removes outliers in the focus volume, improves the accuracy of the depth map of the reconstructed object, avoids the problems of incomplete noise reduction and excessive smoothing, and improves the optimization effect of the depth map.
Smart Images

Figure CN118096864B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of 3D reconstruction technology, and in particular to a focal volume optimization method and apparatus based on prior information. Background Technology
[0002] Focused topography restoration is a monocular passive reconstruction technique that acquires partially focused image sequences by changing the distance between the imaging system and the object to be reconstructed, using sharpness as a reconstruction cue to determine the depth of each pixel location.
[0003] Currently, improving depth map accuracy mainly involves three aspects: improving the accuracy of the focal operator calculation results, refining the focal volume, and optimizing the depth map. The depth map is generated by selecting the position of the maximum focal value along the optical axis within the focal volume; therefore, the accuracy of the focal volume directly determines the accuracy of the reconstruction result. When there are many errors in the focal volume, error propagation occurs, leading to numerous incorrect depth estimates, which limits the optimization effect on the depth map.
[0004] Currently, commonly used focus operators are calculated primarily in the spatial and transform domains. In the spatial domain, operators based on the first and second derivatives are frequently used, employing image edge information as a sharpness evaluation criterion. For small window regions, statistical operators are predominantly used, calculating the variance within the window region. In sharp locations, the large differences in grayscale values result in significant variance values. In the transform domain, discrete cosine transforms and Fourier transforms are performed on the image to obtain its high-frequency components.
[0005] Many new focus operators have been proposed to obtain more useful information by selecting windows of different shapes. For specific objects, the image is transformed from Cartesian coordinates to polar coordinates, and the properties of different coordinate systems are used to obtain accurate focus values. To avoid the limitations of a single focus operator, principal component analysis is used to process a large number of focus operators to determine the optimal focus value.
[0006] In refining the focal volume, the focal values within the window are averaged and the center position is replaced, similar to linear filtering. Since the acquired image sequence is discrete, the reconstructed depth map is discontinuous. Therefore, methods such as Gaussian fitting, multi-term fitting, Bezier fitting, and Cartesian fitting are used to fit the focal curve, removing outliers while obtaining continuous depth. Alternatively, the initial depth map or full-focus image can be used as prior information to guide the focal volume filtering. Or, multi-directional anisotropic nonlinear filtering can be combined to enhance the focal volume. Dynamic programming to find the FIS shape is also a common method. For depth map optimization, forced smoothing filtering is often used to smooth the depth map.
[0007] In summary, due to the inherent limitations of focus operators, a single method is difficult to adapt to all objects, especially on unstructured complex surfaces and weakly textured regions, which has been a long-standing research focus. Furthermore, depth map accuracy depends on the focus volume, and optimization techniques often employ filtering methods. While these methods can smooth noise, they suffer from incomplete noise reduction and over-smoothing, resulting in limited optimization effectiveness. Summary of the Invention
[0008] This invention provides a focal volume optimization method and apparatus based on prior information, which can remove outliers in the focal volume and improve the accuracy of the depth map.
[0009] In a first aspect, the present invention provides a focal volume optimization method based on prior information. The method includes: acquiring multi-layer images taken at different distances between an imaging system and a reconstructed object; generating a three-dimensional grayscale matrix based on the multi-layer images; wherein the elements of the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer images; generating a focal volume matrix based on the three-dimensional grayscale matrix; wherein the elements of the focal volume matrix are the focal values of each pixel in the multi-layer images, and the focal values are used to characterize the sharpness level; performing prior information calculation on the focal volume matrix and anomaly detection to determine anomalies in the focal volume matrix; and optimizing the anomalies in the focal volume matrix based on a curve interpolation method to obtain an optimized focal volume matrix.
[0010] In one possible implementation, prior information calculation and anomaly detection are performed on the focal volume matrix to determine anomalies in the focal volume matrix. This includes: performing anomaly detection on each pixel in the focal volume matrix along the optical axis to obtain anomalies in the optical axis direction; performing anomaly detection on each pixel in the focal volume matrix along the horizontal direction to obtain anomalies in the horizontal direction; and determining the anomalies in the focal volume matrix based on the anomalies in the optical axis direction and the anomalies in the horizontal direction.
[0011] In one possible implementation, anomaly detection is performed on each pixel in the focal volume matrix along the optical axis to obtain anomalies along the optical axis. This includes: for any pixel, normalizing its focal curve to obtain a normalized focal curve; the focal curve is a curve composed of the number of image layers and the focal value along the optical axis; performing a gamma transform on the normalized focal curve to obtain the pixel's gamma sequence, which represents the pixel's gamma values in each image layer; dividing and reassigning intervals based on the gamma values of the pixel's gamma sequence to obtain reassigned gamma values and the intervals corresponding to each gamma value; calculating the pixel's information entropy based on the reassigned gamma values and the intervals corresponding to each gamma value; and determining whether the pixel is an anomaly along the optical axis based on its information entropy.
[0012] In one possible implementation, based on the gamma values of the pixel's gamma sequence, intervals are divided and reassigned to obtain reassigned gamma values and corresponding intervals. This includes: dividing 0 to 1 into N equal parts to obtain N intervals; determining the interval corresponding to each gamma value based on the pixel's gamma sequence and the N intervals; and reassigning each gamma value based on the intervals corresponding to each gamma value to obtain the reassigned gamma value.
[0013] In one possible implementation, determining whether a pixel is an anomalous point in the optical axis direction based on the information entropy of the pixel includes: if the information entropy of the pixel is less than a first threshold, then determining that the pixel is a normal point in the optical axis direction; if the information entropy of the pixel is greater than or equal to the first threshold, then determining that the pixel is an anomalous point in the optical axis direction.
[0014] In one possible implementation, outlier detection is performed on each pixel in the focal volume matrix along the horizontal direction to obtain outliers in the horizontal direction. This includes: for a local window on any image layer, dividing the local window into multiple sub-windows; calculating the minimum and maximum focal values of the multiple sub-windows; calculating the maximum value among the minimum focal values of the multiple sub-windows; calculating the minimum value among the maximum focal values of the multiple sub-windows; calculating the absolute difference between the maximum and minimum values; and determining whether a pixel in the local window is an outlier in the horizontal direction based on the absolute difference.
[0015] In one possible implementation, determining whether a pixel in the local window is an outlier in the horizontal direction based on the absolute difference includes: if the absolute difference is less than a second threshold, then determining that the pixel in the local window is a normal pixel in the horizontal direction; if the absolute difference is greater than or equal to the second threshold, then determining that the pixel in the local window is an outlier in the horizontal direction.
[0016] In one possible implementation, the outliers in the focal volume matrix are optimized based on the curve interpolation method to obtain an optimized focal volume matrix. This includes: optimizing the outliers in the focal volume matrix based on the curve interpolation method to obtain an intermediate matrix; calculating the variation difference of each pixel between the intermediate matrix and the focal volume matrix; if the variation difference is less than a third threshold, then the intermediate matrix is determined to be the optimized focal volume matrix; if the variation difference is greater than or equal to the third threshold, then the intermediate matrix is optimized along the optical axis and horizontal direction until the variation difference is less than the third threshold, thus obtaining the optimized focal volume matrix.
[0017] In one possible implementation, a focal volume matrix is generated based on a three-dimensional grayscale matrix, including: calculating the focal value of each pixel in the multi-layer image based on the three-dimensional grayscale matrix and a preset focal metric operator; and determining the focal volume matrix based on the focal value of each pixel in the multi-layer image.
[0018] Secondly, embodiments of the present invention provide a focal volume optimization device based on prior information. The device includes a communication module and a processing module. The communication module is used to acquire multi-layer images captured at different distances between the imaging system and the reconstructed object. The processing module is used to generate a three-dimensional grayscale matrix based on the multi-layer images; the elements in the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer images; generate a focal volume matrix based on the three-dimensional grayscale matrix; the elements in the focal volume matrix are the focal values of each pixel in the multi-layer images, and the focal values are used to characterize the sharpness level; perform prior information calculation on the focal volume matrix and anomaly detection to determine anomalies in the focal volume matrix; and optimize the anomalies in the focal volume matrix based on the curve interpolation method to obtain an optimized focal volume matrix.
[0019] In one possible implementation, the processing module is specifically used to perform anomaly detection on each pixel in the focal volume matrix along the optical axis to obtain anomalies in the optical axis direction; to perform anomaly detection on each pixel in the focal volume matrix along the horizontal direction to obtain anomalies in the horizontal direction; and to determine the anomalies in the focal volume matrix based on the anomalies in the optical axis direction and the anomalies in the horizontal direction.
[0020] In one possible implementation, the processing module is specifically used to normalize the focus curve of any pixel to obtain a normalized focus curve; the focus curve is a curve composed of the number of image layers and the focus value along the optical axis; perform a gamma transform on the normalized focus curve to obtain the gamma sequence of the pixel, the gamma sequence being the gamma value of the pixel in each image layer; based on each gamma value of the pixel's gamma sequence, perform interval division and reassignment to obtain reassigned gamma values and the intervals corresponding to each gamma value; calculate the information entropy of the pixel based on the reassigned gamma values and the intervals corresponding to each gamma value; and determine whether the pixel is an anomaly in the optical axis direction based on the information entropy of the pixel.
[0021] In one possible implementation, the processing module is specifically used to divide 0 to 1 into N equal parts to obtain N intervals; based on the gamma values of the gamma sequence of the pixel and the N intervals, determine the interval corresponding to each gamma value; and based on the interval corresponding to each gamma value, reassign each gamma value to obtain the reassigned gamma value.
[0022] In one possible implementation, the processing module is specifically configured to determine that if the information entropy of the pixel is less than a first threshold, the pixel is a normal point in the optical axis direction; and if the information entropy of the pixel is greater than or equal to the first threshold, the pixel is determined to be an abnormal point in the optical axis direction.
[0023] In one possible implementation, the processing module is specifically used to divide a local window on any image layer into multiple sub-windows; calculate the minimum and maximum focal values of the multiple sub-windows; calculate the maximum value among the minimum focal values of the multiple sub-windows; calculate the minimum value among the maximum focal values of the multiple sub-windows; calculate the absolute difference between the maximum and minimum values; and determine whether a pixel in the local window is a horizontal outlier based on the absolute difference.
[0024] In one possible implementation, the processing module is specifically used to determine that if the absolute difference is less than a second threshold, the pixel in the local window is a normal point in the horizontal direction; if the absolute difference is greater than or equal to the second threshold, the pixel in the local window is an abnormal point in the horizontal direction.
[0025] In one possible implementation, the processing module is specifically used to optimize outliers in the focal volume matrix based on the curve difference method to obtain an intermediate matrix; calculate the change difference of each pixel between the intermediate matrix and the focal volume matrix; if the change difference is less than a third threshold, then the intermediate matrix is determined to be the optimized focal volume matrix; if the change difference is greater than or equal to the third threshold, then the intermediate matrix is optimized along the optical axis and horizontal direction until the change difference is less than the third threshold, thus obtaining the optimized focal volume matrix.
[0026] In one possible implementation, the processing module is specifically used to calculate the focal value of each pixel in the multi-layer image based on the three-dimensional grayscale matrix and a preset focal measurement operator; and to determine the focal volume matrix based on the focal value of each pixel in the multi-layer image.
[0027] Thirdly, embodiments of the present invention provide an electronic device including a memory and a processor. The memory stores a computer program, and the processor is configured to execute the steps of the method described in the first aspect and any possible implementation thereof when calling and running the computer program stored in the memory.
[0028] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, it implements the steps of the method as described in the first aspect and any possible implementation thereof.
[0029] This invention provides a focal volume optimization method and apparatus based on prior information. After acquiring multi-layer images of a reconstructed object, the invention calculates the focal value of each pixel using the three-dimensional grayscale matrix of the multi-layer images to obtain a focal volume matrix. Then, prior information calculation and outlier detection are performed on the focal volume matrix to obtain outliers in the focal volume matrix. The outliers are then optimized to obtain an optimized focal volume matrix, which removes outliers from the focal volume and improves the accuracy of the depth map of the reconstructed object. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a flowchart illustrating a focal volume optimization method based on prior information provided in an embodiment of the present invention.
[0032] Figure 2 This is a flowchart illustrating another focal volume optimization method based on prior information provided in an embodiment of the present invention;
[0033] Figure 3 This is a flowchart illustrating another focal volume optimization method based on prior information provided in an embodiment of the present invention;
[0034] Figure 4 This is a flowchart illustrating another focal volume optimization method based on prior information provided in an embodiment of the present invention;
[0035] Figure 5 This is a schematic diagram of a focal volume optimization device based on prior information provided in an embodiment of the present invention;
[0036] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0037] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0038] In the description of this invention, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Furthermore, "at least one" and "more than one" refer to two or more. The terms "first," "second," etc., do not limit the quantity or order of execution, and "first," "second," etc., do not necessarily imply differences.
[0039] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner to facilitate understanding.
[0040] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the steps or modules listed, but may optionally include other steps or modules not listed, or may optionally include other steps or modules inherent to such process, method, product, or device.
[0041] To make the objectives, technical solutions, and advantages of the present invention clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.
[0042] As described in the background section, improving the accuracy of depth maps is currently difficult due to issues such as incomplete noise reduction and excessive smoothing, which limits the optimization effect of depth maps.
[0043] To solve the above technical problems, such as Figure 1 and Figure 2 As shown, this embodiment of the invention provides a focal volume optimization method based on prior information. The method includes steps S101-S105.
[0044] S101. Acquire multi-layer images taken at different distances between the imaging system and the reconstructed object.
[0045] S102. Generate a three-dimensional grayscale matrix based on multi-layer images.
[0046] The elements in the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer image.
[0047] S103. Generate the focal volume matrix based on the three-dimensional grayscale matrix.
[0048] The elements in the focal volume matrix are the focal values of each pixel in the multi-layer image, and the focal values are used to characterize the level of sharpness.
[0049] As one possible implementation, the embodiments of the present invention may specifically take steps S1031-S1032 to generate the focal volume matrix.
[0050] S1031. Based on the three-dimensional grayscale matrix and the preset focus measurement operator, calculate the focus value of each pixel in the multi-layer image.
[0051] S1032. Determine the focal volume matrix based on the focal value of each pixel in the multi-layer image.
[0052] It should be noted that, as Figure 2 As shown, in this embodiment of the invention, the first step is to acquire an image sequence I of the object to be reconstructed. z (x, y), assuming the image acquisition interval is Step (less than the depth of field of the optical system), each image in the image sequence contains a partially focused, sharp region of the object, where z is the image layer number, and x and y are the pixel positions in the image. Using a suitable focus metric operator, the sharpness level at each pixel position in the image sequence is calculated. The result is called the focus value, and the set of all focus values is called the focus volume S². Commonly used focus metric operators include the Sum-Modified-Laplacian (SML), the Tenegrad (TEN) gradient operator, the Gray Level Variance (GLV) operator, and the Discrete Cosine Transform (DCT). The focus volume, also known as the focus volume, is composed of the sharpness level of each pixel calculated in the image sequence, and its size is equal to I. z (x,y) are the same.
[0053] S104. Calculate prior information for the focal volume matrix and detect outliers to identify outliers in the focal volume matrix.
[0054] As one possible implementation, step S104 can be specifically implemented as steps S1041-S1043.
[0055] S1041. Along the optical axis, perform anomaly detection on each pixel in the focal volume matrix to obtain anomalies along the optical axis.
[0056] For example, for any pixel, the embodiments of the present invention can determine whether the pixel is an abnormal point in the optical axis direction through steps A1-A5.
[0057] A1. For any pixel, normalize the focus curve of that pixel to obtain a normalized focus curve; the focus curve is the curve formed by the number of image layers and the focus value along the optical axis.
[0058] A2. Perform a gamma transform on the normalized focus curve to obtain the gamma sequence of the pixel. The gamma sequence represents the gamma value of the pixel in each image layer.
[0059] A3. Based on the gamma values of the gamma sequence of the pixel, divide the interval and reassign the values to obtain the reassigned gamma values and the intervals corresponding to each gamma value.
[0060] For example, in this embodiment of the invention, 0 to 1 can be divided into N equal parts to obtain N intervals; based on the gamma values of the gamma sequence of the pixel and the N intervals, the interval corresponding to each gamma value is determined; based on the interval corresponding to each gamma value, each gamma value is reassigned to obtain the reassigned gamma value.
[0061] A4. Based on the assigned gamma values and the corresponding intervals, calculate the information entropy of the pixel.
[0062] A5. Based on the information entropy of the pixel, determine whether the pixel is an anomaly point in the optical axis direction.
[0063] For example, if the information entropy of a pixel is less than a first threshold, then the pixel is determined to be a normal point in the optical axis direction.
[0064] Another example is that if the information entropy of a pixel is greater than or equal to a first threshold, then the pixel is determined to be an anomaly in the optical axis direction.
[0065] It should be noted that, as Figure 3 As shown, in this embodiment of the invention, the focus curve at position (x,y) can be normalized (S32), transforming the value of the focus curve to between 0 and 1. Then, a gamma transformation (S33) is performed. The formula for gamma transformation is s=crγ, where c is the grayscale scaling factor (usually 1), r is the grayscale value, γ is the gamma factor controlling the scaling degree of the entire transformation, and s is the output result. This process suppresses the focus values in blurred areas and highlights the focus values in clear areas. Then, the 0-1 interval is divided into N equal parts, and the focus values in each interval are reassigned (S34). The distribution of the focus curve's focus is observed. Assuming the focus value is between 0 and 1 / N, it is reassigned to 1 / N. Focus values in clear areas that are larger only account for a small portion, while focus values close to 0 account for the majority. Therefore, the information entropy calculated for the desired position should be relatively small. The information entropy of the focus curve is calculated (S35). , This represents the probability of the random focusing curve X at a position of size xi. It is compared with a threshold of 1 (S36). If the value is less than the threshold of 1, it is a correct region and assigned a value of 1 (S37); if the value is greater than the threshold of 1, it is an incorrect region and assigned a value of 0 (S38).
[0066] S1042. Along the horizontal direction, perform anomaly detection on each pixel in the focal volume matrix to obtain anomalies in the horizontal direction.
[0067] For example, for a local window on any image layer, this embodiment of the invention can determine whether the pixels in the local window are horizontally abnormal points through steps B1-B6.
[0068] B1. For any local window on an image layer, divide the local window to obtain multiple sub-windows.
[0069] B2. Calculate the minimum and maximum focus values of multiple sub-windows.
[0070] B3. Calculate the maximum value among the minimum focus values of multiple child windows.
[0071] B4. Calculate the minimum value among the maximum focus values of multiple child windows.
[0072] B5. Calculate the absolute difference between the maximum and minimum values.
[0073] B6. Based on the absolute difference, determine whether the pixels in the local window are outliers in the horizontal direction.
[0074] For example, if the absolute difference is less than the second threshold, then the pixel in the local window is determined to be a normal point in the horizontal direction.
[0075] As another example, if the absolute difference is greater than or equal to the second threshold, then the pixel in the local window is determined to be an outlier in the horizontal direction.
[0076] It should be noted that, as Figure 4 As shown, first, determine the local window R of the focus volume of the z-th frame, S42, with a window size of 3×3. Define the regions in R with the top left corner S43, top right corner S44, bottom left corner S45, and bottom right corner S46 as R1, R2, R3, and R4, respectively, with a size of 2×2. Calculate the minimum value of R1, R2, R3, and R4, and determine the maximum value Rmax. Calculate the maximum value of R1, R2, R3, and R4, and determine the minimum value Rmin S47. Calculate the absolute difference between Rmax and Rmin S48, and compare it with a threshold of 2 S49. Regions less than the threshold of 2 are considered correct and assigned a value of 1, as shown in S410; regions greater than the threshold of 2 are considered incorrect and assigned a value of 0, as shown in S411.
[0077] S1043. Based on the anomalies in the optical axis and the horizontal direction, determine the anomalies in the focal volume matrix.
[0078] For example, in embodiments of the present invention, the intersection of anomalies in the optical axis direction and anomalies in the horizontal direction can be determined as anomalies in the focal volume matrix.
[0079] Another exemplary embodiment of the present invention can determine the anomaly point in the focal volume matrix as the union of the anomaly points in the optical axis direction and the anomaly points in the horizontal direction.
[0080] S105. Based on the curve interpolation method, optimize the outliers in the focal volume matrix to obtain the optimized focal volume matrix.
[0081] As one possible implementation, step S105 can be specifically implemented as steps S1051-S1054.
[0082] S1051. Based on the curve interpolation method, optimize the outliers in the focal volume matrix to obtain the intermediate matrix.
[0083] S1052. Calculate the difference in the change of each pixel between the intermediate matrix and the focal volume matrix.
[0084] S1053. If the difference in change is less than the third threshold, then the intermediate matrix is determined to be the optimized focal volume matrix.
[0085] S1054. If the difference in variation is greater than or equal to the third threshold, the intermediate matrix is optimized along the optical axis and horizontal direction until the difference in variation is less than the third threshold, thus obtaining the optimized focal volume matrix.
[0086] It should be noted that the intersection of the positions of the erroneous focal values determined along the optical axis and horizontal direction is used as the final determined erroneous focal value. Surface interpolation is then used to replace the erroneous focal value. The optimized focal volume is then compared with the previous focal volume for similarity. If the change is less than a set threshold, optimization is considered complete, and the focal volume is output; otherwise, noise reduction continues along the optical axis and horizontal direction. For example, in this embodiment, the change between the newly generated focal volume and the previous generation focal volume can be compared with a set threshold 3 (S7). If the change is less than threshold 3, optimization is considered complete, and the focal volume is output (S8); otherwise, the latest optimized focal volume is re-optimized along the optical axis and horizontal direction.
[0087] This invention provides a focal volume optimization method based on prior information. After acquiring multi-layer images of a reconstructed object, the method calculates the focal value of each pixel using the three-dimensional grayscale matrix of the multi-layer images to obtain a focal volume matrix. Then, prior information calculation and outlier detection are performed on the focal volume matrix to obtain outliers in the focal volume matrix. The outliers are then optimized to obtain an optimized focal volume matrix, which removes outliers from the focal volume and improves the accuracy of the depth map of the reconstructed object.
[0088] This invention first uses a traditional focus operator to calculate the focus volume, then determines the position of the erroneous focus value in the focus volume along the optical axis and the horizontal direction, and then uses surface interpolation to replace the erroneous focus value. It then determines whether the change in focus volume before and after optimization is less than a threshold. If it is less than the threshold, the focus volume is output; if it is greater than the focus volume, the noise reduction process is repeated.
[0089] This invention relates to shape focusing algorithms for single-lens optical systems. After calculating the focal volume using a suitable focal operator, the optimization method optimizes the focal volume in both the vertical and horizontal directions. In the vertical direction, the obtained focal volume is first normalized, and a gamma transform is performed on the focal values along the optical axis. The interval is divided into N equal parts and reassigned, and the information entropy is calculated to obtain the confidence level of the estimated depth at each position. In the horizontal direction, a minimax operator is used to find erroneous focal values in the focal volume. Finally, the intersection of the erroneous positions obtained in the two directions is taken to determine the abnormal focal values, which are then replaced using surface interpolation. The above method is iterated until the transformation of the focal volume is less than a certain threshold, thus optimizing the focal volume and generating a more accurate depth map. The method of this invention removes abnormal focal values from two dimensions and performs iterative processing, effectively improving the accuracy of the focal volume.
[0090] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0091] The following are device embodiments of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.
[0092] Figure 5 A schematic diagram of a focal volume optimization device based on prior information provided in an embodiment of the present invention is shown. The focal volume optimization device 200 includes a communication module 201 and a processing module 202.
[0093] The communication module 201 is used to acquire multi-layer images taken at different distances between the imaging system and the reconstructed object.
[0094] Processing module 202 is used to generate a three-dimensional grayscale matrix based on multi-layer images; the elements in the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer images; generate a focal volume matrix based on the three-dimensional grayscale matrix; the elements in the focal volume matrix are the focal values of each pixel in the multi-layer images, and the focal values are used to characterize the sharpness level; perform prior information calculation and anomaly detection on the focal volume matrix to determine the anomalies in the focal volume matrix; optimize the anomalies in the focal volume matrix based on the curve interpolation method to obtain the optimized focal volume matrix.
[0095] In one possible implementation, the processing module 202 is specifically used to perform anomaly detection on each pixel in the focal volume matrix along the optical axis to obtain anomalies in the optical axis direction; perform anomaly detection on each pixel in the focal volume matrix along the horizontal direction to obtain anomalies in the horizontal direction; and determine the anomalies in the focal volume matrix based on the anomalies in the optical axis direction and the anomalies in the horizontal direction.
[0096] In one possible implementation, the processing module 202 is specifically used to: for any pixel, normalize the focus curve of the pixel to obtain a normalized focus curve; the focus curve is a curve composed of the number of image layers and the focus value along the optical axis; perform a gamma transform on the normalized focus curve to obtain the gamma sequence of the pixel, the gamma sequence being the gamma value of the pixel in each image layer; based on each gamma value of the pixel's gamma sequence, divide and reassign intervals to obtain reassigned gamma values and the intervals corresponding to each gamma value; calculate the information entropy of the pixel based on the reassigned gamma values and the intervals corresponding to each gamma value; and determine whether the pixel is an anomaly in the optical axis direction based on the information entropy of the pixel.
[0097] In one possible implementation, the processing module 202 is specifically used to divide 0 to 1 into N equal parts to obtain N intervals; based on the gamma values of the gamma sequence of the pixel and the N intervals, determine the interval corresponding to each gamma value; and based on the interval corresponding to each gamma value, reassign each gamma value to obtain the reassigned gamma value.
[0098] In one possible implementation, the processing module 202 is specifically used to determine that if the information entropy of the pixel is less than a first threshold, the pixel is a normal point in the optical axis direction; if the information entropy of the pixel is greater than or equal to the first threshold, the pixel is determined to be an abnormal point in the optical axis direction.
[0099] In one possible implementation, the processing module 202 is specifically used to divide a local window on any image layer into multiple sub-windows; calculate the minimum and maximum focal values of the multiple sub-windows; calculate the maximum value among the minimum focal values of the multiple sub-windows; calculate the minimum value among the maximum focal values of the multiple sub-windows; calculate the absolute difference between the maximum and minimum values; and determine whether a pixel in the local window is a horizontal outlier based on the absolute difference.
[0100] In one possible implementation, the processing module 202 is specifically used to determine that if the absolute difference is less than a second threshold, the pixel in the local window is a normal point in the horizontal direction; if the absolute difference is greater than or equal to the second threshold, the pixel in the local window is an abnormal point in the horizontal direction.
[0101] In one possible implementation, the processing module 202 is specifically used to optimize outliers in the focal volume matrix based on the curve difference method to obtain an intermediate matrix; calculate the change difference of each pixel between the intermediate matrix and the focal volume matrix; if the change difference is less than a third threshold, then the intermediate matrix is determined to be the optimized focal volume matrix; if the change difference is greater than or equal to the third threshold, then the intermediate matrix is optimized along the optical axis and horizontal direction until the change difference is less than the third threshold, thus obtaining the optimized focal volume matrix.
[0102] In one possible implementation, the processing module 202 is specifically used to calculate the focal value of each pixel in the multi-layer image based on the three-dimensional grayscale matrix and a preset focal measurement operator; and to determine the focal volume matrix based on the focal value of each pixel in the multi-layer image.
[0103] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. For example... Figure 6 As shown, the electronic device 300 of this embodiment includes: a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program 303, it implements the steps in the above-described method embodiments, for example... Figure 1 The steps S101-S105 are shown. Alternatively, when the processor 301 executes the computer program 303, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 5 The functions of the communication module 201 and the processing module 202 shown are illustrated.
[0104] For example, the computer program 303 can be divided into one or more modules / units, which are stored in the memory 302 and executed by the processor 301 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program 303 in the electronic device 300. For example, the computer program 303 can be divided into... Figure 5 The communication module 401 and the processing module 402 are shown.
[0105] The processor 301 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0106] The memory 302 can be an internal storage unit of the electronic device 300, such as a hard disk or memory of the electronic device 300. The memory 302 can also be an external storage device of the electronic device 300, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 300. Furthermore, the memory 302 can include both internal and external storage units of the electronic device 300. The memory 302 is used to store the computer program and other programs and data required by the terminal. The memory 302 can also be used to temporarily store data that has been output or will be output.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0108] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0109] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0110] In the embodiments provided by this invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0111] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0112] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0113] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0114] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A focal volume optimization method based on prior information, characterized in that: include: Acquire multiple layers of images taken at different distances between the imaging system and the reconstructed object; Based on the multi-layer image, generating a three-dimensional grayscale matrix; The elements in the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer image; Based on the three-dimensional grayscale matrix, generating a focal volume matrix; The elements in the focal volume matrix are the focal values of each pixel in the multi-layer image, and the focal values are used to characterize the clarity level; Performing prior information calculation and outlier detection on the focal volume matrix to determine outliers in the focal volume matrix; Based on a curve difference method, optimizing the outliers in the focal volume matrix to obtain an optimized focal volume matrix; The method of optimizing the abnormal points in the focal volume matrix based on the curve difference method to obtain the optimized focal volume matrix includes: optimizing the abnormal points in the focal volume matrix based on the curve difference method to obtain an intermediate matrix; calculating the change difference of each pixel point between the intermediate matrix and the focal volume matrix; if the change difference is less than a third threshold, determining that the intermediate matrix is the optimized focal volume matrix; if the change difference is greater than or equal to the third threshold, optimizing the intermediate matrix along the optical axis direction and the horizontal direction until the change difference is less than the third threshold, so as to obtain the optimized focal volume matrix.
2. The focal volume optimization method based on prior information according to claim 1, characterized in that: The calculating of prior information on the focal volume matrix and the detection of outliers to determine outliers in the focal volume matrix include: Along the optical axis direction, outlier detection is performed on each pixel point in the focal volume matrix to obtain outliers in the optical axis direction; Along the horizontal direction, outlier detection is performed on each pixel in the focal volume matrix to obtain outliers in the horizontal direction; Based on the outliers in the optical axis direction and the outliers in the horizontal direction, outliers in the focal volume matrix are determined.
3. The focal volume optimization method based on prior information according to claim 2, characterized in that: The method of performing outlier detection on each pixel point in the focal volume matrix along the optical axis direction to obtain outliers in the optical axis direction includes: For any pixel point, a focusing curve of the pixel point is normalized to obtain a normalized focusing curve; the focusing curve is a curve composed of the number of image layers and the focus value along the optical axis direction; Performing a gamma transformation on the normalized focus curve to obtain a gamma sequence of the pixel point, wherein the gamma sequence is a gamma value of the pixel point in each image layer; Based on the gamma values of the gamma sequence of the pixel point, interval division and re-assignment are performed to obtain the assigned gamma values and the intervals corresponding to the gamma values; Calculating the information entropy of the pixel based on the assigned gamma values and the intervals corresponding to the gamma values; Based on the information entropy of the pixel, determine whether the pixel is an abnormal point in the optical axis direction.
4. The focal volume optimization method based on prior information according to claim 3, characterized in that: The gamma values of the gamma sequence based on the pixel point are divided into intervals and re-assigned to obtain the assigned gamma values and the intervals corresponding to the gamma values, including: Divide 0 to 1 into N equal parts to get N intervals; Based on the gamma values of the gamma sequence of the pixel point and the N intervals, determining the interval corresponding to each gamma value; Based on the intervals corresponding to the gamma values, each gamma value is reassigned to obtain an assigned gamma value.
5. The focal volume optimization method based on prior information according to claim 3, characterized in that: The determining, based on the information entropy of the pixel point, whether the pixel point is an abnormal point in the optical axis direction includes: If the information entropy of the pixel point is less than the first threshold, the pixel point is determined to be a normal point in the optical axis direction; If the information entropy of the pixel point is greater than or equal to the first threshold, the pixel point is determined to be an abnormal point in the optical axis direction.
6. The focal volume optimization method based on prior information according to claim 2, characterized in that: The method of performing outlier detection on each pixel in the focal volume matrix along the horizontal direction to obtain outliers in the horizontal direction includes: For a local window on any image layer, the local window is divided to obtain multiple sub-windows; Calculating minimum focus values and maximum focus values of the multiple sub-windows; Calculating the maximum value among the minimum focus values of the multiple sub-windows; Calculating a minimum value among the maximum focus values of the plurality of sub-windows; Calculate the absolute difference between the maximum value and the minimum value; Based on the absolute difference, it is determined whether the pixel point in the local window is an abnormal point in the horizontal direction.
7. The focal volume optimization method based on prior information according to claim 6, characterized in that: The determining, based on the absolute difference, whether the pixel point in the local window is an abnormal point in the horizontal direction includes: If the absolute difference is less than a second threshold, determining that the pixel point in the local window is a normal point in the horizontal direction; If the absolute difference is greater than or equal to the second threshold, the pixel point in the local window is determined to be an abnormal point in the horizontal direction.
8. The focal volume optimization method based on prior information according to claim 1, characterized in that: The generating a focal volume matrix based on the three-dimensional grayscale matrix comprises: Based on the three-dimensional grayscale matrix and a preset focus measurement operator, a focus value of each pixel in the multi-layer image is calculated; The focal volume matrix is determined based on the focal value of each pixel in the multi-layer image.
9. A focal volume optimization device based on prior information, characterized in that: include: A communication module, used to obtain multi-layer images taken at different distances between the imaging system and the reconstructed object; A processing module, used to generate a three-dimensional grayscale matrix based on the multi-layer image; the elements in the three-dimensional grayscale matrix are the grayscale values of each pixel in the multi-layer image; Based on the three-dimensional grayscale matrix, generating a focal volume matrix; The elements in the focal volume matrix are the focal values of each pixel in the multi-layer image, and the focal values are used to characterize the clarity level; Performing prior information calculation and outlier detection on the focal volume matrix to determine outliers in the focal volume matrix; Based on a curve difference method, optimizing the outliers in the focal volume matrix to obtain an optimized focal volume matrix; The processing module is specifically used to optimize the abnormal points in the focal volume matrix based on the curve difference method to obtain an intermediate matrix; Calculating the change difference of each pixel point between the intermediate matrix and the focal volume matrix; If the change difference is less than a third threshold, determining that the intermediate matrix is an optimized focal volume matrix; If the change difference is greater than or equal to the third threshold, the intermediate matrix is optimized along the optical axis direction and the horizontal direction until the change difference is less than the third threshold, thereby obtaining the optimized focal volume matrix.
Citation Information
Patent Citations
Abnormal focus removing method
CN103745435A
An object volume measurement device and method applied to a smart phone
CN109903328A
