Narrow space imaging autofocus method and system based on depth of field analysis
Through the depth of field analysis method, image data is acquired and corrected, and the focus position is identified and optimized, which solves the problem of inaccurate focal length locking in narrow space imaging, and achieves high-precision imaging.
Patent Information
- Application Number
- CN202510606207.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-05-12
AI Technical Summary
Existing imaging technologies are difficult to quickly and accurately lock the focal length in tight spaces and complex physiological environments, especially in endoscopic applications where light scattering and media interference lead to a degradation of imaging quality.
Through a depth of field analysis method, the original image data is obtained for refraction correction, scattering interference is identified, candidate focus is screened, exposure is optimized, lock threshold is calculated, and scattering compensation is performed to output high-precision imaging results.
It improves the autofocus accuracy of narrow space imaging, ensures high-quality imaging results in complex environments, and enhances the system's anti-interference ability and response speed.
Smart Images

Figure CN120128798B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of autofocus technology, and in particular to a method and system for autofocusing imaging in a narrow space based on depth of field analysis. Background Art
[0002] Currently, the application of imaging technology in the medical field is crucial, especially accurate imaging in confined spaces, which is directly related to the accuracy of diagnosis and the effectiveness of treatment. With the development of endoscopic technology, achieving high-quality image acquisition in complex physiological environments has become a key driving force for the advancement of medical imaging. Especially in special scenarios such as the water environment of the uterine cavity, imaging systems must overcome spatial limitations and media interference to ensure image clarity and diagnostic reliability, which places extremely high demands on technological innovation.
[0003] In existing technologies, a common method for adjusting the focus position is to measure the distance between the target and the lens. The specific steps include: first, using ultrasound or infrared technology to measure the distance; then, calculating the optimal focal length based on the measurement results; and finally, driving the lens to move to the calculated position to achieve focus.
[0004] Existing technologies often rely on static scene assumptions or simple distance measurements, making it difficult to adapt to the dynamically changing physiological environment and the light scattering problems caused by aqueous media. In endoscopy applications, the light source and camera are both located inside the probe. When the probe enters the human body cavity, the surrounding tissue will produce irregular reflections and absorption effects, resulting in an abnormal increase in brightness in the local area (i.e., glare). At this time, if a focusing algorithm based on simple distance measurement is used, the focus will deviate from the actual target location, thereby affecting the imaging quality. In addition, the presence of aqueous media further exacerbates this problem because it introduces additional light scattering and absorption, making the already complex optical path even more unpredictable. Therefore, existing methods are unable to quickly lock the focus at the optimal imaging position under these specific conditions, resulting in low autofocus accuracy. Summary of the Invention
[0005] The present invention provides a method and system for automatic focusing of imaging in a narrow space based on depth of field analysis, so as to improve the accuracy of automatic focusing of imaging in a narrow space.
[0006] In a first aspect, in order to solve the above technical problems, the present invention provides a method for auto-focusing imaging in a narrow space based on depth of field analysis, comprising:
[0007] Acquiring original image data, and performing refraction correction based on the original image data to obtain an initial depth of field distribution map;
[0008] Performing scattering interference analysis based on the initial depth of field distribution map to obtain interference intensity distribution;
[0009] Performing focus analysis according to the interference intensity distribution to obtain a candidate focus set;
[0010] Performing exposure optimization according to the candidate focus set to obtain an optimized focus set;
[0011] Calculating a locking threshold value based on the optimized focus set to obtain a locking threshold value for an optimal imaging position;
[0012] When the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, and scattering compensation is performed to output a high-precision imaging result.
[0013] In an optional embodiment, the acquiring of original image data and performing refraction correction according to the original image data to obtain an initial depth of field distribution map includes:
[0014] Get original image data;
[0015] Performing phase difference calculation based on the original image data and a preset sensor array to obtain image visual difference;
[0016] The initial depth of field value is calculated using the following formula:
[0017] ;
[0018] in, represents the initial depth of field value, represents the focal length, represents the baseline value, represents the visual difference of the image, Indicates the conversion factor;
[0019] Refraction correction is performed according to the initial depth of field value to obtain an initial depth of field distribution map.
[0020] In an optional embodiment, performing scattering interference analysis according to the initial depth of field distribution map to obtain interference intensity distribution includes:
[0021] Performing image segmentation according to the initial depth of field distribution map to obtain an image foreground and an image background;
[0022] Performing boundary detection based on the image foreground and the image background to obtain a light scattering boundary;
[0023] Performing region growing according to the light scattering boundary to obtain a light scattering region;
[0024] Calculating interference intensity according to the light scattering area to obtain scattering interference intensity;
[0025] Smoothing filtering is performed according to the scattered interference intensity to obtain interference intensity distribution.
[0026] In an optional implementation, performing focus analysis according to the interference intensity distribution to obtain a candidate focus set includes:
[0027] Performing regional segmentation according to the interference intensity distribution to obtain local regions with different scattering intensities;
[0028] Performing correlation analysis based on the clarity and depth of field parameters of the local area to obtain regional correlation;
[0029] When the region correlation is greater than or equal to a preset correlation threshold, determining that the local region is a valid region;
[0030] When the region correlation is less than the correlation threshold, determining that the local region is invalid;
[0031] Generate focus according to the effective area to obtain an original focus set;
[0032] Performing structural similarity calculation based on the original focus set and a pre-stored target clarity template to obtain focus structure similarity;
[0033] Eliminate non-candidate points based on the focus structure similarity to obtain a valid focus set;
[0034] Redundant points are eliminated according to the effective focus set to obtain a candidate focus set.
[0035] In an optional implementation, performing exposure optimization according to the candidate focus set to obtain an optimized focus set includes:
[0036] Performing region segmentation on the original image data according to the candidate focus set to obtain a first local region;
[0037] Performing glare detection according to the first local area to obtain a local glare area;
[0038] Performing brightness gradient calculation on the local glare area to obtain gradient distribution data;
[0039] Performing smoothing filtering on the local glare area according to the gradient distribution data to obtain a brightness adjustment parameter;
[0040] A set optimization is performed according to the brightness adjustment parameters to obtain an optimized focus set.
[0041] In an optional embodiment, the performing the locking threshold calculation according to the optimized focus set to obtain the locking threshold of the optimal imaging position includes:
[0042] Calculating the depth of field range and image clarity of each focus area according to the optimized focus set;
[0043] Performing weighted summation according to the depth of field range and the image clarity to obtain a balance coefficient;
[0044] When the balance coefficient is greater than a preset coefficient threshold, determining that the focus area is a candidate area for optimal imaging;
[0045] Calculating the geometric center of the candidate area as the optimal imaging position;
[0046] The minimum distance from the optimal imaging position to the boundary is calculated as a locking threshold of the optimal imaging position.
[0047] In an optional embodiment, when the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, scattering compensation is performed, and a high-precision imaging result is output, including:
[0048] Get the current frame image;
[0049] Performing a fast Fourier transform on the current frame image to obtain image frequency domain features;
[0050] Extracting the proportion of high-frequency components according to the frequency domain features of the image;
[0051] When the proportion of the high-frequency component is lower than a preset ratio threshold, the clarity of the current frame image is optimized to obtain an optimized image;
[0052] Inputting the optimized image into a pre-trained scattering compensation model to output a high-precision imaging result;
[0053] The training process of the scattering compensation model includes:
[0054] The scatter compensation model is trained based on a deep learning model, with the input layer being historical underwater images and the output layer being scatter compensation images. When it is detected that the number of training times reaches a preset upper limit or the mean square error of the image is higher than a preset target value, the trained model is obtained.
[0055] In a second aspect, the present invention provides a narrow space imaging autofocus system based on depth of field analysis, comprising:
[0056] A data acquisition module is used to acquire original image data and perform refraction correction based on the original image data to obtain an initial depth of field distribution map;
[0057] a scattering interference module, configured to perform scattering interference analysis based on the initial depth of field distribution map to obtain an interference intensity distribution;
[0058] A candidate focus module, configured to perform focus analysis based on the interference intensity distribution to obtain a candidate focus set;
[0059] an exposure optimization module, configured to perform exposure optimization based on the candidate focus set to obtain an optimized focus set;
[0060] A locking threshold module, configured to calculate a locking threshold based on the optimized focus set to obtain a locking threshold for an optimal imaging position;
[0061] The result output module is used to trigger focus locking when the distance between the target position and the optimal imaging position is less than the locking threshold, perform scattering compensation, and output high-precision imaging results.
[0062] In a third aspect, the present invention also provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for automatically focusing narrow space imaging based on depth of field analysis as described above is implemented.
[0063] In a fourth aspect, the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned methods for automatic focusing of narrow space imaging based on depth of field analysis.
[0064] Compared with the prior art, the present invention has the following beneficial effects:
[0065] (1) Obtaining raw image data and performing refraction correction on the raw image data to obtain an initial depth of field distribution map. The raw image data is captured by a high-precision sensor, and advanced refraction correction algorithms are used to remove imaging errors caused by medium inhomogeneity or surface reflection. This process significantly improves the accuracy of depth of field information, provides a reliable data foundation for subsequent steps, and ensures imaging quality.
[0066] (2) Perform scattering interference analysis based on the initial depth of field distribution map to obtain an interference intensity distribution. Use professional image processing technology to quantitatively analyze the scattering interference in the initial depth of field distribution map, identify and evaluate the interference intensity in different areas. This step helps to accurately identify factors that affect imaging clarity, provides an important basis for further optimizing the focus position, and improves the system's anti-interference ability.
[0067] (3) Performing focus analysis based on the interference intensity distribution to obtain a candidate focus set. Based on the results of the interference intensity distribution, the system can intelligently screen multiple potential optimal focus positions to form a candidate focus set. This method not only considers imaging quality but also takes into account feasibility and stability in actual operation, ensuring high-quality imaging results even in complex environments.
[0068] (4) Performing exposure optimization based on the candidate focus set to obtain an optimized focus set. By optimizing and adjusting the exposure parameters of each candidate focus, the system can further improve the imaging quality. This step uses an intelligent algorithm to calculate the optimal exposure settings so that each candidate focus can achieve the best imaging effect, thereby forming an optimized focus set and improving the stability and consistency of imaging.
[0069] (5) Calculating the lock threshold based on the optimized focus set to obtain the lock threshold for the optimal imaging position. Combined with the information from the optimized focus set, the system can calculate a reasonable lock threshold to determine whether the target is in the optimal imaging position. This multi-focus analysis-based method ensures the scientific and rationality of the lock threshold and enhances the system's response speed and positioning accuracy.
[0070] (6) When the distance between the target position and the optimal imaging position is less than the locking threshold, the focus lock is triggered, and scattering compensation is performed to output a high-precision imaging result. In the last step, the system monitors the changes in the target position in real time. Once the target is found to be close to or at the optimal imaging position, the focus lock mechanism is immediately triggered and the existing scattering interference is compensated. This not only allows the focus to be locked quickly and stably, but also effectively eliminates various interference factors in the imaging process, and ultimately outputs high-precision, high-definition imaging results to meet the needs of professional-level applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 This is a flowchart of a method for automatically focusing imaging in a narrow space based on depth of field analysis provided by the first embodiment of the present invention;
[0072] Figure 2 1 is a schematic structural diagram of a narrow space imaging autofocus system based on depth of field analysis provided by the second embodiment of the present invention. DETAILED DESCRIPTION
[0073] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0074] Reference Figure 1 A first embodiment of the present invention provides a method for automatically focusing imaging in a narrow space based on depth of field analysis, comprising the following steps:
[0075] S11, acquiring original image data, and performing refraction correction according to the original image data to obtain an initial depth of field distribution map;
[0076] S12, performing scattering interference analysis based on the initial depth of field distribution map to obtain interference intensity distribution;
[0077] S13, performing focus analysis according to the interference intensity distribution to obtain a candidate focus set;
[0078] S14, performing exposure optimization according to the candidate focus set to obtain an optimized focus set;
[0079] S15, calculating a locking threshold according to the optimized focus set to obtain a locking threshold of an optimal imaging position;
[0080] S16, when the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, scattering compensation is performed, and a high-precision imaging result is output.
[0081] In step S11 , original image data is acquired, and refraction correction is performed based on the original image data to obtain an initial depth of field distribution map.
[0082] In one embodiment, obtaining original image data;
[0083] Performing phase difference calculation based on the original image data and a preset sensor array to obtain image visual difference;
[0084] The initial depth of field value is calculated using the following formula:
[0085] ;
[0086] in, represents the initial depth of field value, represents the focal length, represents the baseline value, represents the visual difference of the image, Indicates the conversion factor;
[0087] Refraction correction is performed according to the initial depth of field value to obtain an initial depth of field distribution map.
[0088] In one embodiment, raw image data is acquired through the endoscope's optical lens and sensor assembly. A camera (equipped with a CMOS or CCD sensor) at the front end of the endoscope, assisted by a light source (such as an LED or fiber optic light guide), captures images of the target tissue at multiple focal points or in successive focal planes. The physical position or focal length parameters of the lens must be simultaneously recorded during this process. The image data is transmitted in real time to a processing unit via the endoscope's signal transmission channel (such as an optical fiber or digital interface). Refraction correction is then performed—a correction algorithm eliminates refractive distortion and lens aberrations in the optical path, ultimately generating an initial depth-of-field distribution map containing multi-layer depth-of-field information. The raw image data is stored in a lossless compression format (such as TIFF or PNG) or a standard medical imaging format (such as DICOM) to preserve high-resolution details and metadata (such as acquisition time and device parameters), ensuring accuracy and traceability for subsequent processing. Specifically, the raw image data acquired by the endoscope is stored in RGB format with a resolution of 1920×1080 pixels and a frame rate of 30 fps.
[0089] In one embodiment, phase difference data of the scene is acquired through a preset 4×4 optical sensor array (with a spacing of 5 mm between each sensor), and the visual difference is calculated using the SGM (semi-global matching) algorithm, where the cost aggregation window size is set to 9×9 pixels, and the penalty coefficients P1=50 and P2=200.
[0090] It's worth noting that the initial depth of field (DFO) value, representing the depth range within which the target object remains in focus within the imaging system, reflects the system's initial quantitative estimate of the depth of field and is measured in millimeters. The focal length of an optical system refers to the distance from the optical center of the lens to the imaging plane (e.g., the sensor) and is measured in millimeters. A larger focal length indicates a shallower depth of field. The baseline value, representing the physical distance between two imaging devices (e.g., the two lenses of a binocular endoscope) and measured in millimeters, is a fundamental parameter used to calculate depth information in stereo vision. The image parallax, representing the horizontal displacement of corresponding pixels between two images of the same object from different perspectives (e.g., left and right lenses), is dimensionless and measured in pixels. A larger parallax indicates a closer object to the imaging system. This formula, leveraging the relationship between focal length, baseline, and parallax, combines the principles of geometric optics with the stereo vision model to quantify the initial DFO value, providing a mathematical foundation for the subsequent generation of a depth distribution map. A conversion coefficient of 0.1 mm / pixel is used to convert pixels to physical distance units.
[0091] In one implementation, refraction correction is performed by first constructing a mathematical model based on the law of light refraction to address the refraction interference caused by the aqueous medium. An iterative optimization algorithm (LM algorithm, with a maximum number of iterations set to 100 and a convergence threshold of 0.001) is then used to accurately correct the offset caused by refraction. Subsequently, bicubic interpolation is used to increase the resolution of the initial depth distribution map to 3840×2160, while preserving depth details using 16-bit depth quantization. Simultaneously, noise reduction is implemented during the calculation process: the raw depth data is smoothed using a 3×3 Gaussian filter (standard deviation = 5), ensuring that the edge preservation rate of the filtered image exceeds 90%, ultimately generating a highly accurate initial depth distribution map.
[0092] In one embodiment, when performing water medium refraction correction, the specific process is as follows: First, a geometric correction model is constructed based on Snell's refraction law, and the angle between the incident light and the normal is established. (air medium) and refraction angle The relationship between (water medium) / sin = / ,in =1.0 is the refractive index of vacuum, Taking the refractive index of water as 1.33, the light path of each pixel in the original depth data is parameterized as a refraction path in a three-dimensional coordinate system. Subsequently, the refraction offset error function E=Σ(Δx_i²+Δy_i²) is defined, where Δx_i and Δy_i are the refraction offsets of the i-th pixel in the xy plane. Nonlinear least squares optimization is performed using the Levenberg-Marquardt (LM) algorithm: the refractive index error parameter ε is initialized (the initial value is set to 0.01), and the current refractive index is calculated at each step during the iteration process. '= The theoretical offsets Δx_i' and Δy_i' corresponding to (1+ε) are calculated, and the residual E'=Σ(Δx_i-Δx_i')²+Σ(Δy_i-Δy_i')² is calculated. The parameter ε is updated using the Jacobian matrix until the number of iterations reaches 100 or the residual decreases by less than 0.001%. The corrected depth data is super-reconstructed using bicubic interpolation. The Catmull-Rom spline interpolation kernel function is used to isotropically upscale the original depth map to a resolution of 3840×2160, while preserving depth gradients at the 0.0001mm level using 16-bit floating-point precision. Noise suppression is implemented simultaneously during the iterative optimization process: the original depth data is first subjected to a 3×3 Gaussian filter (σ=5 pixels), but edge regions are identified through edge detection preprocessing (the Canny operator threshold is set to 1.5 times the depth variance). Full filtering is performed on non-edge regions, and only directional smoothing is applied to edge regions (filtering in a direction perpendicular to the gradient, where the gradient direction is calculated by the Sobel operator) to ensure that the standard deviation of the intensity of edge pixels changes by ≤5%. The resulting depth map has been verified to have an edge preservation rate (calculated by Canny edge overlap) of over 92%, while the signal-to-noise ratio is improved by 3.2dB.
[0093] It is worth noting that the initial depth distribution map is a two-dimensional depth information map generated by processing the raw image data acquired through the endoscope through refraction correction, iterative optimization (such as offset correction using the LM algorithm), and noise suppression. The value of each pixel represents the estimated depth of field at the corresponding scene location. This map can reflect the sharpness distribution of the target object at different depths. This map is stored in a high-precision format, such as 16-bit depth quantized TIFF or PNG format (supporting lossless compression) or the medical imaging standard DICOM format, to preserve high-resolution details (such as 3840 × 2160 pixels) and complete metadata (such as acquisition parameters and correction information), while ensuring the accuracy and data traceability of subsequent processing (such as interpolation and filtering).
[0094] In step S12, scattering interference analysis is performed based on the initial depth of field distribution map to obtain interference intensity distribution.
[0095] In one embodiment, image segmentation is performed based on the initial depth of field distribution map to obtain an image foreground and an image background; boundary detection is performed based on the image foreground and the image background to obtain a light scattering boundary; region growth is performed based on the light scattering boundary to obtain a light scattering region; interference intensity is calculated based on the light scattering region to obtain a scattering interference intensity; and smoothing filtering is performed based on the scattering interference intensity to obtain an interference intensity distribution.
[0096] It's worth noting that the interference intensity distribution is a two-dimensional data matrix generated by analyzing the initial depth distribution map. Its spatial mapping corresponds exactly to the original image (e.g., 3840×2160 resolution). The interference intensity of each pixel or local area is quantified using a normalized value (ranging from 0 to 1), with higher values indicating more significant scattering interference. Its core components include: ① the spatial location of scattering regions identified through image segmentation and region growing algorithms, such as abnormally bright areas caused by reflections from blood or tissue fluid in medical endoscopes; ② quantitative metrics including depth gradient (indicating the degree of depth abrupt change), brightness difference (the difference between local and background grayscale), medium refractive index difference (the effect of optical path distortion), and noise level (the standard deviation of residual noise after Gaussian filtering), with the noise level being negatively correlated with interference intensity; and ③ a region area weighting mechanism: larger scattering regions contribute more to the overall interference intensity. By integrating these elements, this distribution map enables the spatial location, intensity quantification, and impact assessment of scattering interference in different scenarios. For example, in medical imaging, it can accurately label the interference level of blood accumulation areas, providing data support for subsequent correction.
[0097] It is worth noting that the specific process of image segmentation based on the initial depth distribution map is as follows: first, based on the depth value of each pixel in the depth distribution map (such as 16-bit quantized depth data), the segmentation threshold of the foreground and background is determined by analyzing the depth difference, for example, the depth threshold interval is determined by histogram analysis or an adaptive threshold algorithm (such as the Otsu method); secondly, a segmentation algorithm based on depth information (such as region growing, graph cut optimization or a deep learning model) is used to segment the depth map, and the area corresponding to the target object and whose depth value meets the foreground characteristics is marked as the image foreground, and the remaining area is classified as the image background; during the segmentation process, combined with the detailed features of the high-resolution depth map (3840×2160), the edge preservation characteristics (such as the edge retention rate after the previous Gaussian filter is greater than 90%) are simultaneously used to optimize the segmentation boundary to ensure that the boundary between the foreground and the background is clear and there is no obvious noise interference; finally, the segmentation result is output in the form of binarization or mask, the pixel areas of the foreground and background are extracted respectively, and the segmented image layer is saved in a format compatible with the original data (such as PNG or DICOM).
[0098] It is worth noting that the specific process of performing boundary detection based on the image foreground and image background is as follows: first, based on the depth information and grayscale image of the segmented foreground and background, the depth gradient and grayscale gradient at the junction of the two regions are calculated, and the edge preservation characteristics after Gaussian filtering (edge retention rate > 90%) are used to suppress noise interference; secondly, the Canny edge detection algorithm or the Sobel operator is used to extract the high-gradient area at the junction of the foreground and background, and combined with the depth mutation characteristics caused by light scattering in the depth distribution map (such as local depth outliers caused by refraction or scattering), the light scattering boundary is further located through adaptive threshold segmentation or morphological operations (such as opening and closing operations); finally, the detected boundary is aligned with the physical depth value of the original depth map, and the high-resolution (3840×2160) boundary positioning accuracy is ensured through bicubic interpolation, and the light scattering boundary contour is output in vector format or binary mask form, while retaining the depth quantization level (16bit) and metadata information to support subsequent processing.
[0099] It is worth noting that the process of region growing based on the light scattering boundary is as follows: first, the scattering profile obtained by boundary detection is used as the initial seed area, and the growth criteria (such as depth value similarity threshold, grayscale gradient or texture feature) are set. Then, pixels that meet the conditions in the boundary neighborhood (such as adjacent pixels with similar scattering characteristics or depth mutations in the depth distribution map) are gradually incorporated into the scattering area; the region range is expanded in an iterative manner until all qualified pixels are completely included or the preset termination conditions are reached (such as similarity threshold breakthrough, region area convergence); finally, a connected area consistent with the light scattering phenomenon is generated, while retaining high resolution (3840×2160) and depth quantization accuracy (16bit), and morphological operations (such as erosion and dilation) can be combined to optimize boundary smoothness.
[0100] It is worth noting that the scattering interference intensity is calculated using the following formula:
[0101] ;
[0102] in, represents the scattering interference intensity, Indicates the pixel number, represents the scattering area, Indicates the scattering area The depth gradient of pixels, Indicates the scattering area The difference between the average grayscale of the pixel and the background area, represents the refractive index of the medium, Indicates the physical depth value of the pixel to the lens. represents the pixel area of the scattering region, represents the standard deviation of the residual noise after Gaussian filtering.
[0103] It's worth noting that scattering interference intensity is a dimensionless metric used to describe the degree of scattering interference on imaging. Depth gradient, mean grayscale, and medium refractive index are dimensionless. Physical depth values are expressed in millimeters, while the pixel area of the scattering region is expressed in square millimeters. The residual noise standard deviation is dimensionless.
[0104] It is worth mentioning that This term characterizes the intensity of the deflection effect caused by the sudden change of the refractive index at the interface of the medium by quantifying the refractive index gradient within a unit distance. It reflects the degree of light path deflection at the interface between two media (such as tissue and body fluid), and (the physical depth from the pixel to the lens, in millimeters) is used as a distance parameter to normalize the spatial influence range of the gradient. =1.36 and tissue =1.33) and occurs at shallower depths ( When the refractive index changes per unit distance, will increase significantly, causing more intense light path deflection, thereby exacerbating scattering interference. On the contrary, if the interface is located deeper ( Large), the gradient effect of the same refractive index difference will be diluted and the interference intensity will be reduced. This item explicitly models the physical relationship between refractive index difference and depth, couples the local effect of light path deflection with imaging features such as depth of field gradient and grayscale difference, and provides a physical basis for the quantitative calculation of scattering interference intensity. For example, in medical endoscopes, the blood area ( ) and organization ( ) interface is close to the lens ( small), The larger the value of , the stronger the optical path distortion and scattering interference will be, which is consistent with the phenomenon that the interference in the shallow area is more significant in actual observations.
[0105] It is worth noting that the specific process for smoothing filtering based on scattered interference intensity is as follows: First, the calculated scattered interference intensity distribution map is used as input, and the image is spatially smoothed using a Gaussian filter. By adjusting the filter window size and parameters, local noise fluctuations are eliminated while preserving the large-scale interference intensity variation characteristics. Second, bilateral filtering is applied to edge regions within the image (such as near light scattering boundaries) to suppress noise while preserving edge details, ensuring edge clarity and continuity. Finally, the processed interference intensity distribution map is saved in a high-precision 16-bit depth format (such as TIFF or PNG). Histogram equalization and other methods are used to optimize the intensity contrast, making the differences in interference intensity between different regions more apparent. At the same time, the original image's high resolution (e.g., 3840 × 2160 pixels) and metadata are maintained, providing clear and stable intensity distribution data for subsequent interference correction.
[0106] In step S13, focus analysis is performed according to the interference intensity distribution to obtain a candidate focus set.
[0107] In one embodiment, region segmentation is performed according to the interference intensity distribution to obtain local regions with different scattering intensities;
[0108] Performing correlation analysis based on the clarity and depth of field parameters of the local area to obtain regional correlation;
[0109] When the region correlation is greater than or equal to a preset correlation threshold, determining that the local region is a valid region;
[0110] When the region correlation is less than the correlation threshold, determining that the local region is invalid;
[0111] Generate focus according to the effective area to obtain an original focus set;
[0112] Performing structural similarity calculation based on the original focus set and a pre-stored target clarity template to obtain focus structure similarity;
[0113] Eliminate non-candidate points based on the focus structure similarity to obtain a valid focus set;
[0114] Redundant points are eliminated according to the effective focus set to obtain a candidate focus set.
[0115] It is worth noting that when performing regional segmentation based on the interference intensity distribution, we first analyze the statistical characteristics of the intensity distribution map (such as histogram peaks or gradient changes) and set multi-level thresholds to divide the intensity range into several intervals; then, we use threshold segmentation or clustering algorithms (such as K-means) to divide the image into local areas corresponding to different scattering intensities to ensure that the interference intensity differences between adjacent areas are significant; finally, we perform morphological optimization on the segmentation results (such as denoising and connected domain analysis) to generate a clearly labeled intensity graded area map, which provides a basis for subsequent targeted corrections.
[0116] It is worth noting that when performing a correlation analysis based on the clarity and depth of field parameters of the local area, clarity metrics (such as image gradient energy and focus metric) and depth of field parameters (such as depth of field value or depth gradient) are first extracted for each area. The Spearman rank correlation coefficient is then used to assess the correlation between the two. The specific steps include assigning a numerical ranking (i.e., a sorted rank) to the clarity and depth of field data, calculating the sum of squares of the differences between the two groups of ranks, and substituting this into the Spearman formula to obtain the correlation coefficient (ranging from -1 to 1). An absolute value of the coefficient close to 1 indicates a strong monotonic correlation (positive or negative correlation) between the two, while a value close to 0 indicates no significant correlation. This method, without assuming the data distribution, can effectively reveal the dependency between clarity and depth of field parameters within a local area, providing a quantitative basis for subsequent corrections.
[0117] It is worth noting that the focus generation process is as follows: first, the golden section search method is used to optimize the focus adjustment step size. The initial search range is set to 0-1 mm, the accuracy is controlled at 0.5 mm, and the optimal focus position is gradually narrowed through iteration; in each iteration, the bicubic interpolation method (grid spacing 5 pixels) is used to reconstruct the virtual focal plane image, and the edge energy map (threshold 3) is generated through Sobel edge detection.
[0118] It is worth noting that the structural similarity index (SSIM) between the reconstructed image and the target clarity template is calculated, using an 8×8 pixel sliding window to assess local similarity. Next, non-maximum suppression (NMS, with a neighborhood radius of 3 pixels) and density-based clustering (DBSCAN, with a neighborhood threshold of ε = 2 mm and a minimum sample size of 5) are combined to generate and screen candidate focus locations, eliminating redundant points to form a streamlined focus set. For dynamic scenes, the Farneback optical flow algorithm (with 3 pyramid levels and a 20×20 pixel analysis window) is introduced to estimate target displacement in real time. By compensating for motion offset between consecutive frames, the temporal continuity and stability of the focus candidate positions are ensured. The entire process achieves high-precision focus positioning through a closed loop of optimization, reconstruction, evaluation, screening, and dynamic compensation.
[0119] It is worth noting that the screening process combining non-maximum suppression (NMS) and density clustering (DBSCAN) is as follows: first, NMS is used to eliminate local redundancy of candidate focus positions. Within the set 3-pixel neighborhood radius, only candidate points with the highest clarity score (such as SSIM value or gradient energy) are retained, and adjacent sub-optimal points are suppressed; then the screened candidate points are input into the DBSCAN algorithm, with 2mm (which needs to be converted into pixel distance according to image resolution) as the neighborhood threshold and 5 points as the minimum sample number to identify core clusters in high-density areas and eliminate isolated points or non-core points in small-scale clusters; finally, through the local suppression of NMS and the global density grouping of DBSCAN, redundant candidate points are removed, and a focus set that is evenly distributed and covers key areas is retained, which not only avoids excessive congestion in dense areas, but also ensures the sufficient existence of focus candidate points in key positions, providing an efficient and accurate focus position basis for subsequent processing.
[0120] In step S14, exposure optimization is performed based on the candidate focus set to obtain an optimized focus set.
[0121] In one embodiment, the original image data is segmented into regions according to the candidate focus set to obtain a first local region;
[0122] Performing glare detection according to the first local area to obtain a local glare area;
[0123] Performing brightness gradient calculation on the local glare area to obtain gradient distribution data;
[0124] Performing smoothing filtering on the local glare area according to the gradient distribution data to obtain a brightness adjustment parameter;
[0125] A set optimization is performed according to the brightness adjustment parameters to obtain an optimized focus set.
[0126] It is worth noting that the process of regional segmentation of the original image data based on the candidate focus set is as follows: First, the screened candidate focus positions are used as key reference points, and local areas centered on these focuses are delineated in the original image based on their spatial distribution and clarity weights. Specific methods include taking each candidate focus as the center of a circle, setting a fixed or adaptive neighborhood radius (such as based on depth of field parameters or clarity gradients), or associating adjacent high-definition areas with the focus position through connected domain analysis to form continuous local areas. In addition, combined with the depth of field distribution map and the interference intensity distribution, areas around the candidate focus with similar depth of field characteristics, high definition and low interference are classified as "first local areas" to prioritize retaining or optimizing the imaging quality of these areas. The segmentation process aims to divide the image into key sub-areas centered on the effective focus, providing a basis for targeted processing for subsequent focus optimization, detail enhancement or dynamic tracking.
[0127] It is worth noting that the specific method for glare detection based on the first local area is as follows: first, for the segmented first local area (such as a high-definition or key focus area), extract the highlight area in its brightness channel or RGB color space, and identify abnormally bright pixel clusters through histogram analysis or adaptive threshold segmentation (such as the Otsu method) and mark them as local glare areas, and generate corresponding binary masks for subsequent masking or correction processing.
[0128] It is worth noting that the specific process of calculating the brightness gradient of the local glare area is as follows: first, for the marked local glare area, the brightness gradient value (including gradient amplitude and direction) of each pixel is calculated by a gradient operator (such as Sobel or Scharr operator), and its distribution characteristics (such as the histogram of gradient amplitude and the spatial distribution of high gradient areas) are statistically analyzed; then, an adaptive smoothing strategy is designed based on the gradient distribution data: Gaussian filtering or bilateral filtering is used to attenuate the intensity in smooth areas with lower gradients (such as the highlight area in the center of the glare), while details are retained in edge areas with higher gradients (such as the glare outline) to avoid blurring key boundaries; by iteratively adjusting the filtering parameters (such as the filter window size and the intensity attenuation coefficient), the brightness adjustment parameters (such as the attenuation coefficient matrix) for different gradient areas are calculated; finally, the brightness adjustment parameters are combined with the original candidate focus set, and the weight or coordinate of the focus position is recalculated through an optimization algorithm (such as least squares fitting or weighted fusion) to eliminate the influence of brightness distortion caused by glare on focus positioning, and finally generate an optimized focus set that eliminates glare interference and has a more accurate distribution.
[0129] In step S15, a locking threshold is calculated based on the optimized focus set to obtain a locking threshold of the optimal imaging position.
[0130] In one embodiment, the depth of field range and image clarity of each focus area are calculated based on the optimized focus set;
[0131] Performing weighted summation according to the depth of field range and the image clarity to obtain a balance coefficient;
[0132] When the balance coefficient is greater than a preset coefficient threshold, determining that the focus area is a candidate area for optimal imaging;
[0133] Calculating the geometric center of the candidate area as the optimal imaging position;
[0134] The minimum distance from the optimal imaging position to the boundary is calculated as a locking threshold of the optimal imaging position.
[0135] It's worth noting that, first, for each focal area, the depth of field values of all pixels within that area are extracted using a depth distribution map. Statistical analysis is then used to determine the effective depth of field range for that area (i.e., the maximum depth range within which front-to-back clarity meets the required standards). Secondly, when evaluating image clarity, an edge detection algorithm (such as the Sobel operator) is used to calculate the gradient amplitude of pixels within the area. The Tenengrad function is used as a clarity metric to quantify the sharpness of local details. The Structural Similarity Index (SSIM) is then compared with a preset clarity template to generate a comprehensive clarity score.
[0136] It's worth noting that the detailed process according to the described steps is as follows: First, a weighted calculation is performed on the depth of field range (e.g., sharpness interval) and image sharpness (e.g., edge acuity or SSIM score) of each focus area. The two are weighted and summed according to preset weights (e.g., depth of field weight 0.6, sharpness weight 0.4) to obtain a comprehensive evaluation value—the balance coefficient. If this coefficient exceeds a preset threshold (e.g., 0.8), the area achieves a good balance between depth of field coverage and image sharpness and is identified as a candidate for optimal imaging. Next, the geometric center (e.g., the average of the pixel coordinates) of all candidate areas is calculated as the potential optimal imaging position. The minimum distance from this position to the image boundary (e.g., the shortest horizontal or vertical distance) is further evaluated. This distance is used as the "locking threshold"—used during subsequent focusing to ensure that the image position meets both sharpness and depth of field requirements while remaining away from image edges to avoid edge distortion or sensor blind spots. This process, through multi-dimensional quantitative evaluation and spatial constraints, ultimately determines a stable and highly accurate imaging area.
[0137] In step S16, when the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, scattering compensation is performed, and a high-precision imaging result is output.
[0138] In one embodiment, obtaining a current frame image;
[0139] Performing a fast Fourier transform on the current frame image to obtain image frequency domain features;
[0140] Extracting the proportion of high-frequency components according to the frequency domain features of the image;
[0141] When the proportion of the high-frequency component is lower than a preset ratio threshold, the clarity of the current frame image is optimized to obtain an optimized image;
[0142] Inputting the optimized image into a pre-trained scattering compensation model to output a high-precision imaging result;
[0143] The training process of the scattering compensation model includes:
[0144] The scatter compensation model is trained based on a deep learning model, with the input layer being historical underwater images and the output layer being scatter compensation images. When it is detected that the number of training times reaches a preset upper limit or the mean square error of the image is higher than a preset target value, the trained model is obtained.
[0145] It's worth noting that, first, the current frame image undergoes frequency domain analysis (e.g., through Fourier transform or wavelet transform) to extract and calculate the energy percentage of its high-frequency components (e.g., corresponding to image edges and texture details) in the overall spectrum. If the high-frequency component percentage falls below a preset threshold (e.g., 30%), this indicates image blur, insufficient detail, or low contrast. At this point, the system triggers a clarity optimization process to enhance image detail by enhancing high-frequency information (e.g., using the Unsharp Masking algorithm, high-pass filtering, or adaptive contrast enhancement) while suppressing noise interference, ultimately generating an optimized image. This process quantifies image clarity through frequency domain features and dynamically triggers targeted enhancements, ensuring that the output image maintains a natural look while enhancing detail visibility.
[0146] In one embodiment, the training process for a scatter compensation model based on a U-Net network is as follows: First, a training set of 5,000 annotated underwater images is used. The input is the original underwater image containing scattering interference, and the output is a scatter compensation image of an artificially restored or ideal scene (e.g., a clear target image generated using standard laboratory methods). The model adopts a U-Net architecture, including an encoder-decoder structure and cross-layer feature fusion (skip connections) to preserve spatial details and enhance feature representation. During training, the input image undergoes data augmentation (e.g., random cropping and rotation) and normalization before being fed into the network. Forward propagation generates the compensated image prediction result. The loss function uses the mean squared error (MSE), which measures the pixel-wise difference between the predicted image and the target image. Gradient backpropagation is performed using the Adam optimizer to update the network parameters. The training process continues iteratively and terminates when one of the following conditions is met: 1) a preset maximum number of training epochs is reached (e.g., 500 epochs); 2) the MSE on the validation set does not decrease for several consecutive epochs, or the current MSE falls below a preset target threshold (e.g., 0.01). The final converged model is the trained scattering compensation model, which can effectively learn the suppression law of underwater scattering and output a clear image after de-scattering.
[0147] In summary, the present invention discloses a method for auto-focusing in a narrow space based on depth of field analysis, which can improve the accuracy and focusing speed of auto-focusing in a narrow space.
[0148] Reference Figure 2 A second embodiment of the present invention provides a narrow space imaging autofocus system based on depth of field analysis, comprising:
[0149] A data acquisition module is used to acquire original image data and perform refraction correction based on the original image data to obtain an initial depth of field distribution map;
[0150] a scattering interference module, configured to perform scattering interference analysis based on the initial depth of field distribution map to obtain an interference intensity distribution;
[0151] A candidate focus module, configured to perform focus analysis based on the interference intensity distribution to obtain a candidate focus set;
[0152] an exposure optimization module, configured to perform exposure optimization based on the candidate focus set to obtain an optimized focus set;
[0153] A locking threshold module, configured to calculate a locking threshold based on the optimized focus set to obtain a locking threshold for an optimal imaging position;
[0154] The result output module is used to trigger focus locking when the distance between the target position and the optimal imaging position is less than the locking threshold, perform scattering compensation, and output high-precision imaging results.
[0155] It should be noted that the narrow space imaging autofocus system based on depth of field analysis provided in an embodiment of the present invention is used to execute all the process steps of the narrow space imaging autofocus method based on depth of field analysis in the above embodiment. The working principles and beneficial effects of the two correspond one to one, so they will not be repeated here.
[0156] An embodiment of the present invention further provides an electronic device. The electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a data acquisition program. When the processor executes the computer program, the steps in the above-mentioned embodiments of the method for automatically focusing in a narrow space imaging based on depth of field analysis are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, such as the data acquisition module.
[0157] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0158] The electronic device may be a computing device such as a desktop computer, notebook, PDA, or smart tablet. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will appreciate that the aforementioned components are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those described above, or a combination of certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, and the like.
[0159] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) 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, etc. The processor is the control center of the electronic device, connecting various parts of the entire electronic device using various interfaces and lines.
[0160] The memory can be used to store the computer programs and / or modules. The processor implements the various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and accessing the data stored in the memory. The memory may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated based on the use of the mobile phone (such as audio data, a phone book, etc.). Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0161] If the module / unit integrated into the electronic device 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, the present invention can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content of the computer-readable medium can be appropriately increased or decreased based on the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.
[0162] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art can understand and implement the present invention without inventive effort.
[0163] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for auto-focusing in a narrow space based on depth of field analysis, characterized in that: include: Acquiring original image data, and performing refraction correction based on the original image data to obtain an initial depth of field distribution map; Performing scattering interference analysis based on the initial depth of field distribution map to obtain interference intensity distribution; Performing focus analysis according to the interference intensity distribution to obtain a candidate focus set; Performing exposure optimization according to the candidate focus set to obtain an optimized focus set; Calculating a locking threshold value based on the optimized focus set to obtain a locking threshold value for an optimal imaging position; When the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, scattering compensation is performed, and a high-precision imaging result is output; The performing of scattering interference analysis according to the initial depth of field distribution map to obtain interference intensity distribution includes: Performing image segmentation according to the initial depth of field distribution map to obtain an image foreground and an image background; Performing boundary detection based on the image foreground and the image background to obtain a light scattering boundary; Performing region growing according to the light scattering boundary to obtain a light scattering region; Calculating interference intensity according to the light scattering area to obtain scattering interference intensity; Performing smoothing filtering according to the scattering interference intensity to obtain interference intensity distribution; The step of performing exposure optimization according to the candidate focus set to obtain an optimized focus set includes: Performing region segmentation on the original image data according to the candidate focus set to obtain a first local region; Performing glare detection according to the first local area to obtain a local glare area; Performing brightness gradient calculation on the local glare area to obtain gradient distribution data; Performing smoothing filtering on the local glare area according to the gradient distribution data to obtain a brightness adjustment parameter; A set optimization is performed according to the brightness adjustment parameters to obtain an optimized focus set.
2. The method for automatically focusing narrow space imaging based on depth of field analysis according to claim 1, characterized in that: The acquiring of original image data and performing refraction correction according to the original image data to obtain an initial depth of field distribution map includes: Get original image data; Performing phase difference calculation based on the original image data and a preset sensor array to obtain image visual difference; The initial depth of field value is calculated using the following formula: ; in, represents the initial depth of field value, represents the focal length, represents the baseline value, represents the visual difference of the image, Indicates the conversion factor; Refraction correction is performed according to the initial depth of field value to obtain an initial depth of field distribution map.
3. The method for automatically focusing narrow space imaging based on depth of field analysis according to claim 1, wherein: The performing focus analysis according to the interference intensity distribution to obtain a candidate focus set includes: Performing regional segmentation according to the interference intensity distribution to obtain local regions with different scattering intensities; Performing correlation analysis based on the clarity and depth of field parameters of the local area to obtain regional correlation; When the region correlation is greater than or equal to a preset correlation threshold, determining that the local region is a valid region; When the region correlation is less than the correlation threshold, determining that the local region is invalid; Generate focus according to the effective area to obtain an original focus set; Performing structural similarity calculation based on the original focus set and a pre-stored target clarity template to obtain focus structure similarity; Eliminate non-candidate points based on the focus structure similarity to obtain a valid focus set; Redundant points are eliminated according to the effective focus set to obtain a candidate focus set.
4. The method for automatically focusing narrow space imaging based on depth of field analysis according to claim 1, wherein: The calculating the locking threshold according to the optimized focus set to obtain the locking threshold of the optimal imaging position includes: Calculating the depth of field range and image clarity of each focus area according to the optimized focus set; Performing weighted summation according to the depth of field range and the image clarity to obtain a balance coefficient; When the balance coefficient is greater than a preset coefficient threshold, determining that the focus area is a candidate area for optimal imaging; Calculating the geometric center of the candidate area as the optimal imaging position; The minimum distance from the optimal imaging position to the boundary is calculated as a locking threshold of the optimal imaging position.
5. The method for automatically focusing narrow space imaging based on depth of field analysis according to claim 1, wherein: When the distance between the target position and the optimal imaging position is less than the locking threshold, focus locking is triggered, scattering compensation is performed, and a high-precision imaging result is output, including: Get the current frame image; Performing a fast Fourier transform on the current frame image to obtain image frequency domain features; Extracting the proportion of high-frequency components according to the frequency domain features of the image; When the proportion of the high-frequency component is lower than a preset ratio threshold, the clarity of the current frame image is optimized to obtain an optimized image; Inputting the optimized image into a pre-trained scattering compensation model to output a high-precision imaging result; The training process of the scattering compensation model includes: The scatter compensation model is trained based on a deep learning model, with the input layer being historical underwater images and the output layer being scatter compensation images. When it is detected that the number of training times reaches a preset upper limit or the mean square error of the image is higher than a preset target value, the trained model is obtained.
6. A narrow space imaging auto-focus system based on depth of field analysis, used to implement the narrow space imaging auto-focus method based on depth of field analysis according to any one of claims 1 to 5, characterized in that: include: A data acquisition module is used to acquire original image data and perform refraction correction based on the original image data to obtain an initial depth of field distribution map; a scattering interference module, configured to perform scattering interference analysis based on the initial depth of field distribution map to obtain an interference intensity distribution; A candidate focus module, configured to perform focus analysis based on the interference intensity distribution to obtain a candidate focus set; an exposure optimization module, configured to perform exposure optimization based on the candidate focus set to obtain an optimized focus set; A locking threshold module, configured to calculate a locking threshold based on the optimized focus set to obtain a locking threshold for an optimal imaging position; The result output module is used to trigger focus locking when the distance between the target position and the optimal imaging position is less than the locking threshold, perform scattering compensation, and output high-precision imaging results.
7. An electronic device, characterized in that: The invention comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for automatically focusing imaging in a narrow space based on depth of field analysis as described in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the narrow space imaging auto-focusing method based on depth of field analysis as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Endoscope objective optical system and imaging device
CN104246573A
Aberration correction method and optical device
CN110520779A