An optical lens coating defect detection method and system

By identifying optical lens coating defects through multi-scale median fusion and adaptive LBP eigenvalues, the problems of false detection and missed detection in the detection of highly reflective coating surfaces are solved, and high-precision defect detection is achieved.

CN121190558BActive Publication Date: 2026-04-07HONGCHENG OPTICAL PROD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-14
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing methods for detecting defects in optical lens coatings are prone to false positives and false negatives on highly reflective coated surfaces due to mirror reflection and uneven lighting, making it difficult to accurately identify minute defects and exhibiting poor robustness.

Method used

Multi-scale median fusion is used to estimate the defect-free background gray value of each pixel, calculate the local deviation and local abnormal fluctuation level, generate an illumination invariance threshold, improve LBP feature value, adaptively identify abnormal regions, and combine morphological operations for defect detection.

Benefits of technology

It effectively distinguishes between real defects and light interference, improves the robustness and sensitivity of detection, and significantly reduces the false detection rate and false negative rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121190558B_ABST
    Figure CN121190558B_ABST
Patent Text Reader

Abstract

The application discloses a kind of optical lens coating defect detection method and system, it is related to image processing technical field, method includes: obtaining the image of coating surface under standard light source irradiation and pre-processing, obtain the coordinates and gray value of each pixel point on gray scale chart;Based on the coordinates and gray value of all pixel points, the defect-free background gray estimation value and local deviation of each pixel point on gray scale chart are calculated;Based on the local deviation of pixel point, the local abnormal fluctuation level of each pixel point neighborhood is calculated, and the illumination invariance threshold of each pixel point is generated;Based on illumination invariance threshold, improve and calculate the LBP characteristic value of each pixel point;Based on the LBP characteristic value of pixel point determines adaptive abnormal threshold, and based on adaptive abnormal threshold, abnormal region is identified, and the position and area of defect are obtained.The application can solve the problem that defect feature is difficult to accurately extract on high-reflective coating surface, and realize accurate identification of coating defect.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to an optical lens coating defect detection method and system. BACKGROUND

[0002] Optical lens coating is a key process to improve the performance of optical systems, and the coating quality directly determines the imaging accuracy, durability and reliability of the final product. However, in the coating process, various surface defects such as bubbles, cracks, scratches and pinholes are inevitable, which will significantly affect the imaging quality, light transmittance and service life of the optical system, leading to problems such as image blurring, increased glare and decreased contrast. In high-end optical systems such as lasers, space remote sensing and precision medical equipment, even micron-level defects such as pinholes, scratches or uneven film layers may cause light energy loss and increased scattering, or even cause local thermal damage under high-power laser irradiation, resulting in damage to the optical system of the equipment. Therefore, high-precision and high-reliability defect detection of optical lens coating is a key link to ensure the quality of optical elements, and is of great significance to improve the market competitiveness and user satisfaction of optical products.

[0003] Currently, optical lens coating defect detection mainly relies on manual inspection and automatic optical detection technology based on traditional image processing. Manual inspection is inefficient, subjective and prone to fatigue, and cannot meet the needs of modern large-scale and high-precision production. Existing optical automatic detection technology mostly uses fixed threshold segmentation, edge detection or simple texture analysis methods. These existing detection methods have significant shortcomings when facing high-reflective coating surfaces. Especially for coatings made of materials such as magnesium fluoride and silicon dioxide, which have strong mirror reflection characteristics, the existing detection methods are prone to uneven illumination and local highlight areas in the image during defect detection due to the reflection of the coating surface, affecting the accuracy of defect detection.

[0004] When facing high-reflective coating surfaces, the commonly used illumination method of existing detection methods will produce strong mirror highlights on the lens curve and edge light attenuation, forming a large range of smooth gray gradient, which is easily misjudged as a defect, resulting in high false detection rate. At the same time, in the high light area, the gray scale change caused by a small real defect such as a pinhole may be overwhelmed by the strong light, leading to missed detection. Moreover, the existing detection methods usually lack the ability to adapt to local illumination and material reflection characteristics. Real defects can cause a sudden change in reflectivity, and uneven illumination can cause a smooth change in light intensity. The existing detection methods cannot distinguish the gray scale difference caused by the two, and have poor robustness. SUMMARY

[0005] In order to exclude the interference of uneven illumination, realize accurate identification of coating defects, solve the problem that the high-reflective coating surface is difficult to accurately extract defect features, leading to missed detection of small defects and misalignment of defect detection, the application provides a kind of optical lens coating defect detection method and system, its technical scheme is as follows:

[0006] In the first aspect, the application provides an optical lens coating defect detection method, which comprises the following steps: obtaining the image of the optical lens coating surface under standard light source irradiation and preprocessing to obtain the coordinates and gray values of each pixel point on the coating surface gray scale diagram;Based on the coordinates and gray values of all pixel points, the non-defect background gray estimation value of each pixel point on the gray scale diagram is calculated;Based on the gray value and non-defect background gray estimation value of the pixel point, the local deviation degree of each pixel point is calculated;Based on the local deviation degree of the pixel point, the local abnormal fluctuation level of the neighborhood of each pixel point is calculated, and the illumination invariance threshold of each pixel point is generated;Based on the illumination invariance threshold, the LBP feature value of each pixel point is improved and calculated;Based on the LBP feature value of the pixel point, the adaptive abnormal threshold is determined, and the abnormal area is identified based on the adaptive abnormal threshold to obtain the position and area of the defect.

[0007] Preferably, the high dynamic range industrial camera is used to collect images of the coating surface of the optical lens under the irradiation of the constant temperature dust-free workshop and the standard light source, the optical lens is placed horizontally, the irradiation angle of the light source system matches the curvature of the optical lens, the lens of the industrial camera is arranged directly above the optical lens, and the vertical angle is used to shoot downward to obtain the image of the coating surface of the optical lens;The bilateral filtering algorithm is used to eliminate the high-frequency noise of the optical lens coating surface image, and the histogram specification processing is performed on the denoised image to obtain the gray scale diagram of the coating surface, and the gray scale diagram information is extracted to obtain the coordinates and gray values of each pixel point on the gray scale diagram.

[0008] Preferably, a plurality of window sizes with odd values are set, based on the coordinates of the pixel points, the pixel points on the gray scale diagram are sequentially taken as the center to divide the window area of each pixel point on the gray scale diagram under different window sizes, for the pixel points in the edge area of the gray scale diagram, the mean value of the gray values of the pixel points in the window area is taken as the inserted value, and the missing values of the pixel points in the edge area of the gray scale diagram in the window area are filled;Based on a certain window size, the gray values of each pixel point in the window area on the gray scale diagram are sequentially extracted, and the median values of the gray value sets in the window area corresponding to each pixel point on the gray scale diagram are sequentially calculated, and the median values of the gray value sets in the window area corresponding to each pixel point under different window sizes are obtained in the same way;The average value of the median values of the gray values of a certain pixel point under all window sizes is taken as the non-defect background gray estimation value of the pixel point, and the non-defect background gray estimation value of each pixel point on the gray scale diagram is obtained in the same way.

[0009] Preferably, the gray value of each pixel point on the gray scale image and the non-defect background gray estimation value are extracted, and the absolute value of the difference between the gray value of a certain pixel point and the non-defect background gray estimation value is taken as the local deviation degree of the pixel point. Similarly, the local deviation degree of each pixel point on the gray scale image is obtained.

[0010] Preferably, based on a certain window size, the local deviation degrees of each pixel point in the window region corresponding to the pixel point under the window size are extracted, and the median of the local deviation degree set in the window region corresponding to a certain pixel point is taken as the neighborhood typical abnormality degree of the pixel point. Similarly, the neighborhood typical abnormality degree of each pixel point under the window size is obtained. Based on the neighborhood typical abnormality degree of a certain pixel point, the absolute values of the difference between the local deviation degrees of each pixel point in the window region corresponding to the pixel point and the neighborhood typical abnormality degree of the pixel point are sequentially calculated, and the median of the absolute value set in the window region corresponding to the pixel point is taken as the local abnormal fluctuation level of the pixel point. Similarly, the local abnormal fluctuation level of each pixel point on the gray scale image is obtained.

[0011] Preferably, based on the scaling coefficient set according to the statistical law, the product of the local abnormal fluctuation level of a certain pixel point on the gray scale image and the scaling coefficient is taken as the illumination invariance threshold value of the pixel point. Similarly, the illumination invariance threshold value of each pixel point on the gray scale image is obtained.

[0012] Preferably, based on the illumination invariance threshold value of a certain pixel point on the gray scale image, the difference between the gray value of the other pixel points in the 8-neighborhood of the pixel point and the gray value of the pixel point is sequentially calculated in the order of the orientation of the distribution of the other pixel points in the 8-neighborhood of the pixel point, and the difference is compared with the illumination invariance threshold value of the pixel point. The pixel points with a difference greater than or equal to the illumination invariance threshold value are marked as 1, and the pixel points with a difference less than the illumination invariance threshold value are marked as 0. The other pixel points in the 8-neighborhood of the pixel point are sequentially converted into 0 and 1 and combined into an 8-bit binary data. The decimal data converted from the 8-bit binary data is taken as the LBP feature value of the pixel point. Similarly, the LBP feature value of each pixel point on the gray scale image is obtained.

[0013] Preferably, based on the LBP feature value of each pixel point on the gray scale image, an LBP global histogram is constructed, the number of pixel points corresponding to each LBP feature value is counted, and based on the detection accuracy requirement and detection experience of the actual application scene, an abnormal boundary value is set. After sorting all LBP feature values in ascending order, the value of the LBP feature value is sequentially taken as a judgment threshold value, the number of pixel points with an LBP feature value less than or equal to the judgment threshold value is counted and taken as a normal region statistical value, the corresponding judgment threshold value when the normal region statistical value is greater than or equal to the abnormal boundary value is extracted, and the LBP feature value corresponding to the smallest judgment threshold value is selected as an adaptive abnormal threshold value.

[0014] Preferably, based on the adaptive abnormal threshold, the pixel points with the LBP feature value greater than the adaptive abnormal threshold on the gray image are regarded as abnormal points and marked as 1, and the pixel points with the LBP feature value less than or equal to the adaptive abnormal threshold on the gray image are regarded as normal points and marked as 0, to obtain a corresponding candidate defect binary image; morphological closing operation is performed on the candidate defect binary image, and a plurality of abnormal regions are obtained by connecting the abnormal points adjacent to each other on the candidate defect binary image; a noise threshold is set based on the detection accuracy requirement and detection experience of the actual application scene, and the abnormal regions with an area less than the noise threshold on the candidate defect binary image are removed, so as to filter the isolated noise spots on the candidate defect binary image; the processed defect mask is superimposed on the gray image, and the position and area of the defect are output, and the defect detection is completed.

[0015] In a second aspect, the present application provides an optical lens coating defect detection system for implementing the optical lens coating defect detection method, comprising a processor, a memory, a communication interface, a light source system, a lens placing table and an image acquisition device, the processor stores computer program instructions for implementing the optical lens coating defect detection method, the light source system is a ring-shaped LED lamp panel with adjustable brightness and illumination angle and capable of emitting standard light source, the lens placing table is located directly below the center of the light source system, the image acquisition device is an industrial camera and is arranged directly above the lens placing table, and the communication interface is in communication connection with the image acquisition device.

[0016] Compared with the prior art, the present application has the following advantages:

[0017] The present application accurately estimates the expected background gray level of each pixel point in the defect-free state by multi-scale median fusion, effectively separates the reflectivity mutation caused by real defects from the smooth gray change caused by uneven illumination, and fundamentally improves the ability to distinguish defects from interference on the high-reflective coating surface; at the same time, based on the illumination invariance threshold dynamically generated by the local deviation degree and the local abnormal fluctuation level, the discrimination standard can be adaptively adjusted according to the illumination intensity and background complexity of the local area, the false positives are suppressed in high-light areas, the detection ability of weak defects is enhanced in dark areas, and the robustness and sensitivity of the detection are significantly improved. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 The present application provides an embodiment of an optical lens coating defect detection method for an implementation flowchart;

[0019] Figure 2 The present application provides an embodiment of an optical lens coating defect detection system for a structure block diagram. DETAILED DESCRIPTION

[0020] The technical features of the present invention will be further described in detail below with reference to the accompanying drawings so that those skilled in the art can understand them.

[0021] A method for detecting defects in optical lens coatings, the implementation process is as follows: Figure 1 As shown, the specific implementation steps are as follows:

[0022] Step S1: Acquire an image of the coated surface of the optical lens under standard light source illumination and perform preprocessing to obtain the coordinates and grayscale value of each pixel on the grayscale image of the coated surface.

[0023] Specifically, a high dynamic range industrial camera is used to capture images of the coated surface of an optical lens in a constant temperature and cleanroom under standard light source illumination. The optical lens is placed horizontally, and the illumination angle of the light source system matches the curvature of the optical lens. The lens of the industrial camera is positioned directly above the optical lens, and the image is taken vertically downwards to obtain an image of the coated surface of the optical lens. A bilateral filtering algorithm is used to eliminate high-frequency noise in the image of the coated surface of the optical lens, and histogram specification processing is performed on the denoised image to obtain a grayscale image of the coated surface. The grayscale image information is extracted to obtain the coordinates and grayscale value of each pixel in the grayscale image.

[0024] The light source system adopts a ring shape. The array's emission angle is matched to the curvature of the optical lenses to ensure uniform illumination on the coated surface and to make the light angle as perpendicular as possible to the coated surface. The standard light source intensity is within the range of 5000 lux ± 200 lux, and the color temperature is maintained within the range of 5500K ± 200K. An industrial camera equipped with 12... The depth sensor's industrial camera acquires images in a temperature-controlled, dust-free workshop to eliminate ambient light interference.

[0025] Step S2: Based on the coordinates and grayscale values ​​of all pixels, calculate the defect-free background grayscale estimate of each pixel in the grayscale image.

[0026] On highly reflective coated surfaces, image grayscale values ​​are determined by both local illumination intensity and surface reflectivity. Real defects manifest as abrupt changes in local reflectivity; for example, pinhole defects cause a sharp decrease in the reflectivity of the coated surface in that area, resulting in an image grayscale value in that area being much lower than its surrounding areas. Conversely, uneven illumination, such as specular highlights or edge attenuation caused by a ring light source, manifests as smooth changes in local illumination intensity. The Local-Binary-Pattern (Local Binary Pattern) algorithm uses a fixed threshold to compare the grayscale values ​​between pixels, failing to distinguish between these two differences. This leads to missed detection of minute defects in highlight areas and false detection of noise in areas of gradual illumination change. Therefore, to eliminate the interference of local illumination intensity variations and distinguish and identify true defects, it is necessary to assume that the pixel has no defects, and its grayscale value is determined solely by the combined effects of local illumination and material reflectivity. This results in the grayscale value of the pixel in its defect-free state, i.e., the grayscale estimate of the defect-free background. The grayscale estimate of the defect-free background will serve as the core benchmark for subsequently constructing the illumination invariance threshold, enabling... The algorithm can identify grayscale differences that exceed the normal fluctuation range, thereby accurately locating the real defects.

[0027] Specifically, multiple window sizes with odd values ​​are set. The selection of window size and number can be adjusted according to the size of the optical lens and the image resolution in the actual application scenario. Preferably, in this embodiment of the invention, the window size can be selected from four values: 3, 5, 7, and 9, i.e., setting four window regions: 3×3, 5×5, 7×7, and 9×9. Based on the coordinates of the pixels, the grayscale image is divided into window regions for each pixel under different window sizes, centered on the pixels on the grayscale image. For pixels in the edge regions of the grayscale image, the mean interpolation method is used to interpolate the pixels in the window region. The average grayscale value of each pixel is used as the interpolation value to fill the missing values ​​of pixels in the edge region of the grayscale image within the window region. Based on a certain window size, the grayscale value of each pixel in the grayscale image within the window region is extracted sequentially, and the median of the set of grayscale values ​​in the window region corresponding to each pixel in the grayscale image is calculated sequentially. Similarly, the median of the set of grayscale values ​​in the window region corresponding to each pixel under different window sizes is obtained. The average of the median grayscale values ​​of a certain pixel under all window sizes is used as the defect-free background grayscale estimate of that pixel. Similarly, the defect-free background grayscale estimate of each pixel in the grayscale image is obtained.

[0028] Wherein, the defect-free background grayscale estimate of the i-th pixel is The calculation formula is as follows:

[0029]

[0030]

[0031] In the formula, This represents the median of the set of grayscale values ​​within the window region corresponding to the i-th pixel under the s-th window size, where S represents the number of different window sizes. In the embodiment of this invention, S is 4. Let represent the set of other pixels within the window region corresponding to the i-th pixel under the s-th window size. This represents the grayscale value of the j-th other pixel within the window region corresponding to the i-th pixel. This represents the median function.

[0032] The defect-free background grayscale estimate is a physical quantity calculated through multi-scale median filtering, rather than a value obtained through direct measurement. Calculating the defect-free background grayscale estimate for each pixel is to accurately estimate the grayscale value that the corresponding pixel should have when there are no defects. Its value directly reflects the normal brightness level at that location; high values ​​correspond to strong light or high-reflectivity coating materials, such as silicon dioxide, while low values ​​correspond to weak light or low-reflectivity coating materials, such as magnesium fluoride. This invention employs four different sizes of odd-numbered square windows, and calculates the defect-free background grayscale estimate of the pixel by fusing the median values ​​of the four windows. This is because defect detection on highly reflective coating surfaces faces two core challenges: First... The first challenge is that the defect itself is a sparse local anomaly, and the second challenge is uneven illumination, which manifests as a smooth gradient over a large area. Traditional neighborhood mean values ​​are easily affected by defects, and single-scale median values ​​cannot simultaneously take into account fine structure and global trends, while Gaussian filtering and other methods tend to blur the edges of highlights. Therefore, this invention utilizes the robustness of median filtering to outliers by taking median values ​​at multiple scales and averaging them. It captures microscopic details, balances the scene, and captures macroscopic illumination trends through windows of different scales. It tolerates fluctuations in bright areas and enhances sensitivity in dark areas, ultimately serving the subsequent LBP feature calculation to accurately distinguish between grayscale anomalies caused by real defects and grayscale fluctuations caused by simple changes in illumination.

[0033] Step S3: Calculate the local deviation of each pixel based on the gray value of the pixel and the gray value estimate of the defect-free background.

[0034] Local deviation is the absolute difference between the original gray value and the gray value estimate of the defect-free background, reflecting the degree of abnormality of a pixel. In defect-free areas, the original gray value of a pixel is close to the gray value estimate of the defect-free background, so the local deviation is mainly composed of sensor noise and minor illumination interference, and its value is small and its distribution is stable. In areas with defects, due to the sudden change in reflectivity, the original gray value of the pixel deviates significantly from the corresponding gray value estimate of the defect-free background, so the value of the local deviation will increase significantly.

[0035] Specifically, the gray value of each pixel in the grayscale image and the estimated gray value of the defect-free background are extracted. The absolute value of the difference between the gray value of a certain pixel and the estimated gray value of the defect-free background is taken as the local deviation of that pixel. Similarly, the local deviation of each pixel in the grayscale image is obtained.

[0036] Wherein, the local deviation of the i-th pixel is The calculation formula is as follows:

[0037]

[0038] In the formula, This represents the grayscale value of the i-th pixel. This represents the estimated grayscale value of the defect-free background at the i-th pixel.

[0039] Step S4: Based on the local deviation of the pixel, calculate the local abnormal fluctuation level of the neighborhood of each pixel and generate the illumination invariance threshold for each pixel.

[0040] Since the value of local deviation alone cannot determine whether an anomaly is significant, because the normal grayscale value of the highlight area fluctuates greatly, it is necessary to further calculate the local anomaly fluctuation level of the pixel within a window area of ​​a certain window size, that is, the median absolute deviation of the local deviation, which is a robust statistic that is not sensitive to sparse anomalies.

[0041] Specifically, based on a set window size, the local deviation of each pixel within the window region corresponding to each pixel under that window size is extracted. Preferably, in this embodiment of the invention, the selected window size is 7, and the corresponding window region size is 7×7. The median of the set of local deviations within the window region corresponding to a pixel is taken as the neighborhood typical anomaly of that pixel. Similarly, the neighborhood typical anomaly of each pixel under that window size is obtained. Based on the neighborhood typical anomaly of a pixel, the absolute value of the difference between the local deviation of each pixel within the window region corresponding to that pixel and the neighborhood typical anomaly of that pixel is calculated sequentially. The median of the set of absolute values ​​within the window region corresponding to that pixel is taken as the local anomaly fluctuation level of that pixel. Similarly, the local anomaly fluctuation level of each pixel on the grayscale image is obtained.

[0042] Wherein, the local anomaly fluctuation level of the i-th pixel is The calculation formula is as follows:

[0043]

[0044]

[0045] In the formula, This represents the set of other pixels within the 7×7 window region at the i-th pixel when the window size is 7. Represents the median function. This represents the local deviation of the j-th other pixel within the window region corresponding to the i-th pixel. It represents the neighborhood typical anomaly of the i-th pixel, which is the median of the set of local deviations of other pixels within the window region corresponding to the i-th pixel.

[0046] Calculating the local anomaly fluctuation level is to dynamically measure the range of normal deviation of pixels within a window area, thus providing an adaptive benchmark for defect judgment. Two median calculations are used: first, the median of the local deviation of other pixels within the window area is calculated, and then the median of their absolute deviation is calculated. This ensures a robust estimate of the undisturbed normal fluctuation level even in the presence of sparse anomalies (such as defects or highlights). The magnitude of the local anomaly fluctuation level directly reflects the acceptable grayscale variation range of the local area. A larger value indicates more drastic fluctuations in the lighting background, making the area more likely to be a highlight; a smaller value indicates a more stable lighting background, making the area more likely to be a dark area. The representation of the local anomaly fluctuation level is based on the statistical characteristic that the median is insensitive to outliers, accurately reflecting the normal fluctuation range of most pixels. By utilizing the characteristics of the local anomaly fluctuation level, it avoids misjudging normal lighting gradients as defects in highlight areas and maintains sensitivity to subtle anomalies in dark areas, effectively solving the problem of distinguishing between defects and lighting interference on highly reflective coating surfaces.

[0047] Furthermore, the purpose of calculating the illumination invariance threshold is to dynamically set a tolerable upper limit for normal fluctuations for each pixel, thereby setting a dynamic judgment standard for each pixel to distinguish between real defects and grayscale fluctuation interference caused by illumination changes. The size of the illumination invariance threshold changes dynamically with the local illumination background, being smaller in areas with stable illumination to improve sensitivity to weak defects, and larger in areas with highlights or gradients to effectively suppress false alarms.

[0048] The specific calculation process is as follows: Based on statistical laws, a scaling factor is set, and the product of the local abnormal fluctuation level of a certain pixel on the grayscale image and the scaling factor is used as the illumination invariance threshold of that pixel. Similarly, the illumination invariance threshold of each pixel on the grayscale image is obtained.

[0049] Wherein, the illumination invariance threshold of the i-th pixel is The calculation formula is as follows:

[0050]

[0051] In the formula, The value of d represents the local abnormal fluctuation level of the i-th pixel, and d represents the scaling factor; preferably, based on statistical regularity, the value of d in this embodiment of the invention is 3.

[0052] Since most normal fluctuations do not exceed three times their typical fluctuation range, changes that significantly exceed this range can be considered abnormal. Therefore, based on statistical laws, the scaling factor can be set to 3. The value of the illumination invariance threshold represents the maximum tolerable normal grayscale difference in the current local area, thus enabling the setting of a dynamic judgment standard for each pixel. This avoids misjudging smooth brightness changes as defects in bright areas, while not affecting the identification of weak abnormal signals captured in dark areas. This effectively solves the problem of both missed and false detections in the detection of defects on highly reflective coating surfaces.

[0053] Step S5: Based on the illumination invariance threshold, improve and calculate the LBP feature value of each pixel.

[0054] Embedding the illumination invariance threshold of pixels into the local texture encoding process of the LBP algorithm can improve upon the traditional LBP algorithm. Traditional LBP algorithms use a fixed threshold, typically 0, to compare the gray values ​​of neighboring pixels with the gray value of the center pixel, making them highly susceptible to illumination effects. This invention replaces the comparison benchmark with the illumination invariance threshold of each pixel: only when the gray value difference between a neighboring pixel and the center pixel exceeds the illumination invariance threshold corresponding to the center pixel is it considered a structural change and included in the encoding. In this case, gray value differences caused by smooth illumination changes are effectively filtered out, while abrupt changes in reflectivity caused by real defects, such as pinholes or scratches, are retained and encoded as high response values. The resulting LBP feature map not only retains the structural information of the local texture but also possesses strong robustness against illumination interference, laying the foundation for subsequent defect identification.

[0055] Specifically, based on the illumination invariance threshold of a pixel in the grayscale image, taking that pixel as the center, and following the orientational order of other pixels within its 8-neighborhood, the difference between the grayscale value of the pixel and the grayscale value of the other pixels within its 8-neighborhood is calculated sequentially. This difference is then compared with the illumination invariance threshold of the pixel. Pixels with a difference greater than or equal to the illumination invariance threshold are marked as 1, and pixels with a difference less than the illumination invariance threshold are marked as 0. The other pixels within its 8-neighborhood are then converted into 0s and 1s and combined into an 8-bit binary data. The decimal data converted from this 8-bit binary data is used as the LBP feature value of the pixel. Similarly, the LBP feature value of each pixel in the grayscale image is obtained.

[0056] Step S6: Determine the adaptive anomaly threshold based on the LBP feature value of the pixel, and identify the abnormal region based on the adaptive anomaly threshold to obtain the location and area of ​​the defect.

[0057] Specifically, based on the LBP feature value of each pixel in the grayscale image, a global LBP histogram is constructed, and the number of pixels corresponding to each LBP feature value is counted. An abnormal boundary value is set based on the detection accuracy requirements and detection experience of the actual application scenario. Preferably, in this embodiment of the invention, the abnormal boundary value is set to 0.995, that is, 99.5% of the pixels in the grayscale image are considered normal, and the remaining 0.5% of the pixels are considered abnormal. After sorting all LBP feature values ​​in ascending order, the LBP feature values ​​are used as judgment thresholds. The number of pixels whose LBP feature values ​​are less than or equal to the judgment thresholds is counted and used as the normal region statistics. The judgment thresholds corresponding to the normal region statistics being greater than or equal to the abnormal boundary value are extracted, and the LBP feature value corresponding to the smallest judgment threshold is selected as the adaptive abnormal threshold.

[0058] The range of LBP eigenvalues ​​is as follows: The LBP global histogram is divided into 256 levels, and its expression is: , The LBP eigenvalues ​​are represented as follows: The number of pixels is such that, since the normal region is dominant, the LBP global histogram shows a significant peak in the low value range, while the number of pixels in the high value range is very small, which is consistent with the characteristics of many normal samples and few defective samples.

[0059] For obtaining the adaptive anomaly threshold, this embodiment of the invention uses a cumulative distribution function to automatically determine the adaptive anomaly threshold, and the calculation process is as follows:

[0060]

[0061] In the formula, This indicates the currently selected judgment threshold. This represents the statistical value of the normal region when the judgment threshold is R. Specifically, it represents the number of pixels in the grayscale image whose LBP feature values ​​are less than or equal to the judgment threshold when the judgment threshold is R. The LBP eigenvalues ​​are represented as follows: The number of pixels; then, taking values ​​for R in ascending order of LBP feature values, finding the smallest R such that M represents the total number of pixels in the grayscale image; the LBP feature value corresponding to the finally found R is used as the adaptive anomaly threshold.

[0062] Furthermore, based on an adaptive anomaly threshold, pixels with LBP feature values ​​greater than the adaptive anomaly threshold in the grayscale image are designated as anomalies and marked as 1, while pixels with LBP feature values ​​less than or equal to the adaptive anomaly threshold are designated as normal pixels and marked as 0, thus obtaining corresponding candidate defect binary images. Morphological closing operations are performed on the candidate defect binary images, using 3×3 structuring elements to connect adjacent anomalies in the candidate defect binary images to obtain several anomaly regions. Based on the detection accuracy requirements and detection experience of the actual application scenario, a noise threshold is set to remove anomaly regions in the candidate defect binary images with areas smaller than the noise threshold, thereby filtering isolated noise spots in the candidate defect binary images. Preferably, in this embodiment of the invention, the noise threshold is set to 5, i.e., filtering out anomaly regions with areas smaller than 5 pixels. The processed defect mask is then superimposed on the grayscale image, and the position and area of ​​the defect are output, completing the defect detection.

[0063] The assignment expression for the candidate defect binary map is as follows:

[0064]

[0065] In the formula, This represents the value assigned to the i-th pixel in the binary image of the candidate defect. Let R represent the LBP feature value of the i-th pixel, and let R represent the adaptive anomaly threshold.

[0066] This invention also discloses an optical lens coating defect detection system for implementing the aforementioned optical lens coating defect detection method. The system structure is as follows: Figure 2 As shown, it includes: a processor, a memory, a communication interface, a light source system, a lens placement stage, and an image acquisition device; the processor stores computer program instructions for implementing the aforementioned method for detecting defects in optical lens coatings; the light source system is an adjustable ring-shaped LED light panel with adjustable brightness and illumination angle, capable of illuminating a standard light source; the lens placement stage is located directly below the center of the light source system, used to fix the optical lens and keep it in a horizontal position; the image acquisition device is an industrial camera located directly above the lens placement stage, taking images vertically downwards to acquire images of the coated surface of the optical lens; the communication interface is connected to the image acquisition device.

[0067] The embodiments included in this invention are merely descriptions of preferred embodiments of the invention and are not limited to the precise structures described above and shown in the accompanying drawings. Various modifications and changes can be made without departing from the scope of protection. Any variations and improvements made by those skilled in the art to the technical solutions of this invention without departing from the design concept of this invention should fall within the scope of protection of this invention.

Claims

1. A method for detecting defects in optical lens coatings, characterized in that: The image of the coated surface of the optical lens under standard light source illumination is acquired and preprocessed to obtain the coordinates and gray values ​​of each pixel in the grayscale image of the coated surface. Based on the coordinates and gray values ​​of all pixels, the grayscale estimate of the defect-free background of each pixel in the grayscale image is calculated. Based on the gray values ​​of the pixels and the grayscale estimate of the defect-free background, the local deviation of each pixel is calculated. Based on the local deviation of the pixels, the local abnormal fluctuation level of the neighborhood of each pixel is calculated, and the illumination invariance threshold of each pixel is generated. Based on the illumination invariance threshold, the LBP feature value of each pixel is improved and calculated. An adaptive anomaly threshold is determined based on the LBP feature value of each pixel, and anomaly regions are identified based on the adaptive anomaly threshold to obtain the location and area of ​​the defect. Among them, based on the coordinates and gray values ​​of each pixel, the multi-scale median filtering method is used to calculate the gray value of the defect-free background of each pixel on the gray map, so as to accurately estimate the gray value that each pixel should have when there is no defect. Based on the illumination invariance threshold of a pixel in the grayscale image, taking that pixel as the center, and following the orientational order of other pixels within its 8-neighborhood, the difference between the grayscale value of the pixel and the grayscale value of the other pixels within its 8-neighborhood is calculated sequentially. This difference is then compared with the illumination invariance threshold of the pixel. Pixels with a difference greater than or equal to the illumination invariance threshold are marked as 1, and pixels with a difference less than the illumination invariance threshold are marked as 0. The other pixels within its 8-neighborhood are then converted into 0s and 1s and combined into an 8-bit binary data. The decimal data converted from this 8-bit binary data is used as the LBP feature value of the pixel. Similarly, the LBP feature value of each pixel in the grayscale image is obtained.

2. The method for detecting defects in optical lens coatings according to claim 1, characterized in that, The process of acquiring and preprocessing an image of the coated surface of an optical lens under standard light source illumination to obtain the coordinates and grayscale value of each pixel on the grayscale image of the coated surface includes: using a high dynamic range industrial camera in a constant temperature and dust-free workshop under standard light source illumination to acquire an image of the coated surface of the optical lens; placing the optical lens horizontally; matching the illumination angle of the light source system with the curvature of the optical lens; setting the lens of the industrial camera directly above the optical lens; and shooting downwards at a vertical angle to obtain an image of the coated surface of the optical lens; using a bilateral filtering algorithm to eliminate high-frequency noise in the image of the coated surface of the optical lens; and performing histogram specification processing on the denoised image to obtain a grayscale image of the coated surface; and extracting grayscale image information to obtain the coordinates and grayscale value of each pixel on the grayscale image.

3. The method for detecting defects in optical lens coatings according to claim 1, characterized in that, The step of calculating the defect-free background grayscale estimate of each pixel in the grayscale image based on the coordinates and grayscale values ​​of all pixels includes using a multi-scale median filtering method to sequentially obtain the defect-free background grayscale estimate of each pixel. The calculation process is as follows: multiple window sizes with odd values ​​are set. Based on the coordinates of the pixels, the grayscale image is divided into window regions for each pixel under different window sizes, with the pixels as the center. For pixels in the edge region of the grayscale image, the mean interpolation method is used to fill the missing values ​​of the pixels in the edge region of the grayscale image in the window region with the average grayscale value of each pixel in the window region as the interpolation value. Based on a certain window size, the grayscale values ​​in the window region of each pixel in the grayscale image are extracted sequentially, and the median of the grayscale value set in the window region corresponding to each pixel in the grayscale image is calculated sequentially. Similarly, the median of the grayscale value set in the window region corresponding to each pixel under different window sizes is obtained. The average value of the grayscale values ​​of a pixel across all window sizes is used as the defect-free background grayscale estimate for that pixel. Similarly, the defect-free background grayscale estimate for each pixel in the grayscale image is obtained.

4. The method for detecting defects in optical lens coatings according to claim 1, characterized in that, The calculation of the local deviation of each pixel based on the gray value of the pixel and the gray value estimate of the defect-free background includes: extracting the gray value of each pixel in the grayscale image and the gray value estimate of the defect-free background, taking the absolute value of the difference between the gray value of a certain pixel and the gray value estimate of the defect-free background as the local deviation of that pixel, and similarly obtaining the local deviation of each pixel in the grayscale image.

5. The method for detecting defects in optical lens coatings according to claim 3, characterized in that, The calculation of the local anomaly fluctuation level of the neighborhood of each pixel based on the local deviation of the pixel includes: extracting the local deviation of each pixel within the window area corresponding to each pixel under a set window size, taking the median of the set of local deviations within the window area corresponding to a pixel as the typical anomaly of the neighborhood of that pixel, and similarly obtaining the typical anomaly of the neighborhood of each pixel under the window size; based on the typical anomaly of the neighborhood of a pixel, calculating the absolute value of the difference between the local deviation of each pixel within the window area corresponding to that pixel and the typical anomaly of the neighborhood of that pixel, taking the median of the set of absolute values ​​within the window area corresponding to that pixel as the local anomaly fluctuation level of that pixel, and similarly obtaining the local anomaly fluctuation level of each pixel on the grayscale image.

6. The method for detecting defects in optical lens coatings according to claim 5, characterized in that, The process of generating the illumination invariance threshold for each pixel includes: setting a scaling factor based on statistical laws, and using the product of the local abnormal fluctuation level of a pixel on the grayscale image and the scaling factor as the illumination invariance threshold for that pixel; similarly, the illumination invariance threshold for each pixel on the grayscale image is obtained.

7. The method for detecting defects in optical lens coatings according to claim 1, characterized in that, The method for determining the adaptive anomaly threshold based on pixel-level LBP feature values ​​includes: constructing a global LBP histogram based on the LBP feature values ​​of each pixel in the grayscale image; counting the number of pixels corresponding to each LBP feature value; setting anomaly boundary values ​​based on the detection accuracy requirements and detection experience of the actual application scenario; sorting all LBP feature values ​​in ascending order and using each LBP feature value as a judgment threshold; counting the number of pixels whose LBP feature values ​​are less than or equal to the judgment threshold and using them as normal region statistics; extracting the judgment thresholds corresponding to normal region statistics that are greater than or equal to the anomaly boundary values; and selecting the LBP feature value corresponding to the smallest judgment threshold as the adaptive anomaly threshold.

8. The method for detecting defects in optical lens coatings according to claim 7, characterized in that, The method of identifying abnormal regions based on adaptive anomaly thresholds to obtain the location and area of ​​defects includes: based on an adaptive anomaly threshold, pixels with LBP feature values ​​greater than the adaptive anomaly threshold in the grayscale image are identified as anomalies and marked as 1, while pixels with LBP feature values ​​less than or equal to the adaptive anomaly threshold in the grayscale image are identified as normal points and marked as 0, thus obtaining corresponding candidate defect binary images; performing morphological closing operations on the candidate defect binary images to connect mutually adjacent anomalies in the candidate defect binary images to obtain several anomaly regions; setting a noise threshold based on the detection accuracy requirements of the actual application scenario and detection experience to remove anomaly regions in the candidate defect binary images whose areas are smaller than the noise threshold, thereby filtering isolated noise spots in the candidate defect binary images; superimposing the processed defect mask onto the grayscale image and outputting the location and area of ​​the defect to complete defect detection.

9. A system for detecting defects in optical lens coatings, characterized in that: The device includes a processor, a memory, a communication interface, a light source system, a lens placement stage, and an image acquisition device. The processor stores computer program instructions for implementing the optical lens coating defect detection method according to any one of claims 1 to 8. The light source system is an adjustable ring-shaped LED light panel capable of illuminating a standard light source. The lens placement stage is located directly below the center of the light source system. The image acquisition device is an industrial camera and is positioned directly above the lens placement stage. The communication interface is communicatively connected to the image acquisition device.

Citation Information

Patent Citations

  • Sheet metal part quality detection method

    CN116777907A

  • Plastic mold surface defect analysis and detection method based on image processing

    CN116934740A