光场自动对焦数据集构建及图像离焦程度估计方法
Image Defocus Estimation by Learning from a Novel Light Field Autofocus Dataset
- 2026年 页码:1-13
收稿:2026-05-13,
修回:2026-07-17,
录用:2026-08-20,
网络首发:2026-08-20
DOI: 10.11834/jig.260267
移动端阅览

浏览全部资源
扫码关注微信
收稿:2026-05-13,
修回:2026-07-17,
录用:2026-08-20,
网络首发:2026-08-20,
移动端阅览
目的
2
自动对焦模型训练通常需要带有深度标注的多焦点数据,但真实场景中精准深度标注获取困难。针对该问题,本文提出一种基于Blender的光场重聚焦堆栈数据合成与标注方法,并在此基础上构建单帧图像离焦程度估计网络。
方法
2
首先利用Blender物理渲染与光场重聚焦生成多焦点堆栈数据,并同步获得对应的深度标注,构建包含深度信息的多焦点堆栈数据集。随后,针对单张散焦图像推断对焦步长时存在的镜头移动方向二义性问题,设计行进方向判别器,通过图像由外围到中心的深度变化趋势和散焦梯度估计弥散圆斜率符号,以判断镜头移动方向。在确定方向后,构建步长估计器,由单张焦点切片预测到目标聚焦索引所需的移动步长。同时,引入初始透镜对焦索引的轴向位置编码,增强模型对镜头对焦位置的感知能力。
结果
2
实验结果表明,在误差容忍度为±4片索引的条件下,本文方法的聚焦索引预测准确率达到96.8%,相比基线方法提高4.6%。在推理效率方面,本文方法无需遍历完整焦点堆栈,推理速度高于传统全栈遍历算法。
结论
2
本文所提出的光场自动对焦数据集构建及图像离焦程度估计方法,在数据合成与标注过程中避免了真实采集中机械标定误差和焦点呼吸效应的影响,缓解了自动对焦模型训练中精准深度标注不足的问题,并提升了聚焦索引预测的准确率与对焦控制的执行效率。
Objective
2
Autofocus aims to move the lens to an appropriate focal position so that the region of interest can be clearly imaged. In data-driven autofocus methods, a network is usually trained to predict the target focus position or lens movement from defocused images. However, such training requires focus stacks with reliable labels, while accurate depth or focus annotations are difficult to obtain in real imaging. Public datasets constructed from stereo disparity estimation or analytical defocus simulation may be affected by calibration errors, focus breathing, and the mismatch between simplified degradation models and the actual imaging process. In addition, single-image autofocus has an axial ambiguity problem. Similar defocus appearances may occur on both sides of the true focal plane, making it difficult to determine whether the lens should move forward or backward from a single defocused image. To address these problems, this paper proposes a light field autofocus dataset construction method and an image defocus estimation network for single-slice focus prediction.
Method
2
A synthetic light field autofocus dataset, named SLFAF, is constructed using Blender-based physical rendering and light field refocusing. The dataset contains 50 static virtual scenes, including indoor, outdoor, forest, lake, street, and architectural environments. For each scene, a 9×9 virtual camera array is used to render 81 sub-aperture images with a resolution of 1920×1920 pixels, while the corresponding camera intrinsic parameters, extrinsic parameters, and Z-channel depth maps are also recorded. The 2–100 m depth range is converted into disparity according to binocular geometry and divided into 50 focal levels for light-field refocusing and focus labeling. For each patch stack, the local ground-truth depth is calculated by averaging the 3×3 neighborhood around the patch center in the depth map, reducing the influence of single-pixel noise and geometric deviation. The averaged depth is mapped to the nearest focal depth level, and the corresponding level is used as the ground-truth focus index of the patch stack. Finally, 447 original focus stacks were obtained from the 50 scenes to construct the SLFAF dataset. Based on this dataset, a lightweight image defocus estimation network was designed. The network consists of two modules: a movement direction discriminator and a step estimator. The movement direction discriminator is used to reduce the axial ambiguity in single-image autofocus. It takes a 128×128 RGB image patch as input and first extracts edge-related information to suppress redundant background content. Then, the network compares the defocus and structural responses between peripheral and central image regions, implicitly estimating the sign of the circle-of-confusion slope. The output is a binary movement direction label, trained with cross-entropy loss. After the movement direction is determined, the step estimator predicts the absolute movement step from the current focus slice to the target focus index. This module is implemented as a lightweight convolutional regression network and trained with mean square error loss. Since the same defocus appearance may correspond to different initial lens positions, an axial positional encoding strategy, termed Lens-PE, is introduced. The initial focal index is normalized, broadcast to the same spatial size as the image patch, and concatenated with the RGB image as an additional input channel. In this way, the network can jointly use image defocus features and the initial lens position from the early feature extraction stage.
Result
2
Quantitative and qualitative experiments are conducted on the SLFAF dataset. Mean absolute error, root mean square error, and error-tolerance accuracy are used as evaluation metrics. Under the single-slice input setting, the proposed method achieves accuracies of 37.9%, 75.9%, 91.4%, and 96.8% when the prediction error is equal to 0, within 1, within 2, and within 4 focus indices, respectively. The corresponding MAE and RMSE are 1.21 and 2.98. Compared with the MobileNet-v2 baseline under the same single-image prediction setting, the proposed method improves the zero-error accuracy from 31.0% to 37.9% and the accuracy within four focus indices from 92.2% to 96.8%. The inference time of the proposed network is 63ms, which is much shorter than traditional full-stack traversal methods such as Gradient Laplacian and Intensity Variance, which require 814ms and 784ms, respectively, in the same experimental setting. Qualitative results show that the predicted focus slices are closer to the ground-truth focus indices and present clearer edge structures than the baseline results. Ablation experiments further verify the role of the proposed modules. When the movement direction discriminator is added to the base regression network, the MAE decreases from 2.74 to 1.89, showing that explicit direction discrimination is useful for reducing axial ambiguity. When the initial lens position is introduced by deep scalar concatenation, namely Lens-index, the MAE decreases to 1.53 and the accuracy within four focus indices reaches 92.4%. By contrast, the proposed Lens-PE strategy further reduces the MAE to 1.21 and improves the accuracy within four focus indices to 96.8%. These results indicate that early spatial fusion of the initial lens position is more effective than introducing the lens index only at the final regression stage.
Conclusion
2
The proposed method avoids the influence of mechanical calibration errors and focus-breathing effects during data synthesis and annotation, alleviates the shortage of accurately depth-annotated autofocus training data, and improves both focus index prediction accuracy and focus control efficiency.
Abuolaim A , Delbracio M , Kelly D , Brown M S and Milanfar P . 2021 . Learning to reduce defocus blur by realistically modeling dual-pixel data // Proceedings of the IEEE/CVF International Conference on Computer Vision . Montreal, QC, Canada : IEEE: 2289 - 2298 [ DOI: 10.1109/ICCV48922.2021.00229 http://dx.doi.org/10.1109/ICCV48922.2021.00229 ]
Birchfield S and Tomasi C . 2002 . A pixel dissimilarity measure that is insensitive to image sampling . IEEE Transactions on Pattern Analysis and Machine Intelligence , 20 ( 4 ): 401 - 406 [ DOI: 10.1109/34.677269 http://dx.doi.org/10.1109/34.677269 ]
Chen C Y , Hwang R C and Chen Y J . 2010 . A passive auto-focus camera control system . Applied Soft Computing , 10 ( 1 ): 296 - 303 [ DOI: 10.1016/j.asoc.2009.07.007 http://dx.doi.org/10.1016/j.asoc.2009.07.007 ]
Chlubna T , Milet T and Zemčík P . 2021 . Real-time per-pixel focusing method for light field rendering . Computational Visual Media , 7 ( 3 ): 319 - 333 [ DOI: 10.1007/s41095-021- 0205-0 http://dx.doi.org/10.1007/s41095-021-0205-0 ]
Choi M , Lee H and Lee H . 2023 . Exploring positional characteristics of dual-pixel data for camera autofocus // Proceedings of the IEEE/CVF International Conference on Computer Vision . Paris, France : IEEE: 13158 - 13168 [ DOI: 10.1109/ICCV51070.2023.01210 http://dx.doi.org/10.1109/ICCV51070.2023.01210 ]
Dai Y C , Zhang F Y , Pan L Y , Xiang M C and He M Y . 2022 . Dual-pixel imaging and applications: an overview . Journal of Image and Graphics , 27 ( 12 ): 3395 - 3414
戴玉超 , 章飞宇 , 潘利源 , 项末初 , 何明一 . 2022 . 全像素双核成像技术及应用研究综述 . 中国图象图形学报 , 27 ( 12 ): 3395 - 3414 [ DOI: 10.11834/jig.210984 http://dx.doi.org/10.11834/jig.210984 ]
Garg R , Wadhwa N , Ansari S and Barron J T . 2019 . Learning single camera depth estimation using dual-pixels // Proceedings of the IEEE/CVF International Conference on Computer Vision . Seoul, Korea : IEEE: 7628 - 7637 [ DOI: 10.1109/ICCV.2019. 00772 http://dx.doi.org/10.1109/ICCV.2019.00772 ]
Guo X , Nie R , Cao J , Zhou D and Qian W . 2018 . Fully convolutional network-based multifocus image fusion . Neural Computation , 30 ( 7 ): 1775 - 1800 [ DOI: 10.1162/neco_a_01098 http://dx.doi.org/10.1162/neco_a_01098 ]
Han J W , Kim J H , Lee H T and Ko S J . 2011 . A novel training based auto-focus for mobile-phone cameras . IEEE Transactions on Consumer Electronics , 57 ( 1 ): 232 - 238 [ DOI: 10.1109/TCE.20 11.5735507 http://dx.doi.org/10.1109/TCE.2011.5735507 ]
Heng H J , Ye H B , Zhou M and Huang R . 2021 . Coarse-to-fine multiscale defocus blur detection . Journal of Image and Graphics , 26 ( 3 ): 581 - 593
衡红军 , 叶何斌 , 周末 , 黄睿 . 2021 . 由粗到精的多尺度散焦模糊检测 . 中国图象图形学报 , 26 ( 3 ): 581 - 593 [ DOI: 10.11834/jig.200126 http://dx.doi.org/10.11834/jig.200126 ]
Herrmann C , Bowen R S , Wadhwa N , Garg R , He Q , Barron J T , et al . 2020 . Learning to autofocus // Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition . Seattle, WA, USA : IEEE: 2230 - 2239 [ DOI: 10.1109/CVPR42600.2020.00230 http://dx.doi.org/10.1109/CVPR42600.2020.00230 ]
Ho C J , Chan C C and Chen H . 2020 . Af-net: A convolutional neural network approach to phase detection autofocus . IEEE Transactions on Image Processing , 29 : 6386 - 6395 [ DOI: 10.1109/TIP.2019.2947349 http://dx.doi.org/10.1109/TIP.2019.2947349 ]
Krotkov E . 1988 . Focusing . International Journal of Computer Vision , 1 ( 3 ): 223 - 237 [ DOI: 10.1007/BF00127822 http://dx.doi.org/10.1007/BF00127822 ]
Lee S , Choi M , Lee N and Lee H . 2025 . Stable autofocus with focal consistency loss // 2025 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV) . Tucson, AZ, USA : IEEE: 640 - 649 [ DOI: 10.1109/WACV61041.2025.00072 http://dx.doi.org/10.1109/WACV61041.2025.00072 ]
Li W , Wang G , Hu X and Yang H . 2018 . Scene-adaptive image acquisition for focus stacking // Proceedings of the 25th IEEE International Conference on Image Processing (ICIP) . Athens : IEEE: 1887 - 1891 [ DOI: 10.1109/ICIP.2018.8451455 http://dx.doi.org/10.1109/ICIP.2018.8451455 ]
Liu Y , Chen X , Peng H and Wang Z . 2017 . Multi-focus image fusion with a deep convolutional neural network . Information Fusion , 36 : 191 - 207 [ DOI: 10.1016/j.inffus.2016.12.001 http://dx.doi.org/10.1016/j.inffus.2016.12.001 ]
Liu Y , Ou L , Fu Q , Amata H , Heidrich W and Peng Y . 2025 . Learned Binocular-Encoding Optics for RGBD Imaging Using Joint Stereo and Focus Cues // Proceedings of the IEEE/CVF Computer Vision and Pattern Recognition Conference . Nashville, TN, USA : IEEE: 15833 - 15842 [ DOI: 10.1109/CVPR52734.2025.01476 http://dx.doi.org/10.1109/CVPR52734.2025.01476 ]
Nimisha T M , Kumar Singh A and Rajagopalan A N . 2017 . Blur-invariant deep learning for blind-deblurring/ /Proceedings of the IEEE International Conference on Computer Vision: 4752 - 4760 [ DOI: 10.1109/ICCV.2017.509 http://dx.doi.org/10.1109/ICCV.2017.509 ]
Ray S . 2002 . Applied photographic optics. London, UK: Routledge [ DOI: 10.4324/9780080499253 http://dx.doi.org/10.4324/9780080499253 ]
Ren Z , Xu Z and Lam E Y . 2018 . Learning-based nonparametric autofocusing for digital holography . Optica , 5 ( 4 ): 337 - 344 [ DOI: 10.1364/OPTICA.5.000337 http://dx.doi.org/10.1364/OPTICA.5.000337 ]
Schuler C J , Hirsch M , Harmeling S and Schölkopf B . 2015 . Learning to deblur . IEEE Transactions on Pattern Analysis and Machine Intelligence , 38 ( 7 ): 1439 - 1451 [ DOI: 10.1109/TPAMI.2015. 2481418 http://dx.doi.org/10.1109/TPAMI.2015.2481418 ]
Stein F . 2004 . Efficient computation of optical flow using the census transform // Joint Pattern Recognition Symposium . Berlin, Heidelberg : Springer Berlin Heidelberg: 79 - 86 [ DOI: 10.1007/978-3-540-28649-3_10 http://dx.doi.org/10.1007/978-3-540-28649-3_10 ]
Szeliski R . 2022 . Computer vision: algorithms and applications. Cham, Switzerland: Springer Nature [ DOI: 10.1007/978-3- 030-34372-9 http://dx.doi.org/10.1007/978-3-030-34372-9 ]
Thelen A , Frey S , Hirsch S and Hering P . 2008 . Improvements in shape-from-focus for holographic reconstructions with regard to focus operators, neighborhood-size, and height value interpolation . IEEE Transactions on Image Processing , 18 ( 1 ): 151 - 157 [ DOI: 10.1109/TIP.2008.2007049 http://dx.doi.org/10.1109/TIP.2008.2007049 ]
Vaswani A , Shazeer N , Parmar N , Uszkoreit J , Jones L , Gomez A N , et al . 2017 . Attention is all you need . Advances in Neural Information Processing Systems , 30 : 5998 - 6008 [ DOI: 10.48550/ arXiv.1706.03762 http://dx.doi.org/10.48550/arXiv.1706.03762 ]
Wadhwa N , Garg R , Jacobs D E , Feldman B E , Kanazawa N , Carroll R , et al . 2018 . Synthetic depth-of-field with a single-camera mobile phone . ACM Transactions on Graphics (ToG) , 37 ( 4 ): 1 - 13 [ DOI: 10.1145/3197517.3201329 http://dx.doi.org/10.1145/3197517.3201329 ]
Wang C , Huang Q , Cheng M , Ma Z and Brady D J . 2021 . Deep learning for camera autofocus . IEEE Transactions on Computational Imaging , 7 : 258 - 271 [ DOI: 10.1109/TCI.2021.3059497 http://dx.doi.org/10.1109/TCI.2021.3059497 ]
Xu G , Wang X , Ding X and Yang X . 2023 . Iterative geometry encoding volume for stereo matching // Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition . Vancouver, BC, Canada : IEEE: 21919 - 21928 [ DOI: 10.48550/arXiv.2303.06615 http://dx.doi.org/10.48550/arXiv.2303.06615 ]
Zabih R and Woodfill J . 1994 . Non-parametric local transforms for computing visual correspondence // European Conference on Computer Vision . Berlin, Heidelberg : Springer Berlin Heidelberg: 151 - 158 [ DOI: 10.1007/BFb0028345 http://dx.doi.org/10.1007/BFb0028345 ]
Zhu S , Li C , Jiang Y , Wei L , Kan N , Zheng Z , et al . 2025 . Stabilizing and Accelerating Autofocus with Expert Trajectory Regularized Deep Reinforcement Learning // Proceedings of the IEEE/CVF Computer Vision and Pattern Recognition Conference . Nashville, TN, USA : IEEE: 26440 - 26450 [ DOI: 10.1109/CVPR52734.2025.02462 http://dx.doi.org/10.1109/CVPR52734.2025.02462 ]
相关作者
相关机构
京公网安备11010802024621