A method of uncertainty analysis for depth of focus estimation
By applying reversible perturbations to multi-focus image sequences and using gradients to calculate uncertainty scores, the problem of insufficient generalization ability of deep learning models in unknown scenarios is solved, achieving pixel-level uncertainty assessment, which is suitable for precision measurement and defect detection, and improving the reliability and accuracy of depth estimation.
Patent Information
- Application Number
- CN202611525474.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-29
- Publication Date
- 2026-11-24
Smart Images

Figure CN123160632A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of depth estimation in computer vision, and specifically relates to a method for analyzing the uncertainty of depth estimation. Background Technology
[0002] Focus depth estimation is a technique for inferring the three-dimensional spatial structure from a sequence of two-dimensional focused images. It aims to efficiently analyze focus response changes in image sequences and reconstruct the three-dimensional information of a scene with high accuracy. Based on the correlation between focus position and depth information in optical imaging principles, this technique offers advantages such as low cost and ease of deployment, and is commonly used in fields such as camera depth-of-field synthesis and microscopic three-dimensional measurement.
[0003] Existing depth estimation methods mainly fall into two paradigms: operator design-based and deep learning-based. Operator design-based methods evaluate images with different focal planes by designing focus measurement operators. Specifically, they first construct the focus volume and then recover the scene depth based on the location of the focus response peak. These methods rely on manually designed focus measurement operators, making it difficult to fully model the complex mapping relationship between multi-focus image sequences and scene depth. Deep learning-based methods, on the other hand, utilize large-scale datasets with real depth annotations to train multi-layer neural networks, establishing an end-to-end mapping relationship between multi-focus image sequences and scene depth. This allows the model to learn richer focus features and scene semantic information, resulting in superior depth estimation performance. However, in practical applications, variations in imaging conditions, sample materials, and optical parameters can cause input data to deviate from the training distribution, affecting the model's generalization ability in unknown scenes. Furthermore, low-texture regions, noise interference, imaging degradation, and complex optical conditions can damage the focus response features in image sequences, leading to degradation phenomena such as missing, blurred, or distorted depth-related cues. Due to the aforementioned factors, the model's ability to represent different scenarios and features varies, leading to significant differences in the reliability of depth estimation results across different regions. Existing deep learning models typically only output depth estimation results, lacking the ability to explicitly represent the reliability of these results. Furthermore, in applications such as precision measurement and defect detection, users not only focus on the depth estimation results themselves but also need to determine their reliability to support subsequent analysis, decision-making, and task execution. Therefore, it is necessary to perform pixel-by-pixel uncertainty estimation on the depth estimation results to quantify the reliability of each pixel's depth estimation result and provide a basis for identifying potential failure areas in the depth estimation results.
[0004] To address the aforementioned issues, this invention provides a gradient-based uncertainty assessment method for focused depth estimation. This method does not rely on real depth labels and requires no retraining of existing multi-focus depth estimation models, making it a general module that can be integrated into different types of multi-focus depth estimation frameworks. Addressing the application needs of deployed models in real-world scenarios, it can directly perform uncertainty assessment during the inference stage, making it suitable for large-scale continuous processing tasks of multi-focus image sequences in the absence of real depth labels, while also possessing good applicability and computational efficiency. Specifically, this invention applies a reversible perturbation to the input multi-focus image sequence that maintains scene structure consistency, obtaining a reference depth estimation result corresponding to the original depth estimation result. The difference between the two is used to construct a depth estimation consistency loss function to characterize the stability of the model's depth estimation result. When the depth estimation result has good stability, it typically maintains high consistency before and after the perturbation; however, when the depth estimation result is sensitive to input changes, it is prone to exhibiting large result differences. Based on this, the depth estimation consistency loss is backpropagated to a specified layer of the model decoder, and the gradient of the loss function on the feature representation of that layer is calculated. Since gradients characterize the sensitivity of the model depth estimation consistency loss to features, they can be used to depict the strength of the depth estimation result's response to input perturbations. A stronger gradient response indicates greater sensitivity of the model depth estimation to small perturbations, resulting in poorer stability and a higher level of uncertainty. Finally, max pooling, upsampling, and normalization operations are performed on the gradients to generate pixel-level uncertainty scores.
[0005] In practical applications, this invention can be used for three-dimensional topography measurement of precision device surfaces. Specifically, during the measurement process, a multi-focus depth estimation model is used to mine depth cues from the acquired multi-focus image sequences to recover the depth distribution of the device surface. The invention then uses this method to generate uncertainty scores for the depth estimation results corresponding to each pixel, which are used to identify potentially unreliable areas caused by factors such as low texture, reflection, and noise interference. For areas with high uncertainty, further re-acquisition or manual verification can be performed, thereby reducing the impact of unreliable depth estimation on the three-dimensional topography measurement results and improving the reliability of the measurement.
[0006] In summary, this invention, starting from practical application needs, utilizes gradients to characterize the uncertainty of multi-focus depth estimation results and identifies potentially unreliable regions in the depth estimation results at the pixel level. This method requires no real depth annotation, no network retraining, and only one backpropagation, and can be directly integrated into any multi-focus depth estimation model. In practical tasks such as microscopic 3D measurement, the generated uncertainty information can be used to screen the reliability of depth measurement results and provide a basis for re-acquisition, manual verification, and subsequent decision-making, thereby reducing the impact of unreliable depth estimation on subsequent tasks and providing effective support for the reliable application of multi-focus depth estimation in real-world scenarios. Summary of the Invention
[0007] To overcome the shortcomings of existing solutions, the purpose of this invention is to provide a gradient-based method for assessing the uncertainty of focusing depth estimation, comprising the following steps:
[0008] Step 1: By adjusting the focal length of the acquisition device to change the focal plane, images captured at different focal lengths are arranged in the order of capture to obtain a multi-focus image sequence covering the entire depth of field. , This represents the sequence number, and the size of a single frame image is... , Indicates the height and width of a single image. Indicates the number of channels in an image;
[0009] Step 2: The multifocus image sequence obtained in Step 1... The input is fed into the trained multi-focus depth estimation model, and the depth estimate is obtained through equation (1). ,
[0010] (1)
[0011] in, It is the mapping from input to output of the depth estimation model;
[0012] Step 3: Process the multifocus image sequence obtained in Step 1 By applying a reversible perturbation, a set of reference image sequences is obtained through equation (2). ,
[0013] (2)
[0014] in, For the first A type of invertible transformation function, The original multifocus image sequence is processed by the first... The reference image sequence obtained after a reversible transformation function The total number of reversible perturbations that can be applied;
[0015] Step 4: Combine the reference image sequence set obtained in Step 3 Inputting into the multi-focus depth estimation model, the corresponding depth estimation set is obtained through equation (3). ,
[0016] (3)
[0017] in, for Depth estimation obtained from the model;
[0018] Step 5: Apply the depth estimates obtained in Step 4 to the set of depth estimates. By applying the inverse function of the perturbation in equation (4), the reference depth estimation set can be obtained. ,
[0019] (4)
[0020] in, It is an invertible transformation function inverse function, For the first Reference depth estimation;
[0021] Step 6: Use the depth estimate obtained in Step 2 and the reference depth estimate obtained in step 5 Construct the auxiliary loss function using equation (5) ;
[0022] (5)
[0023] Step 7: Use the auxiliary loss function obtained in Step 6 via decoder Perform backpropagation and calculate the auxiliary loss function using equation (6). decoder The gradient of the specified feature representation,
[0024] , (6)
[0025] in, Indicates the first in the decoder layer layer, For the first Layer feature representation, For loss function Regarding feature representation The partial derivative of the loss function with respect to the feature representation;
[0026] Step 8: Apply the gradient obtained in Step 7 Max pooling is performed on the channel dimension using equation (7) to... The number of channels from Reduce to 1,
[0027] (7)
[0028] in, This represents the max pooling operation, which is defined as follows: ;
[0029] Step 9: The results obtained in Step 8 Upsampling and normalization are performed using equation (8) to match the spatial resolution with the depth map, ultimately yielding the uncertainty score. ,
[0030] (8)
[0031] in, This represents the upsampling operation, which is defined as follows: , and These are the maximum and minimum values of the gradient map, respectively.
[0032] Compared with existing methods, the present invention has the following advantages:
[0033] (1) The uncertainty analysis method for focusing depth estimation proposed in this invention uses the post-deterministic uncertainty method. The model’s sensitivity to a feature is characterized by the gradient of the feature, which is applicable to the uncertainty estimation of all deep learning models and has good universality.
[0034] (2) The uncertainty estimation method proposed in this invention does not require retraining the model and only requires one backpropagation to evaluate the reliability of the multi-focus depth estimation model with high efficiency and high accuracy. Attached Figure Description
[0035] Figure 1 This is a flowchart of a gradient-based method for assessing the uncertainty of focusing depth estimation.
[0036] Figure 2 This is a network architecture diagram for a gradient-based method for assessing the uncertainty of focusing depth estimation.
[0037] Figure 3 These are 30 samples from the multi-focus image sequence acquired in step 1 of Embodiment 1 of the present invention;
[0038] Figure 4 This is the actual depth annotation map of Example 1 of the present invention;
[0039] Figure 5 This is a depth estimation map of Example 1 of the present invention;
[0040] Figure 6 This is the actual error diagram of Example 1 of the present invention;
[0041] Figure 7 This is an uncertainty diagram of Example 1 of the present invention;
[0042] Figure 8 This is a graph showing the difference between the actual error and the uncertainty in Example 1 of the present invention. Detailed Implementation
[0043] Example 1
[0044] like Figure 1 , Figure 2 As shown, this embodiment applies the gradient-based focusing depth estimation uncertainty assessment method proposed in this invention to the three-dimensional topography measurement of the surface of precision devices, including the following steps:
[0045] Step 1: By adjusting the focal length of the acquisition device to change the focal plane, images captured at different focal lengths are arranged in the order of capture to obtain a multi-focus image sequence covering the entire depth of field. , This represents the sequence number, and the size of a single frame image is... , Indicates the height and width of a single image. This refers to the number of channels in an image. Specifically, it is obtained by acquiring images of precision devices across the entire scene, such as... Figure 3 The multi-focused sequence shown, wherein the number of sequences is... Image high Image width Image channels ;
[0046] Step 2: The multifocus image sequence obtained in Step 1... The input is fed into the trained multi-focus depth estimation model, and the result is obtained through equation (1). Figure 5 Depth estimation ,
[0047] (1)
[0048] in, It is the mapping from input to output of the depth estimation model;
[0049] Step 3: Process the multifocus image sequence obtained in Step 1 By applying a reversible perturbation, a set of reference image sequences is obtained through equation (2). ,
[0050] (2)
[0051] in, For the first A type of invertible transformation function, The original multifocus image sequence is processed by the first... The reference image sequence obtained after a reversible transformation function For the total number of reversible perturbations that can be applied; specifically, for Figure 3 Multifocus image sequences Apply horizontal flip, and The gamma transform has three invertible transformations, and the total number of invertible perturbations that can be applied. , , , , ;
[0052] Step 4: Combine the reference image sequence set obtained in Step 3 Inputting into the multi-focus depth estimation model, the corresponding depth estimation set is obtained through equation (3). ;
[0053] (3)
[0054] in, for Depth estimation obtained from the model;
[0055] Step 5: Apply the depth estimates obtained in Step 4 to the set of depth estimates. By applying the inverse function of the perturbation in equation (4), the reference depth estimation set can be obtained. ,
[0056] (4)
[0057] in, It is an invertible transformation function inverse function, For the first Reference depth estimation;
[0058] Step 6: Use the depth estimate obtained in Step 2 and the reference depth estimate obtained in step 5 Construct the auxiliary loss function using equation (5) ;
[0059] (5)
[0060] Step 7: Use the auxiliary loss function obtained in Step 6 to pass through the decoder. Perform backpropagation and calculate the auxiliary loss function for the decoder using equation (6). The gradient of the specified feature representation,
[0061] , (6)
[0062] in, Indicates the first in the decoder layer layer, For the first Layer feature representation, For loss function Regarding feature representation The partial derivative of the loss function with respect to the feature representation; specifically, in Example 1, ;
[0063] Step 8: Apply the gradient obtained in Step 7 Max pooling is performed on the channel dimension using equation (7) to... The number of channels from Reduce to 1,
[0064] (7)
[0065] in, This represents the max pooling operation, which is defined as follows: ;
[0066] Step 9: The results obtained in Step 8 Upsampling and normalization are performed using equation (8) to match the spatial resolution with the depth map, ultimately yielding the uncertainty score. ,like Figure 7 As shown,
[0067] (8)
[0068] in, This represents the upsampling operation, which is defined as follows: , and These are the maximum and minimum values of the gradient map, respectively.
[0069] To verify the effectiveness of the gradient-based focusing depth estimation uncertainty assessment method proposed in this invention, this embodiment is based on... Figure 3 The scene shown corresponds to Figure 4 True depth annotation map and Figure 5 The depth estimation map is obtained by calculating the error between the depth estimation result and the true depth pixel by pixel. Figure 6 The actual error diagram shown is combined with... Figure 7 The uncertainty graph shown is further constructed. Figure 8 The diagram shows the difference between the true error and the uncertainty. The true error diagram uses a Hot color map to visualize the depth estimation error at each pixel location. The difference diagram uses quantile thresholds to divide the true error and uncertainty scores separately, and classifies pixels into four categories based on the combination of these two scores: yellow indicates high error and high uncertainty, red indicates high error and low uncertainty, blue indicates low error and high uncertainty, and black indicates low error and low uncertainty.
[0070] Depend on Figure 8The difference map shows that in areas where depth estimation errors are concentrated, such as the edges of precision device contours, pixels are mainly distributed in yellow, indicating that the uncertainty score obtained by this method can respond well to locations with large depth estimation errors. Meanwhile, the red areas with high error and low uncertainty do not form a large, continuous distribution, and the proportion of blue areas with low error and high uncertainty is also relatively small. Further comparison... Figure 6 True error plot and Figure 7 The uncertainty map reveals that high-error regions typically correspond to higher uncertainty scores, and the yellow areas in the difference map show a high degree of consistency with the high-error regions in the true error map in terms of spatial location and distribution range. These visualization results demonstrate that the gradient uncertainty score obtained in this invention effectively reflects the reliability of the depth estimation results and exhibits a good spatial correspondence with the true depth estimation error, thus verifying the effectiveness and rationality of the proposed gradient-based uncertainty assessment method for focusing depth estimation.
Claims
1. An uncertainty analysis method focusing on depth estimation, comprising the following steps: Step 1: Change the focal plane by adjusting the focal length of the acquisition device, arrange the images taken at different focal lengths according to the shooting order, and obtain a multi-focus image sequence covering the entire depth of field , indicates the sequence number, and the size of a single frame image is , indicates the height and width of a single image, indicates the number of channels of the image; Step 2: The multifocus image sequence obtained in Step 1... The input is fed into the trained multi-focus depth estimation model, and the depth estimate is obtained through equation (1). , (1) in, It is the mapping from input to output of the depth estimation model; Step 3: Process the multifocus image sequence obtained in Step 1 By applying a reversible perturbation, a set of reference image sequences is obtained through equation (2). , (2) in, For the first A type of invertible transformation function, The original multifocus image sequence is processed by the first... The reference image sequence obtained after a reversible transformation function The total number of reversible perturbations that can be applied; Step 4: Combine the reference image sequence set obtained in Step 3 Inputting into the multi-focus depth estimation model, the corresponding depth estimation set is obtained through equation (3). , (3) in, for Depth estimation obtained from the model; Step 5: Apply the depth estimates obtained in Step 4 to the set of depth estimates. By applying the inverse function of the perturbation in equation (4), the reference depth estimation set can be obtained. , (4) in, It is an invertible transformation function inverse function, For the first Reference depth estimation; Step 6: Use the depth estimate obtained in Step 2 and the reference depth estimate obtained in step 5 Construct the auxiliary loss function using equation (5) ; (5) Step 7: Use the auxiliary loss function obtained in Step 6 via decoder Perform backpropagation and calculate the auxiliary loss function using equation (6). decoder The gradient of the specified feature representation, , (6) in, Indicates the first in the decoder layer layer, For the first Layer feature representation, For loss function Regarding feature representation The partial derivative of the loss function with respect to the feature representation; Step 8: Apply the gradient obtained in Step 7 Max pooling is performed on the channel dimension using equation (7) to... The number of channels from Reduce to 1, (7) in, This represents the max pooling operation, which is defined as follows: ; Step 9: The results obtained in Step 8 Upsampling and normalization are performed using equation (8) to match the spatial resolution with the depth map, ultimately yielding the uncertainty score. , (8) in, This represents the upsampling operation, which is defined as follows: , and These are the maximum and minimum values of the gradient map, respectively.
