A method and system for detecting surface defects of plastic optical lenses

Through phase consistency multi-scale edge detection and VGG16 deep learning model combined with a 2D measuring instrument, the error detection and missed detection problems of surface defect detection of plastic optical lenses are solved, and high-precision and efficient defect identification and measurement are achieved.

CN119540151BActive Publication Date: 2025-08-29WUXI XINJUHONG INTELLIGENT TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411508484.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-08-29
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

In the prior art, the detection of surface defects of plastic optical lenses has problems such as high error detection rate, high leakage detection rate and low detection efficiency. In particular, the detection accuracy of complex, small or fuzzy defects is low and is easily affected by environmental factors.

Method used

The phase consistency multi-scale edge detection algorithm is used to divide optical zones and non-optical zones with elliptical models, and features are extracted through local contrast enhancement and Laplace operators, defect detection is performed using VGG16 deep learning model, and the length and width of defect areas are obtained by combining a two-dimensional measuring instrument.

Benefits of technology

It improves the accuracy and consistency of defect detection, reduces the rate of error detection and miss detection, can more accurately identify defect characteristics in complex backgrounds, and provides high-precision defect size measurements, improving the comprehensiveness and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540151B_ABST
    Figure CN119540151B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for detecting surface defects in plastic optical lenses, comprising: S1: performing phase-consistent multi-scale edge detection on a plastic lens image to obtain a set of plastic lens edge point coordinates; S2: fitting an elliptical model based on the edge point set, using the fitting result to divide the optical zone into a non-optical zone, and generating an optical zone mask; S3: enhancing and feature-extracting pixels within the optical zone, and screening potential defect areas through binarization to obtain a potential defect map, and using a quadratic element measurement instrument to obtain the length and width of the defect areas; S4: constructing a defect detection model based on VGG16, and using labeled training samples to train and optimize the defect detection model to obtain an optimized model; S5: using the optimized model to detect plastic lens images without labeled defect categories to obtain defect detection results. The present invention can reduce false detections and missed detections of surface defects in plastic optical lenses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of lens surface defect detection, and in particular to a method and system for detecting surface defects of a plastic optical lens. Background Art

[0002] With the widespread application of optical products in consumer electronics, automobiles, medical devices, and precision instruments, the quality requirements for optical lenses are becoming increasingly stringent. Plastic optical lenses, due to their advantages such as lightness, ease of processing, and low cost, are gradually replacing traditional glass lenses and becoming the mainstream in the market. However, due to the softness and susceptibility of plastic materials to contamination, defects such as bubbles, scratches, cracks, and impurities are inevitable during the production process. Therefore, how to efficiently and accurately detect these defects and ensure product quality has become a key research topic in the industry.

[0003] Currently, the detection of surface defects in plastic optical lenses in the market primarily relies on manual inspection and traditional image processing methods. Traditional inspection methods primarily rely on manual operation, visually inspecting the surface defects of optical lenses. However, manual inspection is subject to strong subjectivity, low detection efficiency, and fatigue, making it difficult to ensure consistent inspection in mass production. Furthermore, because some minor defects are difficult to detect with the naked eye, the missed detection rate is high. Some inspection solutions use simple image processing techniques such as edge detection, histogram analysis, and binarization. These methods are effective for detecting simple, obvious defects, but their detection accuracy is lower for complex, minor, or ambiguous defects. These methods are often susceptible to environmental factors such as changes in lighting and lens position deviation, leading to false detections and missed detections. Summary of the Invention

[0004] In view of this, the present invention provides a method for detecting surface defects of plastic optical lenses, aiming to reduce false detection and missed detection of surface defects of plastic optical lenses and provide a reliable solution for quality inspection of plastic optical lenses.

[0005] To achieve the above objectives, the present invention provides a method for detecting surface defects of a plastic optical lens, comprising the following steps:

[0006] S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain the coordinate set of the edge points of the plastic lens;

[0007] S2: Fit an ellipse model based on the edge point set, use the fitting result to divide the optical area and non-optical area, and generate an optical area mask;

[0008] S3: Enhance and extract features of pixels in the optical area, and screen potential defect areas through binarization to obtain a potential defect map. Use a two-dimensional measuring instrument to obtain the length and width of the defect area.

[0009] S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model;

[0010] S5: Use the optimized model to detect plastic lens images without defect categories to obtain defect detection results;

[0011] As a further improvement method of the present invention:

[0012] Optionally, performing phase consistency multi-scale edge detection on the plastic lens image in step S1 to obtain a set of plastic lens edge point coordinates includes:

[0013] S11: Preprocess the plastic lens image I using Gaussian filtering, specifically:

[0014]

[0015] Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, …, 0, …, a-1, a, j = -a, -a+1, …, 0, …, a-1, a; a is the radius of the Gaussian kernel; x and y are the horizontal and vertical coordinates of the plastic lens image pixel, respectively; I(xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); For preprocessed images The pixel value at pixel location (x,y);

[0016] S12: Perform edge point extraction based on phase consistency:

[0017] S121: Preprocessed image Perform a multi-scale Fourier transform, specifically:

[0018]

[0019] Where M and N are the horizontal and vertical lengths of the plastic lens image respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v);

[0020] The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically:

[0021]

[0022] Among them, f n is the center frequency of the nth scale, is the scale number; is the bandwidth control parameter; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain;

[0023] S122: Calculate multi-scale phase map:

[0024] Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically:

[0025]

[0026] in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase diagram θ of the nth scale n The phase value at the pixel location (x,y);

[0027] S123: Calculate phase consistency:

[0028] The phase consistency result graph is calculated using the multi-scale phase map, specifically:

[0029]

[0030] in, is the average phase value of the phase map at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result map PC at the pixel position (x, y); W n (x,y) is the weight of the pixel position (x,y) at the nth scale, specifically:

[0031]

[0032] S124: Extract edge points:

[0033] Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically:

[0034]

[0035] Where T is the edge point extraction threshold; E is the coordinate set of the edge points of the plastic lens; are the horizontal and vertical coordinates of the kth edge point; The phase consistency result map PC is at the pixel position The pixel value at .

[0036] Optionally, in step S2, fitting an ellipse model based on the edge point set, dividing the optical zone and the non-optical zone using the fitting result, and generating an optical zone mask include:

[0037] S21: Fitting an ellipse model using the plastic lens edge point coordinates:

[0038] Using the least squares method, the sum of squared errors of the edge points of the plastic lens is used as the optimization target, specifically:

[0039]

[0040] Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively;

[0041] The error function Z is used to calculate the parameters of the ellipse model Find the partial derivatives of a and b, and set the partial derivatives to 0 to solve for the parameters of the fitted elliptical model a' and b'; where is the center coordinate of the fitted ellipse model; a' and b' are the major axis and minor axis of the fitted ellipse model respectively;

[0042] S22: Divide the inner and outer regions of the fitted elliptical model to obtain the optical zone mask:

[0043] S221: Constructing the conditions for determining regional division:

[0044] Through the fitted ellipse model, if the pixel is in the fitted ellipse model, it is in the optical area, otherwise it is in the non-optical area, and the pixel set R in the optical area is obtained. optical ;

[0045] S222: Generate optical zone mask:

[0046] The pixel values ​​of the pixels in the optical zone are set to 1, and the pixel values ​​of the pixels in the non-optical zone are set to 0 to generate the optical zone mask.

[0047] Optionally, in step S3, pixels in the optical zone are enhanced and features are extracted, and potential defect areas are screened by binarization to obtain a potential defect map, and the length and width of the defect area are obtained using a quadratic element measuring instrument, including:

[0048] S31: Perform image enhancement:

[0049] The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is:

[0050]

[0051] Among them, I enh (x,y) is the enhanced image I enh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a 5×5 local window centered at the pixel position (x, y) of the plastic lens image I; Mask(x, y) is the pixel value of the optical zone mask at the pixel position (x, y);

[0052] S32: Perform feature extraction:

[0053] Use the Laplace operator to extract features from the enhanced image and obtain the Laplace feature map I hp ;

[0054] S33: Use binarization to screen potential defect areas:

[0055] Laplace characteristic map I hp Apply the threshold τ for binarization, specifically:

[0056]

[0057] Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y);

[0058] S34: Measure the length and width of the defect area:

[0059] The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

[0060] Optionally, in step S4, a defect detection model is constructed based on VGG16, and the labeled training samples are used to train and optimize the defect detection model to obtain an optimized model, including:

[0061] S41: Building a defect detection model:

[0062] The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input and obtains the input feature vector, specifically:

[0063] Fea VGG =VGG16([I,B])

[0064] Among them, Fea VGGis the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension;

[0065] The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and with Fea VGG Add together to obtain the fusion feature vector Fea fusion ;

[0066] The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically:

[0067] P=Softmax(MLP(Fea fusion ))

[0068] Where P is a C-dimensional defect probability vector, where each dimension of the vector corresponds to the probability of a different defect category, and C is the total number of categories; Softmax is a normalized exponential function; MLP is the fully connected layer of the VGG16 architecture;

[0069] S42: Training model:

[0070] The model is trained using the cross entropy loss function, which is:

[0071]

[0072] Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model;

[0073] The stochastic gradient descent method is used to iteratively optimize the parameters of the defect detection model to reduce the loss value until the set number of iterations is reached to obtain the optimized model.

[0074] Optionally, in step S5, the optimized model is used to detect the plastic lens image without the defect category labeled to obtain the defect detection result, including:

[0075] S51: Get the model prediction results:

[0076] The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the quadratic element measuring instrument are input into the optimized model to obtain the probability vector predicted by the model.

[0077] S52: Determine the final detection category:

[0078] By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically:

[0079]

[0080] in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

[0081] The present invention also discloses a system for detecting surface defects of plastic optical lenses, comprising:

[0082] Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images;

[0083] Optical zone division module: Fitting an ellipse model based on a set of edge points, and using the fitting results to divide the optical zone into the non-optical zone;

[0084] Potential defect extraction module: Enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain a potential defect map. A quadratic element measuring instrument is used to obtain the length and width of the defect area.

[0085] Model construction module: Build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model;

[0086] Model application module: Use the optimized model to detect plastic lens images without labeled defect categories;

[0087] Beneficial effects:

[0088] This invention utilizes a phase-consistency multi-scale edge detection algorithm to extract edge information from plastic lenses in complex backgrounds, ensuring accurate demarcation between the optical and non-optical areas. Traditional image processing algorithms are often susceptible to noise interference, leading to false detections and missed detections. However, this invention significantly improves detection accuracy by optimizing deep learning models and integrating geometric features. Furthermore, using a quadratic measuring instrument to obtain the precise dimensions of defect areas allows the model to more comprehensively understand defect characteristics, further reducing detection errors.

[0089] This method incorporates a quadratic measuring instrument into the defect detection process to measure key geometric features such as the length and width of the defect area. These features, along with image information, are then fed into the VGG16 model for classification. Compared to detection methods that rely solely on image information, the integration of multidimensional features enhances the model's discriminative capabilities and enables more accurate classification of complex defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0090] Figure 1 1 is a flow chart of a method for detecting surface defects of a plastic optical lens according to an embodiment of the present invention;

[0091] Figure 2 Schematic diagram of defects according to an embodiment of the present invention, wherein (a) shows white spots / black spots, (b) shows dirt, and (c) shows flow marks. DETAILED DESCRIPTION

[0092] The present invention will be further described below with reference to the accompanying drawings, but the present invention is not limited in any way. Any changes or substitutions made based on the teachings of the present invention fall within the scope of protection of the present invention.

[0093] Example 1: A method for detecting surface defects of a plastic optical lens, such as Figure 1 As shown, the following steps are included:

[0094] S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain the coordinate set of the edge points of the plastic lens:

[0095] S11: Preprocess the plastic lens image I using Gaussian filtering, specifically:

[0096]

[0097] Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, ..., 0, ..., a-1, a, j = -a, -a+1, ..., 0, ..., a-1, a; a is the radius of the Gaussian kernel, which is 3 in this embodiment; x and y are the horizontal and vertical coordinates of the plastic lens image pixel, respectively; I(xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); For preprocessed images The pixel value at pixel location (x,y);

[0098] S12: Perform edge point extraction based on phase consistency:

[0099] S121: Preprocessed image Perform a multi-scale Fourier transform, specifically:

[0100]

[0101] Where M and N are the horizontal and vertical lengths of the plastic lens image respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v);

[0102] The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically:

[0103]

[0104] Among them, f n is the center frequency of the nth scale, is the scale number, in this embodiment f1=0.05, f2=0.1, f3=0.2; is the bandwidth control parameter, which is 0.8 in this embodiment; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain;

[0105] S122: Calculate multi-scale phase map:

[0106] Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically:

[0107]

[0108] in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase diagram θ of the nth scale n The phase value at the pixel location (x,y);

[0109] S123: Calculate phase consistency:

[0110] The phase consistency result graph is calculated using the multi-scale phase map, specifically:

[0111]

[0112] in, is the average phase value of the phase map at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result map PC at the pixel position (x, y); W n(x,y) is the weight of the pixel position (x,y) at the nth scale, specifically:

[0113]

[0114] S124: Extract edge points:

[0115] Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically:

[0116]

[0117] Wherein, T is the edge point extraction threshold, which is 0.2 in this embodiment; E is the set of edge point coordinates of the plastic lens; are the horizontal and vertical coordinates of the kth edge point; The phase consistency result map PC is at the pixel position The pixel value at .

[0118] This step preprocesses the image of the plastic lens using Gaussian filtering to remove noise, improving the stability of edge detection. The subsequent phase congruency calculation allows accurate identification of key edges even when the image contains uneven brightness, reflections, or localized blur. Furthermore, a multi-scale Fourier transform combined with phase information analysis effectively mitigates noise interference, making detection results more reliable.

[0119] This step uses a multi-scale Fourier transform, enabling edge detection to simultaneously capture features at different scales. High-frequency scales focus on details such as tiny scratches or cracks, while low-frequency scales capture overall contours and large defects. Fusion of multi-scale information using phase congruence ensures that edge features in complex structures are not overlooked, thereby comprehensively improving detection results.

[0120] S2: Fit an ellipse model based on the edge point set, use the fitting result to divide the optical area and non-optical area, and generate an optical area mask:

[0121] S21: Fitting an ellipse model using the plastic lens edge point coordinates:

[0122] Using the least squares method, the sum of squared errors of the edge points of the plastic lens is used as the optimization target, specifically:

[0123]

[0124] Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively;

[0125] The error function Z is used to calculate the parameters of the ellipse model Find the partial derivatives of a and b, and set the partial derivatives to 0 to solve for the parameters of the fitted elliptical model a' and b'; where is the center coordinate of the fitted ellipse model; a' and b' are the major axis and minor axis of the fitted ellipse model respectively;

[0126] S22: Divide the inner and outer regions of the fitted elliptical model to obtain the optical zone mask:

[0127] S221: Constructing the conditions for determining regional division:

[0128] The pixels are divided into optical and non-optical areas by the fitted ellipse model, specifically:

[0129]

[0130] Among them, R optical is the pixel set of the optical zone;

[0131] S222: Generate optical zone mask:

[0132] The pixel values ​​of the pixels in the optical area are set to 1, and the pixel values ​​of the pixels in the non-optical area are set to 0 to generate the optical area mask. Specifically:

[0133]

[0134] Wherein, Mask(x,y) is the pixel value of the optical area mask Mask at the pixel position (x,y).

[0135] This step accurately describes the edge morphology of plastic lenses by fitting an elliptical model using the least squares method. This model is suitable for the shape characteristics of most plastic lenses and helps accurately delineate the optical and non-optical zones. Compared to simple rectangular or circular segmentation methods, the elliptical model more closely fits the actual lens contour, ensuring a more accurate segmentation result.

[0136] S3: Enhance and extract features of pixels in the optical area, and screen potential defect areas through binarization to obtain a potential defect map. Use a two-dimensional measuring instrument to obtain the length and width of the defect area:

[0137] S31: Perform image enhancement:

[0138] The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is:

[0139]

[0140] Among them, I enh (x,y) is the enhanced image Ienh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a local window of 5×5 centered at the pixel position (x, y) of the plastic lens image I;

[0141] S32: Perform feature extraction:

[0142] The Laplace operator is used to extract features from the enhanced image, specifically:

[0143] I hp (x,y)=I enh (x+1,y)+I enh (x-1,y)+I enh (x,y+1)+I enh (x,y-1)-4I enh (x,y)

[0144] Among them, I hp (x,y) is the Laplace characteristic map I hp The pixel value at the pixel position (x, y); I enh (x+1,y),I enh (x-1,y),I enh (x,y+1) and I enh (x,y-1) are the enhanced images I enh The pixel values ​​at pixel locations (x+1,y), (x-1,y), (x,y+1), and (x,y-1);

[0145] S33: Use binarization to screen potential defect areas:

[0146] Laplace characteristic map I hp A threshold τ is applied for binarization. In this embodiment, τ=10, specifically:

[0147]

[0148] Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y);

[0149] S34: Measure the length and width of the defect area:

[0150] The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

[0151] Local contrast enhancement makes subtle textures and brightness variations within the optical zone more apparent. The mean and standard deviation are calculated for each local window, achieving adaptive contrast enhancement. This method effectively mitigates the effects of uneven lighting and overall brightness variations on inspection results, making even the smallest defects easier to identify.

[0152] Measuring the length and width of a defect area using a minimum enclosing rectangle provides highly accurate dimensional information. This method ensures that the measurement results are applicable to irregularly shaped defects and effectively reflects the actual size of the defect, providing reliable data support for quality control.

[0153] S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model:

[0154] S41: Building a defect detection model:

[0155] The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input and obtains the input feature vector, specifically:

[0156] Fea VGG =VGG16([I,B])

[0157] Among them, Fea VGG is the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension;

[0158] The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and with Fea VGG Add together to obtain the fusion feature vector Fea fusion ;

[0159] The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically:

[0160] P=Softmax(MLP(Fea fusion ))

[0161] Where P is a C-dimensional defect probability vector, where each dimension of the vector corresponds to the probability of a different defect category, and C is the total number of categories. In this embodiment, C=4, representing no defect, white spot / black spot, dirt, and flow mark, respectively. Figure 2As shown; Softmax is the normalized exponential function; MLP is the fully connected layer of the VGG16 architecture;

[0162] S42: Training model:

[0163] The model is trained using the cross entropy loss function, which is:

[0164]

[0165] Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model;

[0166] The parameters of the defect detection model are iteratively optimized using the stochastic gradient descent method to reduce the loss value Loss until the set number of iterations is reached to obtain the optimized model. In this embodiment, the number of iterations is 10,000 times.

[0167] Using plastic lens images and potential defect maps as input samples, the model fuses the locally enhanced and feature-extracted information with the original image through channel-wise splicing, improving the model's ability to perceive defect features. Furthermore, by combining the length and width of the defect area, it achieves feature fusion of multimodal data, further improving the comprehensiveness and accuracy of detection.

[0168] Mapping the size information of the defect area to the same dimension as the image feature vector and adding it to the feature vector extracted by VGG16 can enrich the input features of the model. This fusion strategy helps the model better understand the shape, size, and spatial distribution of defects, improving the classification performance of different types of defects.

[0169] S5: Use the optimized model to detect plastic lens images without labeled defect categories and obtain defect detection results:

[0170] S51: Get the model prediction results:

[0171] The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the quadratic element measuring instrument are input into the optimized model to obtain the probability vector predicted by the model.

[0172] S52: Determine the final detection category:

[0173] By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically:

[0174]

[0175] in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

[0176] Example 2: The present invention also discloses a system for detecting surface defects of plastic optical lenses, comprising the following five modules:

[0177] Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images;

[0178] Optical zone division module: Fitting an ellipse model based on a set of edge points, and using the fitting results to divide the optical zone into the non-optical zone;

[0179] Potential defect extraction module: Enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain a potential defect map. A quadratic element measuring instrument is used to obtain the length and width of the defect area.

[0180] Model construction module: Build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model;

[0181] Model application module: Use the optimized model to detect plastic lens images without labeled defect categories.

[0182] It should be noted that the serial numbers of the above-mentioned embodiments of the present invention are for descriptive purposes only and do not represent the advantages or disadvantages of the embodiments. In addition, the terms "including", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "including a ..." does not exclude the presence of other identical elements in the process, device, article or method comprising the element.

[0183] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0184] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for detecting surface defects of a plastic optical lens, characterized in that: The following steps are involved: S1: Perform phase consistency multi-scale edge detection on the plastic lens image to obtain the coordinate set of the edge points of the plastic lens. The step S1 includes: S11: pre-processing the plastic lens image I using Gaussian filtering, S12: performing edge point extraction based on phase consistency, The step S12 includes the following steps: S121: Preprocessed image Perform a multi-scale Fourier transform, specifically: Where M and N are the horizontal and vertical lengths of the plastic lens image respectively; δ is an imaginary unit, satisfying δ 2 = -1; u and v are the frequency domain positions in the horizontal and vertical directions respectively; F(u,v) is the pixel value of the Fourier transform result image F at the frequency domain position (u,v); The multi-scale Fourier transform result image is extracted based on the Fourier transform result image, specifically: Among them, f n is the center frequency of the nth scale, is the scale number; is the bandwidth control parameter; F n (u,v) is the Fourier transform result image F at the nth scale n The pixel value at position (u,v) in the frequency domain, S122: Calculate multi-scale phase map, S123: Calculate phase consistency, S124: extract edge points; S2: Fit an ellipse model based on the edge point set, use the fitting result to divide the optical area and non-optical area, and generate an optical area mask; S3: Enhance and extract features of pixels in the optical area, and screen potential defect areas through binarization to obtain a potential defect map. Use a two-dimensional measuring instrument to obtain the length and width of the defect area. S4: Build a defect detection model based on VGG16, use the labeled training samples to train and optimize the defect detection model, and obtain the optimized model; S5: Use the optimized model to detect plastic lens images without labeled defect categories to obtain defect detection results.

2. The method for detecting surface defects of a plastic optical lens according to claim 1, wherein: The step S1 includes the following steps: S11: Preprocess the plastic lens image I using Gaussian filtering, specifically: Wherein, π is the circumference of a circle; e is a natural constant; σ is the standard deviation of the Gaussian kernel; i = -a, -a+1, ..., 0, ..., a-1, a; j = -a, -a+1, ..., 0, ..., a-1, a; a is the radius of the Gaussian kernel; x and y are the horizontal and vertical coordinates of the pixel of the plastic lens image I, respectively; I(xi, yj) is the pixel value of the plastic lens image I at the pixel position (xi, yj); For preprocessed images The pixel value at pixel location (x,y).

3. The method for detecting surface defects of a plastic optical lens according to claim 2, wherein: The step S12 includes the following steps: S122: Calculate multi-scale phase map: Perform inverse Fourier transform on the multi-scale Fourier transform result image to obtain a multi-scale phase image, specifically: in, is the inverse Fourier transform; arg is the complex phase extraction function; θ n (x,y) is the phase diagram θ of the nth scale n The phase value at the pixel location (x,y); S123: Calculate phase consistency: The phase consistency result graph is calculated using the multi-scale phase map, specifically: in, is the average phase value of the phase map at the pixel position (x, y) under all scales; PC(x, y) is the pixel value of the phase consistency result map PC at the pixel position (x, y); W n (x,y) is the weight of the pixel position (x,y) at the nth scale, specifically: S124: Extract edge points: Filter the pixels in the phase consistency result map PC to obtain the edge point set, specifically: Where T is the edge point extraction threshold; E is the coordinate set of the edge points of the plastic lens; are the horizontal and vertical coordinates of the kth edge point; The phase consistency result image PC is at the pixel position The pixel value at .

4. The method for detecting surface defects of a plastic optical lens according to claim 2, wherein: The step S2 includes the following steps: S21: Fitting an ellipse model using the plastic lens edge point coordinates: Using the least squares method, the sum of squared errors of the edge points of the plastic lens is used as the optimization target, specifically: Where Z is the error function; |E| is the total number of edge points of the plastic lens in E; is the center coordinate of the ellipse model; a and b are the major axis and minor axis of the ellipse model respectively; The parameters of the ellipse model are Take the partial derivatives of a and b and set them to 0 to solve for the parameters of the fitted ellipse model. a' and b'; where is the center coordinate of the fitted ellipse model; a' and b' are the major axis and minor axis of the fitted ellipse model respectively; S22: Divide the inner and outer regions of the fitted elliptical model to obtain the optical zone mask: S221: Constructing the conditions for determining regional division: Through the fitted ellipse model, if the pixel is in the fitted ellipse model, it is in the optical area, otherwise it is in the non-optical area, and the pixel set R in the optical area is obtained. optical ; S222: Generate optical zone mask: The pixel values ​​of the pixels in the optical zone are set to 1, and the pixel values ​​of the pixels in the non-optical zone are set to 0 to generate the optical zone mask.

5. The method for detecting surface defects of a plastic optical lens according to claim 4, wherein: The step S3 includes the following steps: S31: Perform image enhancement: The pixels in the optical zone of the plastic lens image I are enhanced using a local contrast enhancement method, wherein the local contrast enhancement method is: Among them, I enh (x,y) is the enhanced image I enh The pixel value at the pixel position (x, y); mean 5×5 (x,y) and std 5×5 (x, y) are the mean and standard deviation of the pixel values ​​in a 5×5 local window centered at the pixel position (x, y) of the plastic lens image I; Mask(x, y) is the pixel value of the optical zone mask at the pixel position (x, y); S32: Perform feature extraction: Use the Laplace operator to extract features from the enhanced image and obtain the Laplace feature map I hp ; S33: Use binarization to screen potential defect areas: Laplace characteristic map I hp Apply the threshold τ for binarization, specifically: Wherein, B(x,y) is the pixel value of the potential defect image B at the pixel position (x,y); S34: Measure the length and width of the defect area: The length and width of the defect area are obtained using a two-dimensional measuring instrument, where the length and width of the defect area are the long side and the short side of the minimum circumscribed rectangle containing the defect area.

6. The method for detecting surface defects of a plastic optical lens according to claim 5, wherein: The step S4 includes the following steps: S41: Building a defect detection model: The VGG16 architecture is used as the defect detection model; VGG16 uses the plastic lens image I and the potential defect map B as input and obtains the input feature vector, specifically: Fea VGG =VGG16([I,B]) Among them, Fea VGG is the input feature vector, obtained before the fully connected layer of the VGG16 architecture, with a dimension of 4096; [I, B] is the input sample obtained by concatenating the plastic lens image I and the potential defect image B in the channel dimension; The length and width of the defect area are input into a separate fully connected layer and mapped to the input feature vector Fea VGG Same feature dimension and with Fea VGG Add together to obtain the fusion feature vector Fea fusion ; The fusion feature vector Fea fusion Input to the fully connected layer of the VGG16 architecture and use the normalized exponential function to calculate the defect probability vector, specifically: P=Softmax(MLP(Fea fusion )) Where P is a C-dimensional defect probability vector, where each dimension of the vector corresponds to the probability of a different defect category, and C is the total number of categories; Softmax is a normalized exponential function; MLP is the fully connected layer of the VGG16 architecture; S42: Training model: The model is trained using the cross entropy loss function, which is: Where Loss is the loss value; q is the sample number, q = 1, 2, ..., Q, Q is the number of training samples; cls is the category number, cls = 1, 2, ... C; is the true label of the qth labeled training sample. If the qth training sample input to the defect detection model belongs to the clsth class defect, it is 1, otherwise it is 0; The probability that the qth training sample input to the model belongs to the clsth class defect predicted by the defect detection model; The stochastic gradient descent method is used to iteratively optimize the parameters of the defect detection model to reduce the loss value until the set number of iterations is reached to obtain the optimized model.

7. The method for detecting surface defects of a plastic optical lens according to claim 6, wherein: The step S5 includes the following steps: S51: Get the model prediction results: The plastic lens image without defect category labeling, the corresponding defect map generated by steps S1 to S3, and the length and width of the defect area obtained by the quadratic element measuring instrument are input into the optimized model to obtain the probability vector predicted by the model. S52: Determine the final detection category: By predicting the probability vector of the model Perform the maximum value operation and select the category with the highest probability as the final defect category, specifically: in, The defect category number predicted by the defect detection model; The model predicts the probability that the sample input to the model belongs to the cls class of defects.

8. A system for detecting surface defects of plastic optical lenses, characterized in that: include: Edge detection module: performs phase consistency multi-scale edge detection on plastic lens images; Optical zone division module: Fitting an ellipse model based on a set of edge points, and using the fitting results to divide the optical zone into the non-optical zone; Potential defect extraction module: Enhances and extracts features from pixels in the optical area, and screens potential defect areas through binarization to obtain a potential defect map. A quadratic element measuring instrument is used to obtain the length and width of the defect area. Model construction module: Build a defect detection model based on VGG16, and use labeled training samples to train and optimize the defect detection model; Model application module: Use the optimized model to detect plastic lens images without labeled defect categories; To realize the method for detecting surface defects of a plastic optical lens as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • VR lens defect detection method and system based on image cube and deep learning

    CN117197550A