A focused topography recovery method based on k-nearest neighbor optimization and alternating direction method of multipliers
By generating fully focused images using an improved modified Laplacian operator and k-nearest neighbor optimization, and combining differentiated weights and color guidance, the depth map is optimized using an energy minimization model with alternating direction multipliers. This solves the depth constraint problem in weakly textured regions and achieves efficient and stable 3D topography restoration.
Patent Information
- Application Number
- CN202610814716.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-25
AI Technical Summary
Existing focused topography restoration methods lack depth constraint mechanisms in weakly textured regions, making it difficult to balance smoothness and edge preservation. They also suffer from insufficient optimization efficiency and stability, making it difficult to meet real-time requirements.
An improved modified Laplacian operator and k-nearest neighbor optimization are used to generate fully focused images. Combined with differentiated weight design and color guidance, depth map optimization is performed through an energy minimization model of alternating direction multipliers. An algebraic multigrid method is used to accelerate the solution.
Under conditions of weak texture and high noise, it improves the accuracy and detail preservation of focused topography restoration, enhances reconstruction efficiency and stability, and meets real-time requirements.
Smart Images

Figure CN122636690A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of focused topography restoration, and more particularly to a focused topography restoration method based on k-nearest neighbor optimization and alternating direction multipliers. Background Technology
[0002] Shape From Focus (SFF) is a passive 3D reconstruction technique based on scene focus cues. Its core principle is to use a monocular camera to capture multiple images of the same scene at different focus settings, ensuring that different depth levels of a 3D object are clearly imaged on their respective focal planes. By analyzing the degree of focus of each pixel at different focal positions, the corresponding depth information is inferred, thereby reconstructing the 3D shape of the object.
[0003] Traditional focused topography restoration methods mainly consist of two key steps: focused evaluation and depth map optimization.
[0004] In the focus evaluation stage, it is first necessary to design focus measurement operators (such as the Laplacian operator, gray-level variance, etc.) to measure the focus of the image sequence and generate the focus volume. However, existing focus measurement operators have obvious scene dependence: in high-texture areas, gradient information is abundant, and the evaluation results are relatively reliable; but in low-texture, textureless, or smooth areas, due to the lack of sufficient gray-level variation, the focus measurement values are easily affected by noise and may lead to misjudgment. In addition, factors such as sensor noise, exposure deviation, and lens aberration during the imaging process further cause the initially generated focus volume to contain a large amount of unreliable data.
[0005] To address the noise problem in focusing volume, existing technologies have proposed various optimization strategies. Ali et al. constructed an energy minimization framework that integrates smoothing, structural similarity, and data fidelity terms for focusing volume optimization; and proposed a regularization reconstruction method that introduces a non-convex regularizer and multi-shape priors, which improves the robustness of focusing volume to some extent.
[0006] In the depth map optimization stage, researchers have attempted to model the focus shape restoration problem as a depth reconstruction problem. Boshtayeva et al. proposed an anisotropic depth map smoothing framework, adaptively adjusting the smoothing intensity based on the local structural features of the depth map. Tseng and Wang proposed a depth reconstruction algorithm based on the matted Laplacian matrix, using fully focused images to construct a spatially coherent prior. Ma et al. further proposed a matted Laplacian matrix depth reconstruction method based on the nonlocal principle, and proposed an edge-preserving depth refinement method to address the spatial inconsistencies and texture duplication artifacts caused by the nonlocal principle. He et al. addressed the problem of depth map outliers caused by focus curve noise, proposing a dual-mask filtering method that combines focus curve noise classification, and completing depth map restoration through maximum a posteriori probability estimation of Markov random fields.
[0007] Although the above methods have made some progress in focused evaluation and depth map optimization, the following technical limitations still exist:
[0008] First, the depth constraint mechanism for weakly textured regions is lacking. Existing methods have failed to design effective depth propagation constraint strategies for weakly textured or textureless regions. In these regions, due to the unreliability of the focusing measurements themselves and the lack of effective constraint information from neighboring pixels, depth estimation is prone to severe distortion, becoming a key bottleneck restricting reconstruction accuracy.
[0009] Second, it is difficult to achieve both smoothness and edge preservation. Most depth map optimization methods use a global uniform smoothing strategy, which over-smooths edge details while suppressing noise, resulting in blurred edges and loss of details in the reconstructed shape, making it impossible to accurately restore the true 3D features of the scene.
[0010] Third, the optimization efficiency and stability are insufficient. Traditional energy minimization models based on L1 norm or total variational (TV) regularization have complex solution processes and slow convergence speeds due to the non-smooth objective function, making it difficult to meet the real-time requirements of actual industrial testing. Summary of the Invention
[0011] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a focused topography restoration method based on k-nearest neighbor optimization and alternating direction multipliers. By using an improved MLAP (Modified Laplacian) method and k-nearest neighbor optimization, this method overcomes the focusing evaluation errors of traditional focused topography restoration methods in weak or no textured regions. At the same time, it uses differentiated weight design and color guidance to improve the edge detail preservation ability of the depth map. Finally, it combines the energy minimization model of alternating direction multipliers to optimize the depth map. This method has good topography restoration performance under weak texture and high noise conditions.
[0012] To achieve the above objectives, the technical solution provided by this invention is as follows:
[0013] A focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers includes:
[0014] A multi-cluster image sequence is acquired, and a modified Laplacian operator is used to evaluate the focus of each source image in the multi-cluster image sequence. A fully focused image is then generated through probabilistic fusion.
[0015] Construct a five-dimensional feature space based on the obtained full-focus image and perform... Nearest neighbor search is used to determine the set of nearest neighbor pixels for each pixel. Then, the focusing volume is optimized by nonlocal weighting based on the set of nearest neighbor pixels. Finally, the focusing curve is fitted by three-point Gaussian interpolation based on the nonlocal weighted focusing volume to obtain the initial depth image.
[0016] The reliability metric is calculated by combining the obtained focus curve; then, the data fidelity weight is calculated by combining the reliability metric with a differentiation strategy; at the same time, the smoothing guidance weight is calculated by combining the color gradient information of the full-focus image.
[0017] By combining data fidelity weights and smoothing guidance weights, an energy minimization model based on L1 norm smoothing terms is constructed. The constrained optimization problem of the energy minimization model is decomposed into a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method. The initial depth image is then optimized to obtain the final depth image.
[0018] Furthermore, the process of acquiring a full-focus image includes:
[0019] For the first in a multifocus image sequence Zhang Yuan Image Calculate the modified Laplace response:
[0020] ;
[0021] The modified Laplace response is improved, and the improved modified Laplace response is calculated, which is the corresponding focused measurement value. :
[0022] ;
[0023] in, For the first Zhang Yuan Image In position The corrected Laplace response value at the location; For the first Location in Zhang Yuan's image Pixel value at; The threshold for suppressing noise effects, The size of the window; Indicated by The coordinates of neighboring pixels within the central local window;
[0024] Let the first Location in Zhang Yuan's image pixels at probability With the corresponding focused measurement value If they are proportional, then:
[0025] ;
[0026] For the first Zhang Yuan's image is in location The focused measurement value at the location; This represents the total number of source images in a multifocus image sequence.
[0027] Full-focus image Given below:
[0028] ;
[0029] For the first Location in Zhang Yuan's image pixels at The probability of; For the first Location in Zhang Yuan's image The pixel value at that location.
[0030] Furthermore, a five-dimensional feature space is constructed based on the obtained fully focused image and then executed. Nearest neighbor search is performed to determine the set of nearest neighbor pixels for each pixel. Then, non-local weighted optimization of the focusing volume is performed based on the set of nearest neighbor pixels, including:
[0031] A five-dimensional feature space is constructed based on the obtained full-focus image. ,in For normalized spatial coordinates, These are RGB values that have been normalized and scaled by a factor of 1 / 3.
[0032] Using Euclidean distance in the five-dimensional feature space Search Nearest neighbors are obtained by finding the nearest neighbor pixels of each pixel, i.e., the set of nearest neighbor pixels. ;
[0033] Based on the nearest neighbor pixel set Nonlocal weighted optimization of the focusing volume:
[0034] ;
[0035] in, These are the optimized focused measurement values. pixel position The nearest neighbor pixel position, The focused measurement value calculated by equation (2); The nonlocal weights are calculated using the following formula:
[0036] ;
[0037] in, Set of nearest neighbor pixels The number of nearest neighbor pixels in the array; For the first Zhang Yuan's location in the picture Pixel value at that location, It is the average pixel value within a non-local window. The pixel variance of the non-local window. It is a very small positive value that prevents division by zero.
[0038] Furthermore, based on the nonlocally weighted optimized focusing volume, the focusing curve is fitted using three-point Gaussian interpolation, located at... The focal measurement of the position is defined in continuous depth Gaussian function on Approximation:
[0039] ;
[0040] in, The peak value of the Gaussian function; and These represent the corresponding optimal depth of focus and standard deviation, respectively.
[0041] Thus, the initial depth image is obtained. :
[0042] .
[0043] Furthermore, a reliability metric is calculated by combining the obtained focusing curve. The calculation formula is as follows:
[0044] ;
[0045] in, For located Reliability measurements of the location, In order to be in Maximum focused measurement of the position; Indicates that it is located at The position at the first Gaussian fitted values, Indicates in The position of One focused measurement value, This represents the total number of source images in the multifocus image sequence.
[0046] Furthermore, combined with reliability metrics Calculate data fidelity weights using a differentiation strategy. The calculation formula is as follows:
[0047] ;
[0048] in, For pixel position, For in position Data fidelity weighting at the location For in position The k-nearest neighbor depth pixel variance, For the set unconfidence parameter less than 1, The set confidence threshold, It is a very small positive number that is divisible by zero; In order to be in Maximum focused measurement of the position; In order to be in Minimum focused measurement of position.
[0049] Furthermore, the smoothing guidance weights are calculated by combining the color gradient information of the fully focused image, using the following formula:
[0050] ;
[0051] in, To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; For pixel position; The set of color channels of a fully focused image. ; This refers to the number of color channels; For full-focus images in Position No. The values of each color channel; The color sensitivity parameter is set to control the degree of smoothing; It is an exponential function.
[0052] Furthermore, by combining data fidelity weights and smoothing guidance weights, the energy minimization model based on the L1 norm smoothing term is constructed as follows:
[0053] ;
[0054] in, This is the initial depth image; Weighting to ensure data fidelity; To smooth out the guiding weights, , To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; The depth image to be solved is... The depth image to be solved The gradient; This means that the gradients in the horizontal and vertical directions are weighted element-wise using the corresponding smoothing guide weights. A positive weight parameter is used to balance the data items and the smoothing items; For data fidelity items; This is an L1 norm smoothing term.
[0055] Furthermore, the energy minimization model is decomposed into an iterative solution of a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method. This optimizes the initial depth image to obtain the final depth image, including:
[0056] make Then the augmented Lagrange function of the energy function Represented as:
[0057] ;
[0058] in, For Lagrange multipliers; As an auxiliary variable; The dual variable for constraining the Lagrange multipliers of the penalty term; It is the Lagrange penalty factor;
[0059] The constrained optimization problem is transformed into an iterative solution of a depth graph subproblem, an auxiliary variable subproblem, and a dual variable subproblem. The problem is solved using an alternating minimization approach. For the depth graph subproblem, the values of the auxiliary variable and dual variable are extracted using equation (13). The relevant items yielded:
[0060] ;
[0061] Equation (15) gives the solution to equation (14):
[0062] ;
[0063] in, for Transpose of; Index for iteration count; This is the Toeplitz matrix, corresponding to the matrix form of the horizontal and vertical forward difference operators, used to uniformly calculate the gradients in the horizontal and vertical directions;
[0064] For equation (15), since its coefficient matrix is symmetric and positive definite and has a structure similar to the discrete matrix of elliptic partial differential equations, it can be solved quickly by the algebraic multigrid method.
[0065] For the auxiliary variable subproblem, the result is extracted from equation (13) and... The relevant items yielded:
[0066] ;
[0067] The solution to equation (17) is calculated using soft threshold shrinkage:
[0068] ;
[0069] The operator in the formula extends vectors and matrices by processing data element by element;
[0070] Dual variables With Lagrange penalty factor The update is given by equation (18):
[0071] ;
[0072] when The iteration stops when the maximum number of iterations is reached.
[0073] Compared with existing technologies, the principles and advantages of this technical solution are as follows:
[0074] 1. To address the issue of response distortion in weakly textured regions by the traditional modified Laplacian operator, a weak response suppression and local aggregation mechanism is introduced, and probability-weighted fusion is used to replace hard decision. The resulting fully focused image has smooth pixels, high color fidelity, and strong reference value, providing a high-quality foundation for subsequent processing.
[0075] 2. A k-nearest neighbor-based focusing volume optimization strategy is proposed. By searching for similar pixels of each pixel in the fully focused image and calculating non-local weights, noise in the focusing volume is effectively suppressed, avoiding the focusing response error propagation problem caused by traditional local mean filtering. At the same time, it alleviates the multi-peak interference of the focusing curve caused by high reflectance diffusion and enhances the accuracy of focusing evaluation.
[0076] 3. A differentiated weighting calculation strategy is adopted. By identifying the confidence and non-confidence regions in the depth map, data fidelity weights are calculated in a targeted manner. Color-guided smoothing weights are constructed by combining the color features of the full-focus image, so as to achieve a balance between edge and detail preservation and noise suppression during the depth map optimization process.
[0077] 4. An energy minimization model using alternating direction multipliers is used for depth map optimization, and an algebraic multigrid method is introduced to transform the solution complexity of the depth map subproblem from nonlinear to linear, thereby improving the efficiency and stability of depth map optimization. Combined with the synergistic effect of the above technologies, this invention can still maintain good focused topography recovery performance under complex conditions such as weak texture and high noise. Attached Figure Description
[0078] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, 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.
[0079] Figure 1 This is a flowchart illustrating the principle of a focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers, according to an embodiment of the present invention. Detailed Implementation
[0080] The present invention will be further described below with reference to specific embodiments:
[0081] like Figure 1 As shown in the figure, the focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers described in this embodiment includes the following steps:
[0082] S1. Acquire a multi-cluster image sequence, perform focus evaluation on each source image in the multi-cluster image sequence using an improved modified Laplacian operator, and generate a fully focused image through probabilistic fusion;
[0083] In this step, the process of generating a fully focused image is as follows:
[0084] For the first in a multifocus image sequence Zhang Yuan Image Calculate the modified Laplace response:
[0085] ;
[0086] The modified Laplace response is improved, and the improved modified Laplace response is calculated, which is the corresponding focused measurement value. :
[0087] ;
[0088] in, For the first Zhang Yuan Image In position The corrected Laplace response value at the location; For the first Location in Zhang Yuan's image Pixel value at; The threshold for suppressing noise effects, The size of the window; Indicated by The coordinates of neighboring pixels within the central local window;
[0089] Let the first Location in Zhang Yuan's image pixels at probability With the corresponding focused measurement value If they are proportional, then:
[0090] ;
[0091] For the first Zhang Yuan's image is in location The focused measurement value at the location; This represents the total number of source images in a multifocus image sequence.
[0092] Full-focus image Given below:
[0093] ;
[0094] For the first Location in Zhang Yuan's image pixels at The probability of; For the first Location in Zhang Yuan's image The pixel value at that location.
[0095] S2. Construct a five-dimensional feature space based on the obtained full-focus image and execute... Nearest neighbor search is used to determine the set of nearest neighbor pixels for each pixel. Then, the focusing volume is optimized by nonlocal weighting based on the set of nearest neighbor pixels. Finally, the focusing curve is fitted by three-point Gaussian interpolation based on the nonlocal weighted focusing volume to obtain the initial depth image.
[0096] In this step, a five-dimensional feature space is constructed based on the obtained fully focused image and then executed. Nearest neighbor search is performed to determine the set of nearest neighbor pixels for each pixel. Then, non-local weighted optimization of the focusing volume is performed based on the set of nearest neighbor pixels, including:
[0097] A five-dimensional feature space is constructed based on the obtained full-focus image. ,in For normalized spatial coordinates, These are RGB values that have been normalized and scaled by a factor of 1 / 3.
[0098] Using Euclidean distance in the five-dimensional feature space Search Nearest neighbors are obtained by finding the nearest neighbor pixels of each pixel, i.e., the set of nearest neighbor pixels. ;
[0099] Based on the nearest neighbor pixel set Nonlocal weighted optimization of the focusing volume:
[0100] ;
[0101] in, These are the optimized focused measurement values. pixel position The nearest neighbor pixel position, The focused measurement value calculated by equation (2); The nonlocal weights are calculated using the following formula:
[0102] ;
[0103] in, Set of nearest neighbor pixels The number of nearest neighbor pixels in the array; For the first Zhang Yuan's location in the picture Pixel value at that location, It is the average pixel value within a non-local window. The pixel variance of the non-local window. It is a very small positive value that prevents division by zero.
[0104] In this step, based on the non-locally weighted optimized focusing volume, the focusing curve is fitted using three-point Gaussian interpolation, located at... The focal measurement of the position is defined in continuous depth Gaussian function on Approximation:
[0105] ;
[0106] in, The peak value of the Gaussian function; and These represent the corresponding optimal depth of focus and standard deviation, respectively.
[0107] Thus, the initial depth image is obtained. :
[0108] .
[0109] S3. Calculate the reliability metric by combining the obtained focus curve; then calculate the data fidelity weight by combining the reliability metric with the differentiation strategy; at the same time, calculate the smoothing guidance weight by combining the color gradient information of the full-focus image.
[0110] In this step, the reliability metric is calculated based on the obtained focusing curve. The calculation formula is as follows:
[0111] ;
[0112] in, For located Reliability measurements of the location, In order to be in Maximum focused measurement of the position; Indicates that it is located at The position at the first Gaussian fitted values, Indicates in The position of One focused measurement value, This represents the total number of source images in the multifocus image sequence.
[0113] In this step, reliability metrics are incorporated. Calculate data fidelity weights using a differentiation strategy. The calculation formula is as follows:
[0114] ;
[0115] in, For pixel position, For in position Data fidelity weighting at the location For in position The k-nearest neighbor depth pixel variance, For the set unconfidence parameter less than 1, The set confidence threshold, It is a very small positive number that is divisible by zero; In order to be in Maximum focused measurement of the position; In order to be in Minimum focused measurement of position.
[0116] In this step, the smoothing guide weight is calculated by combining the color gradient information of the fully focused image. The calculation formula is as follows:
[0117] ;
[0118] in, To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; For pixel position; The set of color channels of a fully focused image. ; This refers to the number of color channels; For full-focus images in Position No. The values of each color channel; The color sensitivity parameter is set to control the degree of smoothing; It is an exponential function.
[0119] S4. Combining data fidelity weights and smoothing guidance weights, an energy minimization model based on the L1 norm smoothing term is constructed. The constrained optimization problem of the energy minimization model is decomposed into a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method. The initial depth image is then optimized to obtain the final depth image.
[0120] In this step, by combining data fidelity weights and smoothing guiding weights, the energy minimization model based on the L1 norm smoothing term is constructed as follows:
[0121] ;
[0122] in, This is the initial depth image; Weighting to ensure data fidelity; To smooth out the guiding weights, , To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; The depth image to be solved is... The depth image to be solved The gradient; This means that the gradients in the horizontal and vertical directions are weighted element-wise using the corresponding smoothing guide weights. A positive weight parameter is used to balance the data items and the smoothing items; For data fidelity items; This is an L1 norm smoothing term.
[0123] In this step, the energy minimization model is decomposed into a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method, and iteratively solved to optimize the initial depth image, resulting in the final depth image, including:
[0124] make Then the augmented Lagrange function of the energy function Represented as:
[0125] ;
[0126] in, For Lagrange multipliers; As an auxiliary variable; The dual variable for constraining the Lagrange multipliers of the penalty term; It is the Lagrange penalty factor;
[0127] The constrained optimization problem is transformed into an iterative solution of a depth graph subproblem, an auxiliary variable subproblem, and a dual variable subproblem. The problem is solved using an alternating minimization approach. For the depth graph subproblem, the values of the auxiliary variable and dual variable are extracted using equation (13). The relevant items yielded:
[0128] ;
[0129] Equation (15) gives the solution to equation (14):
[0130] ;
[0131] in, for Transpose of; Index for iteration count; This is the Toeplitz matrix, corresponding to the matrix form of the horizontal and vertical forward difference operators, used to uniformly calculate the gradients in the horizontal and vertical directions;
[0132] For equation (15), since its coefficient matrix is symmetric and positive definite and has a structure similar to the discrete matrix of elliptic partial differential equations, it can be solved quickly by the algebraic multigrid method.
[0133] For the auxiliary variable subproblem, the result is extracted from equation (13) and... The relevant items yielded:
[0134] ;
[0135] The solution to equation (17) is calculated using soft threshold shrinkage:
[0136] ;
[0137] The operator in the formula extends vectors and matrices by processing data element by element;
[0138] Dual variables With Lagrange penalty factor The update is given by equation (18):
[0139] ;
[0140] when The iteration stops when the maximum number of iterations is reached.
[0141] This embodiment designs an energy minimization model based on alternating direction multipliers, decomposes the complex energy minimization problem into three independent simple subproblems, and introduces an algebraic multigrid method to transform the solution complexity of the depth map subproblem from nonlinear to linear, significantly improving the solution speed, shortening the optimization time, and further enhancing the practical application value of the focused topography restoration method.
[0142] The above-described embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Therefore, any changes made in accordance with the shape and principle of the present invention should be covered within the protection scope of the present invention.
Claims
1. A focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers, characterized in that, include: A multi-cluster image sequence is acquired, and a modified Laplacian operator is used to evaluate the focus of each source image in the multi-cluster image sequence. A fully focused image is then generated through probabilistic fusion. A five-dimensional feature space is constructed based on the obtained full-focus image, and then... Nearest neighbor search is used to determine the set of nearest neighbor pixels for each pixel. Then, the focusing volume is optimized by nonlocal weighting based on the set of nearest neighbor pixels. Finally, the focusing curve is fitted by three-point Gaussian interpolation based on the nonlocal weighted focusing volume to obtain the initial depth image. The reliability metric is calculated by combining the obtained focus curve; then, the data fidelity weight is calculated by combining the reliability metric with a differentiation strategy; at the same time, the smoothing guidance weight is calculated by combining the color gradient information of the full-focus image. By combining data fidelity weights and smoothing guidance weights, an energy minimization model based on L1 norm smoothing terms is constructed. The constrained optimization problem of the energy minimization model is decomposed into a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method. The initial depth image is then optimized to obtain the final depth image.
2. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 1, characterized in that, The process of acquiring a panfocused image includes: For the first in a multifocus image sequence Zhang Yuan Image Calculate the modified Laplace response: ; The modified Laplace response is improved, and the improved modified Laplace response, i.e., the corresponding focused measurement value, is calculated. : ; in, For the first Zhang Yuan Image In position The corrected Laplace response value at the location; For the first Location in Zhang Yuan's image Pixel value at; The threshold for suppressing noise effects, The size of the window; Indicated by The coordinates of neighboring pixels within the local window centered on the pixel; Let the first Location in Zhang Yuan's image pixels at probability With the corresponding focused measurement value If they are proportional, then: ; For the first Zhang Yuan's image is in location The focused measurement value at the location; This represents the total number of source images in a multifocus image sequence. Full-focus image Given below: ; For the first Location in Zhang Yuan's image pixels at The probability of; For the first Location in Zhang Yuan's image The pixel value at that location.
3. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 2, characterized in that, A five-dimensional feature space is constructed based on the obtained full-focus image, and then... Nearest neighbor search is performed to determine the set of nearest neighbor pixels for each pixel. Then, non-local weighted optimization of the focusing volume is performed based on the set of nearest neighbor pixels, including: A five-dimensional feature space is constructed based on the obtained full-focus image. ,in For normalized spatial coordinates, These are RGB values that have been normalized and scaled by a factor of 1 / 3. Using Euclidean distance in the five-dimensional feature space Search Nearest neighbors are obtained by finding the nearest neighbor pixels of each pixel, i.e., the set of nearest neighbor pixels. ; Based on the nearest neighbor pixel set Nonlocal weighted optimization of the focusing volume: ; in, These are the optimized focused measurement values. pixel position The nearest neighbor pixel position, The focused measurement value calculated by equation (2); The nonlocal weights are calculated using the following formula: ; in, Set of nearest neighbor pixels The number of nearest neighbor pixels in the array; For the first Zhang Yuan's location in the picture Pixel value at that location, It is the average pixel value within a non-local window. The pixel variance of the non-local window. It is a very small positive value that prevents division by zero.
4. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 3, characterized in that, Based on the nonlocally weighted optimized focusing volume, a focusing curve is fitted using three-point Gaussian interpolation, located at... The focal measurement of the position is defined by the continuous depth. Gaussian function on Approximation: ; in, The peak value of the Gaussian function; and These represent the corresponding optimal depth of focus and standard deviation, respectively. Thus, the initial depth image is obtained. : 。 5. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 4, characterized in that, Calculate the reliability metric by combining the obtained focusing curve. The calculation formula is as follows: ; in, For located Reliability measurements of the location, In order to be in Maximum focused measurement of the position; Indicates that it is located at The position at the first Gaussian fitted values, Indicates in The position of One focused measurement value, This represents the total number of source images in the multifocus image sequence.
6. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 5, characterized in that, Combine reliability metrics Calculate data fidelity weights using a differentiation strategy. The calculation formula is as follows: ; in, For pixel position, For in position Data fidelity weighting at the location For in position The k-nearest neighbor depth pixel variance, For the set unconfidence parameter less than 1, The set confidence threshold, It is a very small positive number that is protected against division by zero; In order to be in Maximum focused measurement of the position; In order to be in The minimum focused measurement of the position.
7. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 1, characterized in that, The smoothing guide weight is calculated by combining the color gradient information of the full-focus image, and the calculation formula is as follows: ; in, To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; For pixel position; The set of color channels of a fully focused image. ; This refers to the number of color channels; For full-focus images in Position No. The values of each color channel; The color sensitivity parameter is set to control the degree of smoothing; It is an exponential function.
8. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 1, characterized in that, Combining data fidelity weights and smoothing guiding weights, the energy minimization model based on the L1 norm smoothing term is constructed as follows: ; in, This is the initial depth image; Weighting to ensure data fidelity; To smooth out the guiding weights, , To guide the weights in the horizontal direction; Smooth guide weights in the vertical direction; The depth image to be solved is... The depth image to be solved The gradient; This means that the gradients in the horizontal and vertical directions are weighted element-wise using the corresponding smoothing guide weights. A positive weight parameter is used to balance the data items and the smoothing items; For data fidelity items; This is an L1 norm smoothing term.
9. The focused topography recovery method based on k-nearest neighbor optimization and alternating direction multipliers according to claim 8, characterized in that, The energy minimization model is decomposed into an iterative solution of a depth map subproblem, an auxiliary variable subproblem, and a dual variable subproblem using the alternating direction multiplier method. This optimizes the initial depth image to obtain the final depth image, including: make Then the augmented Lagrange function of the energy function Represented as: ; in, For Lagrange multipliers; As an auxiliary variable; The dual variable for constraining the Lagrange multipliers of the penalty term; It is the Lagrange penalty factor; The constrained optimization problem is transformed into an iterative solution of a depth graph subproblem, an auxiliary variable subproblem, and a dual variable subproblem. The problem is solved using an alternating minimization approach. For the depth graph subproblem, the values of the auxiliary variable and dual variable are extracted using equation (13). The relevant items yielded: ; Equation (15) gives the solution to equation (14): ; in, for Transpose of; Index for iteration count; This is the Toeplitz matrix, corresponding to the matrix form of the horizontal and vertical forward difference operators, used to uniformly calculate the gradients in the horizontal and vertical directions; For equation (15), the algebraic multigrid method can be used to solve it quickly. For the auxiliary variable subproblem, the result is extracted from equation (13) and... The relevant items yielded: ; The solution to equation (17) is calculated using soft threshold shrinkage: ; The operator in the formula extends vectors and matrices by processing data element by element; Dual variables With Lagrange penalty factor The update is given by equation (18): ; when The iteration stops when the maximum number of iterations is reached.