A method and system for detecting scratches on an optical lens surface

By using mesh generation and color shortest neighbor distance calculation methods, the problems of image blurring and noise interference in scratch detection of optical lens surfaces under coaxial light source illumination are solved, achieving high precision and reliability in scratch detection.

CN119379620BActive Publication Date: 2026-06-16HUBEI YUEQING OPTICAL INSTR CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUBEI YUEQING OPTICAL INSTR CO LTD
Filing Date
2024-10-10
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing technologies using coaxial light sources to illuminate and detect scratches on the surface of optical lenses suffer from problems such as image blurring, noise interference, and excessively high reflection contrast, leading to inaccurate scratch recognition.

Method used

By employing a grid partitioning algorithm and a colorimetric shortest neighbor distance calculation method, the grayscale value of the scratch and the colorimetric shortest neighbor distance are calculated by acquiring the lens grayscale image, thus filtering out the real scratch area and suppressing the influence of random noise.

🎯Benefits of technology

It improves the accuracy and reliability of scratch detection, ensuring that the true grayscale value of the scratch area is accurately reflected, and avoids noise interference and misjudgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119379620B_ABST
    Figure CN119379620B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of optical lens detection, and provides an optical lens surface scratch detection method and system. The method comprises the following steps: acquiring an image of a lens surface; performing grayscale on the image of the lens surface to obtain a lens grayscale image; acquiring a scratch color development grid according to the lens grayscale image, and obtaining a shortest color development distance through the scratch color development grid; obtaining a shortest scratch distance through the shortest color development distance; screening out a real scratch grid through the shortest scratch distance, connecting a center point of each real scratch grid with a center point of a grid corresponding to the shortest color development distance to obtain a scratch area. According to the detection method of the embodiment of the application, random noise in the image can be effectively inhibited, the real grayscale value of the scratch area can be accurately reflected, and the precision and reliability of the scratch detection are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of optical lens testing technology, specifically relating to a method and system for detecting scratches on the surface of optical lenses. Background Technology

[0002] The Chinese patent publication CN111551350A, "A Method for Detecting Scratch Surfaces of Optical Lenses Based on U_Net Networks," has several drawbacks when using coaxial light source illumination to detect scratches on lens surfaces. Firstly, when using coaxial light source illumination, minute scratches on the lens surface may cause image blurring due to complex optical effects, making it difficult to clearly capture scratch details. Secondly, high-brightness areas caused by strong illumination may generate abnormal grayscale noise values, interfering with subsequent image processing and scratch detection, confusing actual scratches with noise. Furthermore, due to direct illumination, the excessively high contrast between scratches and normal surfaces may cause minute scratches to be over-magnified in the image, obscuring details of the normal surface and affecting the overall evaluation. Finally, such strong illumination may also cause minute scratches to be misjudged as larger or deeper defects, leading to incorrect decisions. Therefore, effective detection methods are needed to overcome these problems and improve the accuracy of scratch recognition. Summary of the Invention

[0003] This invention aims to at least partially solve one of the technical problems in related technologies. Therefore, the first objective of this invention is to propose a method for detecting scratches on the surface of optical lenses, which can effectively suppress random noise in images, ensure accurate reflection of the true grayscale value of the scratched area, and improve the accuracy and reliability of scratch detection.

[0004] The second objective of this invention is to provide a scratch detection system for optical lens surfaces.

[0005] To achieve the above objectives, a first aspect of the present invention provides a method for detecting scratches on the surface of an optical lens, the method comprising the following steps:

[0006] S100, acquire an image of the lens surface;

[0007] S200: Convert the image of the lens surface to grayscale to obtain a grayscale image of the lens;

[0008] S300 obtains the scratch color rendering grid based on the lens grayscale image and obtains the shortest adjacent distance for color rendering through the scratch color rendering grid.

[0009] S400 obtains the shortest distance for developing marks by using the shortest adjacent distance for color development;

[0010] The S500 filters out the real scratch grid by the shortest distance of the scratch, and connects the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid to obtain the scratch area.

[0011] The detection method according to embodiments of the present invention can effectively suppress random noise in the image, ensure that the true gray value of the scratch area is accurately reflected, and improve the accuracy and reliability of scratch detection.

[0012] Furthermore, acquiring the image of the lens surface in step S100 includes: an illumination unit based on a coaxial light source, capturing the image of the lens surface through an optical sensor, wherein the optical sensor includes an optical scanning module and an image sensor; placing the lens on the sensor, the optical sensor capturing the lens image by projecting light onto the lens and detecting the reflected light, and the sensor acquiring the image of the lens through optical methods to generate an image of the lens surface.

[0013] Furthermore, in step S200, converting the image of the lens surface to grayscale to obtain a lens grayscale image includes:

[0014] The image of the lens surface is converted to grayscale, and the image of the lens surface after grayscale conversion is denoted as the first grayscale image. The first grayscale image is divided into grids using a grid partitioning algorithm. The grid size is 1 / 800 of the first grayscale image, dividing the first grayscale image into K grids, where K = 800. Let s(i) represent the grayscale value of the i-th grid of the first grayscale image, where i takes the value [1, K], and K is the number of grids after the first grayscale image is divided. The median of the grayscale values ​​in each grid of s(i) is obtained and denoted as sk, and the average grayscale value in each grid of s(i) is obtained and denoted as skm. The scratch grayscale value skp is calculated using the first equation. The scratch grayscale value is the grayscale value used to determine whether the scratch is a scratch color under illumination unit based on a coaxial light source, due to the brightness difference between the scratch and the normal area of ​​the lens.

[0015] The method for calculating the scratch grayscale value skp in the first equation is as follows:

[0016] skp=[(sk+skm) / 2]×ln[e+(sk / skm)];

[0017] Where (sk+skm) / 2 is the arithmetic mean of the median and average gray values ​​of the grid in the first grayscale image, and ln[e+(sk / skm)] represents the logarithmic processing of the median and average gray values ​​of the grid. Since the logarithmic function is not sensitive to small differences but will amplify the effect of large differences, the logarithmic processing can amplify the grayscale difference between the scratch and the normal area, thus highlighting the scratch area more. e is the natural constant, and ln is the logarithm with the natural constant e as the base. By using the natural constant e, the value in the logarithmic function can be avoided to be zero. At the same time, when the ratio of the median (sk) and average (skm) of the grid gray values ​​is close to 1, the logarithmic result is relatively stable.

[0018] The beneficial effects of this step are as follows: by using the median (sk) and average (skm) of the grid gray values ​​to extract the scratch gray value, the influence of random noise in the image (such as light reflection, stains, etc.) on the results can be effectively suppressed, thereby more accurately reflecting the true gray value display of the scratch area and ensuring the efficiency, accuracy and reliability of scratch detection on the surface of optical lenses.

[0019] In step S300, the scratch color rendering grid is obtained based on the lens grayscale image, and the shortest neighbor distance for color rendering is obtained through the scratch color rendering grid, specifically as follows:

[0020] The grids with gray values ​​greater than skp are obtained and denoted as scratch color-developing grids. Let k(j) represent the j-th scratch color-developing grid in the first grayscale image, and let KS(j) represent the shortest neighbor distance of the j-th scratch color-developing grid. j is the index, and the value of j is [1, G], where G is the number of scratch color-developing grids. The shortest neighbor distance of the j-th scratch color-developing grid is the length of the line segment with the smallest length among the line segments between the center point of the j-th scratch color-developing grid and the center points of all scratch color-developing grids.

[0021] While coaxial lighting provides uniform illumination, even minor scratches on the lens surface can cause image blurring or unclearness due to variations in light reflection, resulting in numerous high-grayscale noise points that affect subsequent scratch identification. Furthermore, the strong illumination from a coaxial light source can lead to high-brightness areas, increasing the contrast between scratches and normal surfaces. A large minimum color distance indicates a greater distance between the two scratch color grids, suggesting that these scratch points may exist independently or are noise points caused by variations in light reflection, lacking obvious connectivity and not forming a scratch. Conversely, a small minimum color distance indicates a close proximity between the two scratch color grids, suggesting a connection between the two points, either physically or visually, forming a scratch area. To avoid noise interference or misjudgment of scratches, it is necessary to calculate the shortest distance of the scratch using the minimum color distance for deeper scratch identification.

[0022] Furthermore, in step S400, obtaining the shortest distance for developing marks by using the shortest adjacent distance for color development includes:

[0023] S401, take the obtained KS(j) as an element of the shortest neighbor sequence SP. The shortest neighbor sequence SP consists of n shortest neighbors, namely {KS(1), KS(2), ..., KS(j)}, where KS(j) is the j-th shortest neighbor in the shortest neighbor sequence SP, j is the index, and the value range of j is j = 1, 2, ..., n. Let the average value of all shortest neighbors in the shortest neighbor sequence SP be KM; and obtain the standard deviation of all shortest neighbors in the shortest neighbor sequence SP.

[0024] S402, the shortest neighbor sequence of colorimetric intervals is internally classified according to the standard deviation of all shortest neighbor sequences of colorimetric intervals in SP; the shortest neighbor sequence of colorimetric intervals less than or equal to KM minus the standard deviation is classified as the first shortest neighbor sequence of colorimetric intervals Distan1; the shortest neighbor sequence of colorimetric intervals greater than the mean minus the standard deviation and less than the mean plus the standard deviation is classified as the second shortest neighbor sequence of colorimetric intervals Distan2; the shortest neighbor sequence of colorimetric intervals greater than or equal to the mean plus the standard deviation is classified as the third shortest neighbor sequence of colorimetric intervals Distan3;

[0025] Specifically, the first shortest colorimetric distance range, Distan1, includes all shortest colorimetric distances less than or equal to KM minus the standard deviation. The shorter distance between these grids indicates that they are clustered together and represent scratches with more obvious colorimetric appearance. The second shortest colorimetric distance range, Distan2, includes those shortest colorimetric distances between KM minus the standard deviation and KM plus the standard deviation. The distance between these grids is within a reasonable range and represents the less obvious parts of the scratches. The third shortest colorimetric distance range, Distan3, includes all shortest colorimetric distances greater than or equal to KM plus the standard deviation. The larger distance between these grids means that these grids are the edges of the scratches, sparsely distributed scratch points, or grids with abnormal colorimetric appearance caused by interference factors such as light reflection and stains.

[0026] S403, the distance ranges of the first shortest adjacent distance range Distan1, the second shortest adjacent distance range Distan2, and the third shortest adjacent distance range Distan3 are denoted as [s, m1], [m2, x1], and [x2, p], respectively, where s represents the lower limit (minimum value) of the first shortest adjacent distance range Distan1; this value is the starting point of the shortest adjacent distance range of the scratch, representing the minimum color rendering distance. m1 represents the upper limit (maximum value) of the first shortest adjacent distance range Distan1, which is the maximum distance between color rendering grids with greater scratch severity, representing the adjacent distance value of more severe scratches. m2 represents the lower limit (minimum) of the second color rendering shortest neighbor range Distan2, which is the starting value of the shortest neighbor range for relatively minor scratches; x1 represents the upper limit (maximum) of the second color rendering shortest neighbor range Distan2, which is the maximum neighbor value for relatively minor scratches; x2 represents the lower limit (minimum) of the third color rendering shortest neighbor range Distan3, corresponding to the starting point of the shortest neighbor range for minor scratches. p represents the upper limit (maximum) of the third color rendering shortest neighbor range Distan3, which is the maximum neighbor value for very minor or almost invisible scratches.

[0027] S404, calculate the first shortest distance Sdistan1 and the second shortest distance Sdistan2 of the first colorimetric shortest neighbor range Distan1, the second shortest distance Sdistan2 of the second colorimetric shortest neighbor range Distan2, and the third shortest distance Sdistan3 of the third colorimetric shortest neighbor range.

[0028] Where Sdistan1 is the maximum value m1 in the first shortest neighbor range X1 of color rendering minus the minimum distance range difference, where the minimum neighbor range difference is the product of m2 and the neighbor range stable balance ratio, where the neighbor range stable balance ratio is the ratio of m1×sk to m2×skp; where Sdistan2 is the maximum value m1 in the first shortest neighbor range X1 of color rendering plus the maximum neighbor range difference, where the maximum neighbor range difference is the product of m2 and the neighbor range abnormal balance ratio, where the neighbor range abnormal balance ratio is the ratio of x1×sk to (x2+x1)×skp;

[0029] Among them, the first shortest distance for scratches, Sdistan1, is used to identify the minimum colorimetric shortest neighbor distance for more obvious and severe scratches, while the second shortest distance for scratches, Sdistan2, is used to identify the minimum colorimetric shortest neighbor distance for scratches that are less obvious but still require attention; sk is the median of gray values ​​in all grids in the first grayscale image, and skp is the grayscale value of the scratch.

[0030] The benefits of this step are as follows: Sdistan1 and Sdistan2 are calculated based on statistical features of the shortest neighbor distance for color development, which can help identify areas with defects that significantly affect product functionality and appearance; Sdistan2 ensures that even minor flaws can be detected. This not only improves the accuracy of detection but also allows for detailed analysis under different quality standards; or, companies can further adjust the scratch tolerance through Sdistan1 and Sdistan2 according to product positioning and user needs, achieving more targeted quality management.

[0031] S405, calculate the shortest distance SD of the visible scar using the first visible scar neighbor distance Sdistan1 and the second visible scar neighbor distance Sdistan2;

[0032] Specifically, the method for calculating the shortest distance SD of the visible trace using the first visible trace neighbor distance Sdistan1 and the second visible trace neighbor distance Sdistan2 is as follows:

[0033]

[0034] Among them, the shortest distance for scratch development, SD, is the shortest neighbor distance of the scratch. It is a value based on Sdistan1 and Sdistan2, which helps to determine the location of the scratch in the detection image and the shortest distance of its color features; s represents the lower limit of the first shortest neighbor range for color development, Distan1, and m1 represents the upper limit of the first shortest neighbor range for color development, Distan1. The scratch development coefficient, obtained by using the first and second shortest scratch development distances, represents the scratch development ratio under minor defects. The distance value that can detect scratches with high accuracy can be obtained by multiplying the sum of the upper and lower limits of the first shortest adjacent distance range Distan1 (s+m1) with the scratch development ratio.

[0035] The benefits of this step are as follows: Although coaxial illumination provides uniform light, minor scratches on the lens surface may still cause image blurring or unclearness due to changes in light reflection. In this case, by calculating the minimum development distance (SD), the actual location and extent of the scratch can be determined more accurately based on the actual colorimetric differences. This is especially beneficial for minor scratches, as it avoids interference from noise or light reflection. Furthermore, the strong illumination provided by the coaxial light source may lead to the appearance of high-brightness areas, increasing the contrast between the scratch and the normal surface. This can cause minor scratches to be over-magnified. In this case, the minimum development distance (SD) can enhance the sensitivity to lens scratches under coaxial light by finding a balance between obvious and minor scratches, ensuring comprehensive monitoring of different types of scratches, identifying scratches that truly require attention, and preventing over-detection.

[0036] In step S500, the real scratch grid is selected by filtering out the shortest distance between the scratches. The scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid.

[0037] In the scratch color rendering grid, the grids where KS(j) is less than SD are denoted as real scratch grids. The center point of each real scratch grid is connected to the center point of the grid with the shortest distance to its corresponding color rendering grid by a line segment. All grids in the first grayscale image that are passed through by the line segment are denoted as scratch distribution grids. The area composed of all scratch distribution grids is denoted as the scratch region.

[0038] The beneficial effects of this invention are as follows: by using grayscale processing and color grid analysis, random noise in the image can be effectively suppressed, ensuring that the true grayscale value of the scratch area is accurately reflected, thereby improving the accuracy and reliability of scratch detection.

[0039] To achieve the above objectives, a second aspect of the present invention also provides an optical lens surface scratch detection system, the optical lens surface scratch detection system comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of an optical lens surface scratch detection method, and the optical lens surface scratch detection system operates in a desktop computer, a laptop, a handheld computer, or a cloud data center computing device.

[0040] By using an optical lens surface scratch detection system to detect scratches on the surface of optical lenses, random noise in the image can be effectively suppressed, ensuring that the true gray value of the scratch area is accurately reflected, thus improving the accuracy and reliability of scratch detection. Attached Figure Description

[0041] Figure 1 The diagram shows a flowchart of a method for detecting scratches on the surface of an optical lens.

[0042] Figure 2 The diagram shows the structure of an optical lens surface scratch detection system. Detailed Implementation

[0043] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0044] Figure 1 The diagram shows a flowchart of a method for detecting scratches on the surface of an optical lens.

[0045] Reference Figure 1 This invention proposes a method for detecting scratches on the surface of optical lenses, the method comprising the following steps:

[0046] S100, acquire an image of the lens surface;

[0047] S200: Convert the image of the lens surface to grayscale to obtain a grayscale image of the lens;

[0048] S300 obtains the scratch color rendering grid based on the lens grayscale image and obtains the shortest adjacent distance for color rendering through the scratch color rendering grid.

[0049] S400 obtains the shortest distance for developing marks by using the shortest adjacent distance for color development;

[0050] The S500 filters out the real scratch grid by the shortest distance of the scratch, and connects the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid to obtain the scratch area.

[0051] The detection method according to embodiments of the present invention can effectively suppress random noise in the image, ensure that the true gray value of the scratch area is accurately reflected, and improve the accuracy and reliability of scratch detection.

[0052] Furthermore, acquiring the image of the lens surface in step S100 includes: an illumination unit based on a coaxial light source, capturing the image of the lens surface through an optical sensor, wherein the optical sensor includes an optical scanning module and an image sensor; placing the lens on the sensor, the optical sensor capturing the lens image by projecting light onto the lens and detecting the reflected light, and the sensor acquiring the image of the lens through optical methods to generate an image of the lens surface.

[0053] Furthermore, in step S200, converting the image of the lens surface to grayscale to obtain a lens grayscale image includes:

[0054] The image of the lens surface is converted to grayscale, and the image of the lens surface after grayscale conversion is denoted as the first grayscale image. The first grayscale image is divided into grids using a grid partitioning algorithm. The grid size is 1 / 800 of the first grayscale image, dividing the first grayscale image into K grids, where K = 800. Let s(i) represent the grayscale value of the i-th grid of the first grayscale image, where i takes the value [1, K], and K is the number of grids after the first grayscale image is divided. The median of the grayscale values ​​in each grid of s(i) is obtained and denoted as sk, and the average grayscale value in each grid of s(i) is obtained and denoted as skm. The scratch grayscale value skp is calculated using the first equation. The scratch grayscale value is the grayscale value used to determine whether the scratch is a scratch color under illumination unit based on a coaxial light source, due to the brightness difference between the scratch and the normal area of ​​the lens.

[0055] The method for calculating the scratch grayscale value skp in the first equation is as follows:

[0056]

[0057] The beneficial effects of this step are as follows: by using the median (sk) and average (skm) of the grid gray values ​​to extract the scratch gray value, the influence of random noise in the image (such as light reflection, stains, etc.) on the results can be effectively suppressed, thereby more accurately reflecting the true gray value display of the scratch area and ensuring the efficiency, accuracy and reliability of scratch detection on the surface of optical lenses.

[0058] In step S300, the scratch color rendering grid is obtained based on the lens grayscale image, and the shortest neighbor distance for color rendering is obtained through the scratch color rendering grid, specifically as follows:

[0059] The grids in s(i) whose gray values ​​are greater than skp are identified as scratch color-producing grids. K(j) represents the j-th scratch color-producing grid in the first grayscale image, and KS(j) represents the shortest neighbor distance of the j-th scratch color-producing grid. The value of j is [1, G], where G is the number of scratch color-producing grids. The shortest neighbor distance of the j-th scratch color-producing grid is the length of the line segment with the smallest length among the line segments between the center point of the j-th scratch color-producing grid and the center points of all scratch color-producing grids.

[0060] While coaxial lighting provides uniform illumination, even minor scratches on the lens surface can cause image blurring or unclearness due to variations in light reflection, resulting in numerous high-grayscale noise points that affect subsequent scratch identification. Furthermore, the strong illumination from a coaxial light source can lead to high-brightness areas, increasing the contrast between scratches and normal surfaces. A large minimum color distance indicates a greater distance between the two scratch color grids, suggesting that these scratch points may exist independently or are noise points caused by variations in light reflection, lacking obvious connectivity and not forming a scratch. Conversely, a small minimum color distance indicates a close proximity between the two scratch color grids, suggesting a connection between the two points, either physically or visually, forming a scratch area. To avoid noise interference or misjudgment of scratches, it is necessary to calculate the shortest distance of the scratch using the minimum color distance for deeper scratch identification.

[0061] Furthermore, in step S400, obtaining the shortest distance for developing marks by using the shortest adjacent distance for color development includes:

[0062] S401, take the obtained KS(j) as an element of the shortest neighbor sequence SP. The shortest neighbor sequence SP consists of n shortest neighbors, namely {KS(1), KS(2), ..., KS(j)}, where KS(j) is the j-th shortest neighbor in the shortest neighbor sequence SP, j is the index, and the value range of j is j = 1, 2, ..., n. Let the average value of all shortest neighbors in the shortest neighbor sequence SP be KM; and obtain the standard deviation of all shortest neighbors in the shortest neighbor sequence SP.

[0063] S402, the shortest neighbor sequence of colorimetric intervals is internally classified according to the standard deviation of all shortest neighbor sequences of colorimetric intervals in SP; the shortest neighbor sequence of colorimetric intervals less than or equal to KM minus the standard deviation is classified as the first shortest neighbor sequence of colorimetric intervals Distan1; the shortest neighbor sequence of colorimetric intervals greater than the mean minus the standard deviation and less than the mean plus the standard deviation is classified as the second shortest neighbor sequence of colorimetric intervals Distan2; the shortest neighbor sequence of colorimetric intervals greater than or equal to the mean plus the standard deviation is classified as the third shortest neighbor sequence of colorimetric intervals Distan3;

[0064] Specifically, the first shortest colorimetric distance range, Distan1, includes all shortest colorimetric distances less than or equal to KM minus the standard deviation. The shorter distance between these grids indicates that they are clustered together and represent scratches with more obvious colorimetric appearance. The second shortest colorimetric distance range, Distan2, includes those shortest colorimetric distances between KM minus the standard deviation and KM plus the standard deviation. The distance between these grids is within a reasonable range and represents the less obvious parts of the scratches. The third shortest colorimetric distance range, Distan3, includes all shortest colorimetric distances greater than or equal to KM plus the standard deviation. The larger distance between these grids means that these grids are the edges of the scratches, sparsely distributed scratch points, or grids with abnormal colorimetric appearance caused by interference factors such as light reflection and stains.

[0065] S403, the distance ranges of the first shortest adjacent distance range Distan1, the second shortest adjacent distance range Distan2, and the third shortest adjacent distance range Distan3 are denoted as [s, m1], [m2, x1], and [x2, p], respectively, where s represents the lower limit (minimum value) of the first shortest adjacent distance range Distan1; this value is the starting point of the shortest adjacent distance range of the scratch, representing the minimum color rendering distance. m1 represents the upper limit (maximum value) of the first shortest adjacent distance range Distan1, which is the maximum distance between color rendering grids with greater scratch severity, representing the adjacent distance value of more severe scratches. m2 represents the lower limit (minimum) of the second color rendering shortest neighbor range Distan2, which is the starting value of the shortest neighbor range for relatively minor scratches; x1 represents the upper limit (maximum) of the second color rendering shortest neighbor range Distan2, which is the maximum neighbor value for relatively minor scratches; x2 represents the lower limit (minimum) of the third color rendering shortest neighbor range Distan3, corresponding to the starting point of the shortest neighbor range for minor scratches. p represents the upper limit (maximum) of the third color rendering shortest neighbor range Distan3, which is the maximum neighbor value for very minor or almost invisible scratches.

[0066] S404, calculate the first shortest distance Sdistan1 and the second shortest distance Sdistan2 of the first colorimetric shortest neighbor range Distan1, the second shortest distance Sdistan2 of the second colorimetric shortest neighbor range Distan2, and the third shortest distance Sdistan3 of the third colorimetric shortest neighbor range.

[0067] Where Sdistan1 is the maximum value m1 in the first shortest neighbor range X1 of color rendering minus the minimum distance range difference, where the minimum neighbor range difference is the product of m2 and the neighbor range stable balance ratio, where the neighbor range stable balance ratio is the ratio of m1×sk to m2×skp; where Sdistan2 is the maximum value m1 in the first shortest neighbor range X1 of color rendering plus the maximum neighbor range difference, where the maximum neighbor range difference is the product of m2 and the neighbor range abnormal balance ratio, where the neighbor range abnormal balance ratio is the ratio of x1×sk to (x2+x1)×skp;

[0068] Among them, the first shortest distance for scratches, Sdistan1, is used to identify the minimum colorimetric shortest neighbor distance for more obvious and severe scratches, while the second shortest distance for scratches, Sdistan2, is used to identify the minimum colorimetric shortest neighbor distance for scratches that are less obvious but still require attention; sk is the median of gray values ​​in all grids in the first grayscale image, and skp is the grayscale value of the scratch.

[0069] The benefits of this step are as follows: Sdistan1 and Sdistan2 are calculated based on statistical features of the shortest neighbor distance for color development, which can help identify areas with defects that significantly affect product functionality and appearance; Sdistan2 ensures that even minor flaws can be detected. This not only improves the accuracy of detection but also allows for detailed analysis under different quality standards; or, companies can further adjust the scratch tolerance through Sdistan1 and Sdistan2 according to product positioning and user needs, achieving more targeted quality management.

[0070] S405, calculate the shortest distance SD of the visible scar using the first visible scar neighbor distance Sdistan1 and the second visible scar neighbor distance Sdistan2;

[0071] Specifically, the method for calculating the shortest distance SD of the visible trace using the first visible trace neighbor distance Sdistan1 and the second visible trace neighbor distance Sdistan2 is as follows:

[0072]

[0073] Among them, the shortest distance for scratch development, SD, is the shortest neighbor distance of the scratch. It is a value based on Sdistan1 and Sdistan2, which helps to determine the location of the scratch in the detection image and the shortest distance of its color features; s represents the lower limit of the first shortest neighbor range for color development, Distan1, and m1 represents the upper limit of the first shortest neighbor range for color development, Distan1. The scratch development coefficient, obtained by using the first and second shortest scratch development distances, represents the scratch development ratio under minor defects. The distance value that can detect scratches with high accuracy can be obtained by multiplying the sum of the upper and lower limits of the first shortest adjacent distance range Distan1 (s+m1) with the scratch development ratio.

[0074] The benefits of this step are as follows: Although coaxial illumination provides uniform light, minor scratches on the lens surface may still cause image blurring or unclearness due to changes in light reflection. In this case, by calculating the minimum development distance (SD), the actual location and extent of the scratch can be determined more accurately based on the actual colorimetric differences. This is especially beneficial for minor scratches, as it avoids interference from noise or light reflection. Furthermore, the strong illumination provided by the coaxial light source may lead to the appearance of high-brightness areas, increasing the contrast between the scratch and the normal surface. This can cause minor scratches to be over-magnified. In this case, the minimum development distance (SD) can enhance the sensitivity to lens scratches under coaxial light by finding a balance between obvious and minor scratches, ensuring comprehensive monitoring of different types of scratches, identifying scratches that truly require attention, and preventing over-detection.

[0075] In step S500, the real scratch grid is selected by filtering out the shortest distance between the scratches. The scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid.

[0076] In the scratch color rendering grid, the grids where KS(j) is less than SD are denoted as real scratch grids. The center point of each real scratch grid is connected to the center point of the grid with the shortest distance to its corresponding color rendering grid by a line segment. All grids in the first grayscale image that are passed through by the line segment are denoted as scratch distribution grids. The area composed of all scratch distribution grids is denoted as the scratch region.

[0077] Figure 2 The diagram shows the structure of an optical lens surface scratch detection system.

[0078] Reference Figure 2 The present invention also proposes an optical lens surface scratch detection system 20, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of an optical lens surface scratch detection method. The optical lens surface scratch detection system 20 runs on a desktop computer, a laptop, a handheld computer, or a cloud data center computing device.

[0079] The detection system includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program within the following units of the detection system:

[0080] Acquisition unit 21 is used to acquire images of the lens surface;

[0081] The conversion unit 22 is used to convert the image on the lens surface to grayscale to obtain a grayscale image of the lens;

[0082] Loading unit 23 is used to obtain the scratch color rendering grid based on the lens grayscale image and obtain the shortest neighbor distance for color rendering through the scratch color rendering grid;

[0083] Calculation unit 24 is used to obtain the shortest distance of the developing mark by the shortest adjacent distance of the developing color;

[0084] Display unit 25 is used to filter out the real scratch grid by the shortest distance of the scratch, and connect the center point of each real scratch grid with the center point of the corresponding grid with the shortest distance of the color to obtain the scratch area.

[0085] The optical lens surface scratch detection system described above can run on computing devices such as desktop computers, laptops, handheld computers, and cloud servers. The operational detection system of the optical lens surface scratch detection system may include, but is not limited to, processors and memory. Those skilled in the art will understand that the above example is merely an illustration of an optical lens surface scratch detection system 20 and does not constitute a limitation on the optical lens surface scratch detection system 20. It may include more or fewer components, or combine certain components, or different components. For example, the optical lens surface scratch detection system may also include input / output devices, network access devices, buses, etc.

[0086] By using the optical lens surface scratch detection system 20 to perform the method of detecting scratches on the surface of optical lenses, random noise in the image can be effectively suppressed, ensuring that the true gray value of the scratch area is accurately reflected, thus improving the accuracy and reliability of scratch detection.

[0087] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0088] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0089] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0090] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0091] Furthermore, the terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying relative importance, or implicitly specifying the number of technical features indicated in this embodiment. Therefore, features defined with terms such as "first" and "second" in the embodiments of this invention can explicitly or implicitly indicate that the embodiment includes at least one of those features. In the description of this invention, the word "multiple" means at least two or more, such as two, three, four, etc., unless otherwise explicitly specified in the embodiments.

[0092] In this invention, unless otherwise explicitly specified or limited in the embodiments, the terms "installation," "connection," "joining," and "fixing" appearing in the embodiments should be interpreted broadly. For example, a connection can be a fixed connection, a detachable connection, or an integral part; it can also be a mechanical connection, an electrical connection, etc. Of course, it can also be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components, or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific implementation.

[0093] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.

[0094] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for detecting scratches on the surface of an optical lens, characterized in that, The method includes the following steps: S100, acquire an image of the lens surface; S200: Convert the image of the lens surface to grayscale to obtain a grayscale image of the lens; The image of the lens surface is converted to grayscale, and the image of the lens surface after grayscale conversion is recorded as the first grayscale image; S300 obtains the scratch color rendering grid based on the lens grayscale image and obtains the shortest adjacent distance for color rendering through the scratch color rendering grid. The first grayscale image is divided into grids using a grid partitioning algorithm. The grid size is 1 / 800 of the first grayscale image, dividing it into K grids, where K=800. Let s(i) represent the grayscale value of the i-th grid in the first grayscale image, where i takes the value [1, K], and K is the number of grids after the first grayscale image is partitioned. The median of the grayscale values ​​in each grid in s(i) is obtained and denoted as sk, and the average of the grayscale values ​​in each grid in s(i) is obtained and denoted as skm. The scratch grayscale value skp is calculated using the first equation. The scratch grayscale value is the grayscale value used to determine whether a scratch is a visible color under a lighting unit based on a coaxial light source, due to the difference in brightness between the scratch and the normal area of ​​the lens. The method for calculating the scratch grayscale value skp using the first equation is as follows: ; The grids in s(i) whose gray values ​​are greater than skp are identified as scratch color-producing grids. K(j) represents the j-th scratch color-producing grid in the first grayscale image, and KS(j) represents the shortest neighbor distance of the j-th scratch color-producing grid. The value of j is [1, G], where G is the number of scratch color-producing grids. The shortest neighbor distance of the j-th scratch color-producing grid is the length of the line segment with the smallest length between the center point of the j-th scratch color-producing grid and the center point of all scratch color-producing grids. S400 obtains the shortest distance for developing marks by using the shortest adjacent distance for color development; S401, take the obtained KS(j) as an element of the shortest neighbor sequence SP. The shortest neighbor sequence SP is composed of n shortest neighbors, namely {KS(1), KS(2), ..., KS(j)}, where KS(j) is the j-th shortest neighbor in the shortest neighbor sequence SP, j is the index, and the value range of j is j=1, 2, ..., n. Let the average value of all shortest neighbors in the shortest neighbor sequence SP be KM; and obtain the standard deviation of all shortest neighbors in the shortest neighbor sequence SP. S402, the shortest neighbor sequence of colorimetric intervals is internally classified according to the standard deviation of all shortest neighbor sequences of colorimetric intervals in SP; the shortest neighbor sequence of colorimetric intervals less than or equal to KM minus the standard deviation is classified as the first shortest neighbor sequence of colorimetric intervals Distan1; the shortest neighbor sequence of colorimetric intervals greater than the mean minus the standard deviation and less than the mean plus the standard deviation is classified as the second shortest neighbor sequence of colorimetric intervals Distan2; the shortest neighbor sequence of colorimetric intervals greater than or equal to the mean plus the standard deviation is classified as the third shortest neighbor sequence of colorimetric intervals Distan3; S403, the distance ranges of the first color shortest neighbor range Distan1, the second color shortest neighbor range Distan2, and the third color shortest neighbor range Distan3 are respectively denoted as [s, m1], [m2, x1], and [x2, p]; S404, calculate the first shortest distance Sdistan1 and the second shortest distance Sdistan2 of the first colorimetric shortest neighbor range Distan1, the second shortest distance Sdistan2 of the second colorimetric shortest neighbor range Distan2, and the third shortest distance Sdistan3 of the third colorimetric shortest neighbor range. Where Sdistan1 is the maximum value m1 in the first shortest neighbor range X1 of color rendering minus the minimum distance range difference, where the minimum neighbor range difference is the product of m2 and the neighbor range stable balance ratio, where the neighbor range stable balance ratio is the ratio of m1×sk to m2×skp; where Sdistan2 is the maximum value m1 in the first shortest neighbor range X1 of color rendering plus the maximum neighbor range difference, where the maximum neighbor range difference is the product of m2 and the neighbor range abnormal balance ratio, where the neighbor range abnormal balance ratio is the ratio of x1×sk to (x2+x1)×skp; Where sk is the median of gray values ​​in all grids of the first grayscale image, and skp is the gray value of the scratch. S405, calculate the shortest distance SD of the visible scar using the first visible scar neighbor distance Sdistan1 and the second visible scar neighbor distance Sdistan2; The method for calculating the shortest distance SD of the visible scar using the first visible scar neighbor distance Sdistan1 and the second visible scar neighbor distance Sdistan2 is as follows: ; The S500 filters out the real scratch grid by the shortest distance of the scratch, and connects the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid to obtain the scratch area.

2. The method for detecting scratches on the surface of an optical lens according to claim 1, characterized in that, The process of acquiring an image of the lens surface in step S100 includes: using an illumination unit based on a coaxial light source to capture an image of the lens surface through an optical sensor, wherein the optical sensor includes an optical scanning module and an image sensor; placing the lens on the sensor, and the optical sensor capturing the lens image by projecting light onto the lens and detecting the reflected light; the sensor acquiring the image of the lens through optical methods to generate an image of the lens surface.

3. The method for detecting scratches on the surface of an optical lens according to claim 1, characterized in that, In step S500, the real scratch grid is selected by filtering out the shortest distance between the scratches. The scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding shortest neighbor grid. In the scratch color rendering grid, the grids where KS(j) is less than SD are denoted as real scratch grids. The center point of each real scratch grid is connected to the center point of the grid with the shortest distance to its corresponding color rendering grid by a line segment. All grids in the first grayscale image that are passed through by the line segment are denoted as scratch distribution grids. The area composed of all scratch distribution grids is denoted as the scratch region.

4. A system for detecting scratches on the surface of an optical lens, characterized in that, The optical lens surface scratch detection system includes: a processor, a memory, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the optical lens surface scratch detection method according to any one of claims 1 to 3.