Optical lens surface scratch detection method and system
By analyzing the ashization processing and color rendering grid of optical lenses, calculating the shortest color of the neighbor and the shortest distance of the minimum color rendering, solving the problem of blurring and noise interference of the image light source lighting of coaxial axis, and achieved more efficient, accurate and accurate Scratch detection.
Patent Information
- Application Number
- CN202411406166.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-10
AI Technical Summary
When using coaxial light sources to illuminate the existing optical lens surface scratch detection methods, they may cause image blur, noise interference and tiny scratches to be over-amplified, which will affect the accuracy of the detection.
Put forward a optical lens surface scratch detection method. By obtaining the image on the surface of the lens, the grayization processing and obtaining the scratch color grid, calculate the shortest color of the neighbor and the shortest distance of the show, screen out the real scratch net The grid is connected to the heart point to obtain the scratch area.
Effectively suppress the random noise in the image, ensure that the real grayscale of the scratch area is worthy of accurate reflection, and improves the accuracy and reliability of scratch detection.
Smart Images

Figure CN119379620A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of optical lens detection, and in particular relates to a method and system for detecting scratches on the surface of an optical lens. Background Art
[0002] Since the Chinese patent publication number CN111551350A "A method for detecting scratches on the surface of an optical lens based on a U_Net network" uses coaxial light source illumination to detect scratches on the surface of the lens, the above method may have the following disadvantages; among them, when using coaxial light source illumination, the fine scratches on the surface of the lens may cause image blur due to complex optical effects, making it difficult to clearly capture the details of the scratches; in addition, the high brightness area caused by strong illumination may produce noise points with abnormal grayscale values to interfere with subsequent image processing and scratch detection, confusing the actual scratches with noise, and due to the direct illumination of the light source, the reflection contrast between the scratches and the normal surface is too high, which may cause the tiny scratches to be over-magnified in the image, covering the details of the normal surface, thereby affecting the overall evaluation. Finally, this strong light illumination may also cause tiny scratches to be misjudged as larger or deeper defects, leading to wrong decisions. Therefore, effective detection methods are needed to overcome these problems and improve the accuracy of scratch recognition. Summary of the invention
[0003] The present invention aims to solve at least one of the technical problems in the related art to a certain extent. To this end, the first object of the present invention is to provide a method for detecting scratches on the surface of an optical lens, which can effectively suppress random noise in the image, ensure that the true grayscale value of the scratch area is accurately reflected, and improve the accuracy and reliability of scratch detection;
[0004] The second object of the present invention is to provide a system for detecting scratches on the surface of an optical lens.
[0005] To achieve the above-mentioned purpose, 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, acquiring an image of the lens surface;
[0007] S200, graying the image of the lens surface to obtain a lens grayscale image;
[0008] S300, obtaining a scratch color grid according to the lens grayscale image, and obtaining the shortest color neighbor distance through the scratch color grid;
[0009] S400, obtain the shortest distance of visible traces through the shortest color-displaying neighbor distance;
[0010] S500, selecting the real scratch grids by the shortest scratch display distance, and connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance to obtain the scratch area.
[0011] According to the detection method of the embodiment of the present invention, random noise in the image can be effectively suppressed, ensuring that the real grayscale value of the scratch area is accurately reflected, thereby improving the accuracy and reliability of scratch detection.
[0012] Furthermore, in step S100, obtaining an image of the lens surface includes: a lighting unit based on a coaxial light source, capturing the imaging 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 captures the lens image by projecting light onto the lens and detecting reflected light, and the sensor collects the image of the lens through an optical method to generate an image of the lens surface.
[0013] Furthermore, in step S200, graying the image of the lens surface to obtain a lens grayscale image includes:
[0014] The image of the lens surface is grayed, and the image of the lens surface after graying is recorded as the first grayscale image. The first grayscale image is meshed by a meshing algorithm, and the mesh size is 1 / 800 of the first grayscale image. The first grayscale image is divided into K grids, where K=800, and s(i) represents the grayscale value of the i-th grid of the first grayscale image, i is [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 in s(i) is obtained and recorded as sk, and the average of the grayscale values in each grid in s(i) is obtained and recorded as skm; the scratch grayscale value skp is calculated by the first equation; the scratch grayscale value is the grayscale value for judging whether it is a scratch color in the grayscale difference caused by the brightness difference between the scratch of the lens and the normal area of the lens under the lighting unit based on the coaxial light source.
[0015] Among them, the method for calculating the scratch gray value skp in the first equation is:
[0016] skp=[(sk+skm) / 2]×ln[e+(sk / skm)];
[0017] Among them, (sk+skm) / 2 is the arithmetic mean of the median and average grayscale values of the grid in the first grayscale image, ln[e+(sk / skm)] represents the logarithmic processing of the median and average grayscale values of the grid. Since the logarithmic function is insensitive to small differences but will enhance the impact of large differences, the logarithmic processing can amplify the grayscale difference between the scratch and the normal area, thereby highlighting the scratch area. e is a natural constant, and ln is the logarithm with the natural constant e as the base. By referring to the natural constant e, the value of the logarithmic function can be avoided to be zero. At the same time, when the ratio of the median (sk) and the average (skm) of the grid grayscale value is close to 1, the logarithmic result is relatively stable.
[0018] The beneficial effect of this step is: using the median (sk) and mean (skm) of the grid grayscale value to extract the scratch grayscale value can effectively suppress the influence of random noise in the image (such as light reflection, stains, etc.) on the result, thereby more accurately reflecting the true grayscale display of the scratch area, ensuring the efficiency, accuracy and reliability of optical lens surface scratch detection.
[0019] In step S300, the scratch color grid is obtained according to the lens grayscale image, and the shortest color neighbor distance is obtained through the scratch color grid:
[0020] Get the grids with grayscale values greater than skp and record them as scratch-colored grids, use k(j) to represent the j-th scratch-colored grid in the first grayscale image, and use KS(j) to represent the shortest color-colored neighbor distance of the j-th scratch-colored grid. j is the sequence number, and the value of j is [1, G], G is the number of scratch-colored grids; the shortest color-colored neighbor distance of the j-th scratch-colored grid is the length of the shortest line segment among the line segment lengths between the grid center point of the j-th scratch-colored grid and the center points of all scratch-colored grids.
[0021] Although coaxial light source illumination can provide uniform light source, slight scratches on the lens surface may still cause blurred or unclear images due to changes in light reflection, resulting in many abnormal noise points with high grayscale values, which affect the subsequent identification of scratches. In addition, the strong illumination provided by the coaxial light source may cause high-brightness areas to appear, increasing the reflection contrast between scratches and normal surfaces. When the shortest color neighbor distance is large, it means that the distance between the two scratch color grids is far, indicating that the two scratch points may be independent or noise points caused by changes in light reflection. There is no obvious connectivity between them and no scratches will be generated. On the contrary, when the shortest color neighbor distance is small, it means that the distance between the two scratch color grids is very close, then the two points are actually or visually connected, forming a scratch area. In order to avoid interference from noise points or misjudgment of scratches, it is necessary to calculate the shortest distance of scratches through the shortest color neighbor distance for deeper scratch identification.
[0022] Further, in step S400, obtaining the shortest distance of visible traces by the shortest color-displaying neighbor distance includes:
[0023] S401, use the obtained KS(j) as an element of the color-displaying shortest neighbor distance sequence SP, then the color-displaying shortest neighbor distance sequence SP is composed of n color-displaying shortest neighbor distances, namely {KS(1), KS(2), ..., KS(j)}, KS(j) is the j-th color-displaying shortest neighbor distance in the color-displaying shortest neighbor distance sequence SP, j is a sequence number, and the value range of j is j=1, 2, ..., n. The average value of all the color-displaying shortest neighbor distances in the color-displaying shortest neighbor distance sequence SP is KM; and obtain the standard deviation of all the color-displaying shortest neighbor distances in the color-displaying shortest neighbor distance sequence SP.
[0024] S402, internally classify the color rendering shortest neighbor distance sequence according to the standard deviation of all color rendering shortest neighbor distances in the color rendering shortest neighbor distance sequence SP; the color rendering shortest neighbor distance less than or equal to the value of KM minus the standard deviation is classified as the first color rendering shortest neighbor distance range Distan1; the color rendering shortest neighbor distance greater than the mean value minus the standard deviation and less than the mean value plus the standard deviation is classified as the second color rendering shortest neighbor distance range Distan2; the color rendering shortest neighbor distance greater than or equal to the mean value plus the standard deviation is classified as the third color rendering shortest neighbor distance range Distan3;
[0025] Specifically, the first color display shortest neighbor distance range Distan1 includes all color display shortest neighbor distances less than or equal to KM minus the standard deviation, and the distances between these grids are short, indicating that these grids clustered together represent scratches with more obvious color display; the second color display shortest neighbor distance range Distan2 includes those color display shortest neighbor distances between KM minus the standard deviation and KM plus the standard deviation. The distances between these grids are within a reasonable range and belong to the relatively less obvious part of the scratch color display; the third color display shortest neighbor distance range Distan3 includes all color display shortest neighbor distances greater than or equal to KM plus the standard deviation, and the distances between these grids are larger, which means that these grids are the edge parts of the scratches, sparsely distributed scratch points, or grids with abnormal color display caused by interference factors such as light reflection and stains.
[0026] S403, the distance ranges of the first color rendering shortest neighbor distance range Distan1, the second color rendering shortest neighbor distance range Distan2, and the third color rendering shortest neighbor distance range Distan3 are recorded as [s, m1], [m2, x1], and [x2, p], respectively, where s represents the lower limit (minimum value) of the first color rendering shortest neighbor distance range Distan1; this value is the starting point of the scratch shortest neighbor distance range, indicating the minimum color rendering distance. m1 represents the upper limit (maximum value) of the first color rendering shortest neighbor distance range Distan1, which is the maximum distance between color rendering grids with greater scratch severity, indicating the distance value of more serious scratches. m2 represents the lower limit (minimum value) of the second color rendering shortest distance range Distan2, i.e., the starting value of the shortest distance of relatively minor scratches; x1 represents the upper limit (maximum value) of the second color rendering shortest distance range Distan2, i.e., the maximum distance value of relatively minor scratches; x2 represents the lower limit (minimum value) of the third color rendering shortest distance range Distan3, corresponding to the starting point of the shortest distance of minor scratches. p represents the upper limit (maximum value) of the third color rendering shortest distance range Distan3, i.e., the maximum distance value of very minor or almost invisible scratches.
[0027] S404, calculating a first visible trace shortest distance Sdistan1 and a second visible trace shortest distance Sdistan2 through the first color display shortest neighbor distance range Distan1, the second color display shortest neighbor distance range Distan2, and the third color display shortest neighbor distance range Distan3;
[0028] Wherein Sdistan1 is the maximum value m1 in the first color rendering shortest neighbor distance range X1 minus the minimum distance range difference, wherein the minimum neighbor distance range difference is the product of m2 and the neighbor distance stability balance ratio, wherein the neighbor distance stability balance ratio is the ratio of m1×sk to m2×skp; wherein Sdistan2 is the maximum value m1 in the first color rendering shortest neighbor distance range X1 plus the maximum neighbor distance range difference, wherein the maximum neighbor distance range difference is the product of m2 and the neighbor distance abnormal balance ratio, wherein the neighbor distance abnormal balance ratio is the ratio of x1×sk to (x2+x1)×skp;
[0029] Among them, the first visible scratch shortest distance Sdistan1 is used to identify the minimum color-displaying shortest neighbor distance of more obvious and serious scratches, and the second visible scratch shortest distance Sdistan2 is used to identify the minimum color-displaying shortest neighbor distance of scratches that are less obvious but still need attention; sk is the median of the grayscale values of all grids in the first grayscale image, and skp is the grayscale value of the scratch.
[0030] The beneficial effects of this step are: Sdistan1 and Sdistan2 are obtained by calculating the statistical characteristics based on the shortest neighbor distance of color display, which can help identify areas with defects that significantly affect product function and appearance; and Sdistan2 can ensure that even minor flaws can be monitored. This acquisition not only improves the accuracy of detection, but also allows detailed analysis under different quality standards; or companies can further flexibly adjust the scratch tolerance through Sdistan1 and Sdistan2 according to product positioning and user needs, so as to achieve more targeted quality management.
[0031] S405, calculating the shortest visible trace distance SD by using the first visible trace distance Sdistan1 and the second visible trace distance Sdistan2;
[0032] Specifically, the method for calculating the shortest visible trace distance SD by using the first visible trace distance Sdistan1 and the second visible trace distance Sdistan2 is:
[0033]
[0034] Among them, the shortest scratch distance SD is the shortest neighbor distance of the scratch. It is a value based on Sdistan1 and Sdistan2, which helps to determine the position of the scratch in the detection image and the shortest distance of its color display characteristics; s represents the lower limit of the first color display shortest neighbor distance range Distan1, and m1 represents the upper limit of the first color display shortest neighbor distance range Distan1. It is the trace coefficient obtained by the first shortest trace distance and the second shortest trace distance, which represents the trace ratio under slight defect traces; by multiplying the sum of the upper and lower limits (s+m1) of the first color rendering shortest adjacent distance range Distan1 by the trace ratio, it is possible to obtain a distance value that can detect scratches with high accuracy.
[0035] The beneficial effects of this step are: although coaxial light source illumination can provide a uniform light source, minute scratches on the lens surface may still cause blurred or unclear images due to changes in light reflection. In this case, by calculating the shortest visible scratch distance SD, the actual position and range of the scratch can be determined more accurately based on the actual color rendering proximity difference, especially for relatively minor scratches, which can avoid interference from noise or light reflection; and the strong illumination provided by the coaxial light source may cause high-brightness areas to appear, increasing the reflection contrast between the scratches and the normal surface, so that tiny scratches may be over-magnified. In this case, the shortest visible scratch distance SD can enhance the sensitivity to lens scratches under the coaxial light source by finding a balance between obvious scratches and tiny scratches, ensuring comprehensive monitoring of different types of scratches, identifying scratches that really need attention, and preventing excessive detection.
[0036] In step S500, the real scratch grids are screened out by the shortest distance of scratch display, and the scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance, including:
[0037] The grids in the scratch color grid whose KS(j) is less than SD are recorded as real scratch grids, and the center point of each real scratch grid is connected with the center point of its corresponding color-displayed shortest neighboring distance through a line segment. All grids passed by the line segment in the first grayscale image are recorded as scratch distribution grids, and the area composed of all scratch distribution grids is recorded as the scratch area.
[0038] The beneficial effects of the present invention are as follows: through grayscale processing and color grid analysis, random noise in the image can be effectively suppressed, ensuring that the real grayscale value of the scratch area is accurately reflected, thereby improving the accuracy and reliability of scratch detection.
[0039] To achieve the above-mentioned purpose, the second aspect of the present invention further proposes a system for detecting scratches on the surface of an optical lens, wherein the system comprises: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in a method for detecting scratches on the surface of an optical lens when executing the computer program, and the system for detecting scratches on the surface of an optical lens runs on a computing device such as a desktop computer, a notebook, a PDA, and a cloud data center.
[0040] The method for detecting scratches on the surface of an optical lens by using an optical lens surface scratch detection system can effectively suppress random noise in the image, ensure that the true grayscale value of the scratch area is accurately reflected, and improve the accuracy and reliability of scratch detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Shown is a flow chart of a method for detecting scratches on the surface of an optical lens;
[0042] Figure 2 Shown is the structural diagram of the optical lens surface scratch detection system. DETAILED DESCRIPTION
[0043] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0044] Figure 1 Shown is a flow chart of a method for detecting scratches on the surface of an optical lens.
[0045] Reference Figure 1 The present invention provides a method for detecting scratches on the surface of an optical lens, the method comprising the following steps:
[0046] S100, acquiring an image of the lens surface;
[0047] S200, graying the image of the lens surface to obtain a lens grayscale image;
[0048] S300, obtaining a scratch color grid according to the lens grayscale image, and obtaining the shortest color neighbor distance through the scratch color grid;
[0049] S400, obtain the shortest distance of visible traces through the shortest color-displaying neighbor distance;
[0050] S500, selecting the real scratch grids by the shortest scratch display distance, and connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance to obtain the scratch area.
[0051] According to the detection method of the embodiment of the present invention, random noise in the image can be effectively suppressed, ensuring that the real grayscale value of the scratch area is accurately reflected, thereby improving the accuracy and reliability of scratch detection.
[0052] Furthermore, in step S100, obtaining an image of the lens surface includes: a lighting unit based on a coaxial light source, capturing the imaging 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 captures the lens image by projecting light onto the lens and detecting reflected light, and the sensor collects the image of the lens through an optical method to generate an image of the lens surface.
[0053] Furthermore, in step S200, graying the image of the lens surface to obtain a lens grayscale image includes:
[0054] The image of the lens surface is grayed, and the image of the lens surface after graying is recorded as the first grayscale image. The first grayscale image is meshed by a meshing algorithm, and the mesh size is 1 / 800 of the first grayscale image. The first grayscale image is divided into K grids, where K=800, and s(i) represents the grayscale value of the i-th grid of the first grayscale image, i is [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 in s(i) is obtained and recorded as sk, and the average of the grayscale values in each grid in s(i) is obtained and recorded as skm; the scratch grayscale value skp is calculated by the first equation; the scratch grayscale value is the grayscale value for judging whether it is a scratch color in the grayscale difference caused by the brightness difference between the scratch of the lens and the normal area of the lens under the lighting unit based on the coaxial light source.
[0055] Among them, the method for calculating the scratch gray value skp in the first equation is:
[0056]
[0057] The beneficial effect of this step is: using the median (sk) and mean (skm) of the grid grayscale value to extract the scratch grayscale value can effectively suppress the influence of random noise in the image (such as light reflection, stains, etc.) on the result, thereby more accurately reflecting the true grayscale display of the scratch area, ensuring the efficiency, accuracy and reliability of optical lens surface scratch detection.
[0058] In step S300, the scratch color grid is obtained according to the lens grayscale image, and the shortest color neighbor distance is obtained through the scratch color grid:
[0059] Get the grids in s(i) whose grayscale values are greater than skp and record them as scratch-colored grids, use k(j) to represent the j-th scratch-colored grid in the first grayscale image, and use KS(j) to represent the shortest color-colored neighbor distance of the j-th scratch-colored grid. The value of j is [1, G], and G is the number of scratch-colored grids. The shortest color-colored neighbor distance of the j-th scratch-colored grid is the length of the shortest line segment among the line segments between the grid center point of the j-th scratch-colored grid and the center points of all scratch-colored grids.
[0060] Although coaxial light source illumination can provide uniform light source, slight scratches on the lens surface may still cause blurred or unclear images due to changes in light reflection, resulting in many abnormal noise points with high grayscale values, which affect the subsequent identification of scratches. In addition, the strong illumination provided by the coaxial light source may cause high-brightness areas to appear, increasing the reflection contrast between scratches and normal surfaces. When the shortest color neighbor distance is large, it means that the distance between the two scratch color grids is far, indicating that the two scratch points may be independent or noise points caused by changes in light reflection. There is no obvious connectivity between them and no scratches will be generated. On the contrary, when the shortest color neighbor distance is small, it means that the distance between the two scratch color grids is very close, then the two points are actually or visually connected, forming a scratch area. In order to avoid interference from noise points or misjudgment of scratches, it is necessary to calculate the shortest distance of scratches through the shortest color neighbor distance for deeper scratch identification.
[0061] Further, in step S400, obtaining the shortest distance of visible traces by the shortest color-displaying neighbor distance includes:
[0062] S401, use the obtained KS(j) as an element of the color-displaying shortest neighbor distance sequence SP, then the color-displaying shortest neighbor distance sequence SP is composed of n color-displaying shortest neighbor distances, namely {KS(1), KS(2), ..., KS(j)}, KS(j) is the j-th color-displaying shortest neighbor distance in the color-displaying shortest neighbor distance sequence SP, j is a sequence number, and the value range of j is j=1, 2, ..., n. The average value of all the color-displaying shortest neighbor distances in the color-displaying shortest neighbor distance sequence SP is KM; and obtain the standard deviation of all the color-displaying shortest neighbor distances in the color-displaying shortest neighbor distance sequence SP.
[0063] S402, internally classify the color rendering shortest neighbor distance sequence according to the standard deviation of all color rendering shortest neighbor distances in the color rendering shortest neighbor distance sequence SP; the color rendering shortest neighbor distance less than or equal to the value of KM minus the standard deviation is classified as the first color rendering shortest neighbor distance range Distan1; the color rendering shortest neighbor distance greater than the mean value minus the standard deviation and less than the mean value plus the standard deviation is classified as the second color rendering shortest neighbor distance range Distan2; the color rendering shortest neighbor distance greater than or equal to the mean value plus the standard deviation is classified as the third color rendering shortest neighbor distance range Distan3;
[0064] Specifically, the first color display shortest neighbor distance range Distan1 includes all color display shortest neighbor distances less than or equal to KM minus the standard deviation, and the distances between these grids are short, indicating that these grids clustered together represent scratches with more obvious color display; the second color display shortest neighbor distance range Distan2 includes those color display shortest neighbor distances between KM minus the standard deviation and KM plus the standard deviation. The distances between these grids are within a reasonable range and belong to the relatively less obvious part of the scratch color display; the third color display shortest neighbor distance range Distan3 includes all color display shortest neighbor distances greater than or equal to KM plus the standard deviation, and the distances between these grids are larger, which means that these grids are the edge parts of the scratches, sparsely distributed scratch points, or grids with abnormal color display caused by interference factors such as light reflection and stains.
[0065] S403, the distance ranges of the first color rendering shortest neighbor distance range Distan1, the second color rendering shortest neighbor distance range Distan2, and the third color rendering shortest neighbor distance range Distan3 are recorded as [s, m1], [m2, x1], and [x2, p], respectively, where s represents the lower limit (minimum value) of the first color rendering shortest neighbor distance range Distan1; this value is the starting point of the scratch shortest neighbor distance range, indicating the minimum color rendering distance. m1 represents the upper limit (maximum value) of the first color rendering shortest neighbor distance range Distan1, which is the maximum distance between color rendering grids with greater scratch severity, indicating the distance value of more serious scratches. m2 represents the lower limit (minimum value) of the second color rendering shortest distance range Distan2, i.e., the starting value of the shortest distance of relatively minor scratches; x1 represents the upper limit (maximum value) of the second color rendering shortest distance range Distan2, i.e., the maximum distance value of relatively minor scratches; x2 represents the lower limit (minimum value) of the third color rendering shortest distance range Distan3, corresponding to the starting point of the shortest distance of minor scratches. p represents the upper limit (maximum value) of the third color rendering shortest distance range Distan3, i.e., the maximum distance value of very minor or almost invisible scratches.
[0066] S404, calculating a first visible trace shortest distance Sdistan1 and a second visible trace shortest distance Sdistan2 through the first color display shortest neighbor distance range Distan1, the second color display shortest neighbor distance range Distan2, and the third color display shortest neighbor distance range Distan3;
[0067] Wherein Sdistan1 is the maximum value m1 in the first color rendering shortest neighbor distance range X1 minus the minimum distance range difference, wherein the minimum neighbor distance range difference is the product of m2 and the neighbor distance stability balance ratio, wherein the neighbor distance stability balance ratio is the ratio of m1×sk to m2×skp; wherein Sdistan2 is the maximum value m1 in the first color rendering shortest neighbor distance range X1 plus the maximum neighbor distance range difference, wherein the maximum neighbor distance range difference is the product of m2 and the neighbor distance abnormal balance ratio, wherein the neighbor distance abnormal balance ratio is the ratio of x1×sk to (x2+x1)×skp;
[0068] Among them, the first visible scratch shortest distance Sdistan1 is used to identify the minimum color-displaying shortest neighbor distance of more obvious and serious scratches, and the second visible scratch shortest distance Sdistan2 is used to identify the minimum color-displaying shortest neighbor distance of scratches that are less obvious but still need attention; sk is the median of the grayscale values of all grids in the first grayscale image, and skp is the grayscale value of the scratch.
[0069] The beneficial effects of this step are: Sdistan1 and Sdistan2 are obtained by calculating the statistical characteristics based on the shortest neighbor distance of color display, which can help identify areas with defects that significantly affect product function and appearance; and Sdistan2 can ensure that even minor flaws can be monitored. This acquisition not only improves the accuracy of detection, but also allows detailed analysis under different quality standards; or companies can further flexibly adjust the scratch tolerance through Sdistan1 and Sdistan2 according to product positioning and user needs, so as to achieve more targeted quality management.
[0070] S405, calculating the shortest visible trace distance SD by using the first visible trace distance Sdistan1 and the second visible trace distance Sdistan2;
[0071] Specifically, the method for calculating the shortest visible trace distance SD by using the first visible trace distance Sdistan1 and the second visible trace distance Sdistan2 is:
[0072]
[0073] Among them, the shortest scratch distance SD is the shortest neighbor distance of the scratch. It is a value based on Sdistan1 and Sdistan2, which helps to determine the position of the scratch in the detection image and the shortest distance of its color display characteristics; s represents the lower limit of the first color display shortest neighbor distance range Distan1, and m1 represents the upper limit of the first color display shortest neighbor distance range Distan1. It is the trace coefficient obtained by the first shortest trace distance and the second shortest trace distance, which represents the trace ratio under slight defect traces; by multiplying the sum of the upper and lower limits (s+m1) of the first color rendering shortest adjacent distance range Distan1 by the trace ratio, it is possible to obtain a distance value that can detect scratches with high accuracy.
[0074] The beneficial effects of this step are: although coaxial light source illumination can provide a uniform light source, minute scratches on the lens surface may still cause blurred or unclear images due to changes in light reflection. In this case, by calculating the shortest visible scratch distance SD, the actual position and range of the scratch can be determined more accurately based on the actual color rendering proximity difference, especially for relatively minor scratches, which can avoid interference from noise or light reflection; and the strong illumination provided by the coaxial light source may cause high-brightness areas to appear, increasing the reflection contrast between the scratches and the normal surface, so that tiny scratches may be over-magnified. In this case, the shortest visible scratch distance SD can enhance the sensitivity to lens scratches under the coaxial light source by finding a balance between obvious scratches and tiny scratches, ensuring comprehensive monitoring of different types of scratches, identifying scratches that really need attention, and preventing excessive detection.
[0075] In step S500, the real scratch grids are screened out by the shortest distance of scratch display, and the scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance, including:
[0076] The grids in the scratch color grid whose KS(j) is less than SD are recorded as real scratch grids, and the center point of each real scratch grid is connected with the center point of its corresponding color-displayed shortest neighboring distance through a line segment. All grids passed by the line segment in the first grayscale image are recorded as scratch distribution grids, and the area composed of all scratch distribution grids is recorded as the scratch area.
[0077] Figure 2 Shown is the structural diagram of the optical lens surface scratch detection system.
[0078] Reference Figure 2 The present invention also proposes an optical lens surface scratch detection system 20, the optical lens surface scratch detection system 20 comprises: a processor, a memory and a computer program stored in the memory and executable on the processor, the processor implements the steps in an optical lens surface scratch detection method when executing the computer program, the optical lens surface scratch detection system 20 runs on a desktop computer, a notebook, a PDA and a computing device in a cloud data center.
[0079] The detection system comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to run in the following units of the detection system:
[0080] A collection unit 21, used to obtain an image of the lens surface;
[0081] A conversion unit 22, used for graying the image of the lens surface to obtain a lens grayscale image;
[0082] A loading unit 23, used to obtain a scratch color development grid according to the lens grayscale image, and obtain the shortest color development neighbor distance through the scratch color development grid;
[0083] A calculation unit 24, used for obtaining the shortest distance of the trace through the shortest color-developed neighbor distance;
[0084] The display unit 25 is used to select the real scratch grids according to the shortest scratch display distance, and connect the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance to obtain the scratch area.
[0085] The optical lens surface scratch detection system described above can be run on computing devices such as desktop computers, notebooks, PDAs, and cloud servers. The optical lens surface scratch detection system described above can include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the example described above is merely an example of an optical lens surface scratch detection system 20 and does not constitute a limitation on an optical lens surface scratch detection system 20. The system can include more or fewer components than the example, or a combination of certain components, or different components. For example, the optical lens surface scratch detection system described above can also include input and output devices, network access devices, buses, etc.
[0086] By executing the optical lens surface scratch detection method through the optical lens surface scratch detection system 20, random noise in the image can be effectively suppressed, ensuring that the real grayscale value of the scratch area is accurately reflected, thereby 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 specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0088] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0089] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0090] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0091] In addition, the terms "first", "second", etc. used in the embodiments of the present invention are only used for descriptive purposes and should not be understood as indicating or implying relative importance, or implicitly indicating the number of technical features indicated in the present embodiment. Therefore, the features defined by the terms "first", "second", etc. in the embodiments of the present invention can explicitly or implicitly indicate that the embodiment includes at least one of the features. In the description of the present invention, the word "multiple" means at least two or two or more, such as two, three, four, etc., unless otherwise clearly and specifically defined in the embodiments.
[0092] In the present invention, unless otherwise clearly specified or limited in the embodiments, the terms "installed", "connected", "connected" and "fixed" etc. in the embodiments should be understood in a broad sense. For example, the connection can be a fixed connection, a detachable connection, or an integrated connection. It can be understood that 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 connection of two elements, or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific implementation situation.
[0093] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0094] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary 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 comprises the following steps: S100, acquiring an image of the lens surface; S200, graying the image of the lens surface to obtain a lens grayscale image; S300, obtaining a scratch color grid according to the lens grayscale image, and obtaining the shortest color neighbor distance through the scratch color grid; S400, obtain the shortest distance of visible traces through the shortest color-displaying neighbor distance; S500, selecting the real scratch grids by the shortest scratch display distance, and connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance 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: Acquiring an image of the lens surface in step S100 includes: using a lighting unit based on a coaxial light source, capturing the imaging 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 captures the lens image by projecting light onto the lens and detecting reflected light, and the sensor collects the image of the lens through an optical method 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 S200, graying the image of the lens surface to obtain a lens grayscale image includes: The image of the lens surface is gray-scaled, and the image of the lens surface after gray-scaled processing is recorded as the first gray-scale image. The first gray-scale image is grid-divided by a grid division algorithm, and the grid size is 1 / 800 of the first gray-scale image. The first gray-scale image is divided into K grids, where K=800, s(i) represents the gray-scale value of the i-th grid of the first gray-scale image, the value of i is [1, K], and K is the number of grids after the first gray-scale image is divided; the median of the gray-scale values in each grid in s(i) is obtained and recorded as sk, and the average of the gray-scale values in each grid in s(i) is obtained and recorded as skm; the scratch gray-scale value skp is calculated by the first equation; the scratch gray-scale value is the gray-scale value for judging whether it is a scratch color in the gray-scale difference caused by the brightness difference between the scratch of the lens and the normal area of the lens under the lighting unit based on the coaxial light source.
4. The method for detecting scratches on the surface of an optical lens according to claim 3, characterized in that: In step S300, obtaining a scratch color grid according to the lens grayscale image, and obtaining the shortest color neighbor distance through the scratch color grid includes: Get the grids in s(i) whose grayscale values are greater than skp and record them as scratch-colored grids, use k(j) to represent the j-th scratch-colored grid in the first grayscale image, and use KS(j) to represent the shortest color-colored neighbor distance of the j-th scratch-colored grid. The value of j is [1, G], and G is the number of scratch-colored grids. The shortest color-colored neighbor distance of the j-th scratch-colored grid is the length of the shortest line segment among the line segments between the grid center point of the j-th scratch-colored grid and the center points of all scratch-colored grids.
5. The method for detecting scratches on the surface of an optical lens according to claim 1, characterized in that: In step S400, obtaining the shortest distance of visible traces by using the shortest color-displaying neighbor distance includes: S401, using the obtained KS(j) as an element of a color display shortest neighbor distance sequence SP, wherein the color display shortest neighbor distance sequence SP is composed of n color display shortest neighbor distances, namely {KS(1), KS(2), ..., KS(j)}, KS(j) is the j-th color display shortest neighbor distance in the color display shortest neighbor distance sequence SP, j is a sequence number, and the value range of j is j=1, 2, ..., n, and the average value of all the color display shortest neighbor distances in the color display shortest neighbor distance sequence SP is KM; and obtaining the standard deviation of all the color display shortest neighbor distances in the color display shortest neighbor distance sequence SP; S402, internally classify the color rendering shortest neighbor distance sequence according to the standard deviation of all color rendering shortest neighbor distances in the color rendering shortest neighbor distance sequence SP; the color rendering shortest neighbor distance less than or equal to the value of KM minus the standard deviation is classified as the first color rendering shortest neighbor distance range Distan1; the color rendering shortest neighbor distance greater than the mean value minus the standard deviation and less than the mean value plus the standard deviation is classified as the second color rendering shortest neighbor distance range Distan2; the color rendering shortest neighbor distance greater than or equal to the mean value plus the standard deviation is classified as the third color rendering shortest neighbor distance range Distan3; S403, recording the distance ranges of the first color rendering shortest neighbor distance range Distan1, the second color rendering shortest neighbor distance range Distan2, and the third color rendering shortest neighbor distance range Distan3 as [s, m1], [m2, x1], and [x2, p], respectively; S404, calculating a first visible trace shortest distance Sdistan1 and a second visible trace shortest distance Sdistan2 through the first color display shortest neighbor distance range Distan1, the second color display shortest neighbor distance range Distan2, and the third color display shortest neighbor distance range Distan3; S405, calculating the shortest visible trace distance SD by using the first visible trace distance Sdistan1 and the second visible trace distance Sdistan2.
6. 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 grids are screened out by the shortest distance of scratch display, and the scratch area is obtained by connecting the center point of each real scratch grid with the center point of its corresponding grid with the shortest color display distance, including: The grids in the scratch color grid whose KS(j) is less than SD are recorded as real scratch grids, and the center point of each real scratch grid is connected with the center point of its corresponding color-displayed shortest neighboring distance through a line segment. All grids passed by the line segment in the first grayscale image are recorded as scratch distribution grids, and the area composed of all scratch distribution grids is recorded as the scratch area.
7. An optical lens surface scratch detection system, characterized in that: The optical lens surface scratch detection system comprises: a processor, a memory, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps in the optical lens surface scratch detection method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Optical lens surface scratch detection method based on U _ Net network
CN111551350A
Scratch identification method for full-automatic integrated automobile painting repair
CN116958645A
Seamless steel tube quality detection method based on image processing
CN118334028A
Cited By
Glass lens surface scratch detection method and system
CN120446165A
Paper identification and detection method
CN120490124A
A paper identification detection method
CN120490124B
