CN117314891B - Optical lens surface defect detection method and system based on image processing - Google Patents

Optical lens surface defect detection method and system based on image processing Download PDF

Info

Publication number
CN117314891B
CN117314891B CN202311571461.XA CN202311571461A CN117314891B CN 117314891 B CN117314891 B CN 117314891B CN 202311571461 A CN202311571461 A CN 202311571461A CN 117314891 B CN117314891 B CN 117314891B
Authority
CN
China
Prior art keywords
optical lens
image
lens surface
individual
defect detection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311571461.XA
Other languages
Chinese (zh)
Other versions
CN117314891A (en
Inventor
王云山
柳恒生
朱士松
冉马超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanyang Yongtai Photoelectric Co ltd
Original Assignee
Nanyang Yongtai Photoelectric Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanyang Yongtai Photoelectric Co ltd filed Critical Nanyang Yongtai Photoelectric Co ltd
Priority to CN202311571461.XA priority Critical patent/CN117314891B/en
Publication of CN117314891A publication Critical patent/CN117314891A/en
Application granted granted Critical
Publication of CN117314891B publication Critical patent/CN117314891B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/01Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Databases & Information Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)

Abstract

The invention discloses an optical lens surface defect detection method and system based on image processing, wherein the method comprises the following steps: image acquisition, image enhancement, construction of an optical lens surface defect detection model, model parameter search and optical lens surface defect detection. The invention belongs to the technical field of optical lens detection, in particular to an optical lens surface defect detection method and system based on image processing, wherein the scheme introduces a compensation factor to correct a logarithmic function of an MSR algorithm, calculates an optimal scale parameter based on a flatness index, so as to determine self-adaptive weight and normalize the brightness of an image; calculating the score of the defect category and the square sum of the distance between the feature and the center of the corresponding category, and introducing a weighting coefficient and a constraint factor to define a loss function; initializing individual positions by using a sine chaotic mapping method, introducing a nonlinear convergence factor and a random delay step length to optimize a position updating strategy, and determining model parameters.

Description

Optical lens surface defect detection method and system based on image processing
Technical Field
The invention belongs to the technical field of optical lens detection, and particularly relates to an optical lens surface defect detection method and system based on image processing.
Background
Optical lens surface defect detection refers to detecting an image of the optical lens surface to discover and identify possible defects and damage. However, the existing image enhancement method has the problems of losing or distorting image details, amplifying image noise and causing the enhanced image quality to be reduced; the traditional optical lens surface defect detection model has the problems that local characteristics are concerned too much, so that model training is difficult and convergence time is long; the current model parameter searching algorithm has the problems of low convergence speed, easy sinking into local optimum and low optimum solving accuracy.
Disclosure of Invention
Aiming at the problems that the image details are lost or distorted, the image noise is amplified and the quality of the enhanced image is reduced in the existing image enhancement method, the compensation factors are introduced to correct the logarithmic function of the MSR algorithm, and the optimal scale parameters are calculated based on the flatness index, so that the self-adaptive weight is determined, the brightness of the image is normalized, the enhanced image is more balanced and natural, and the image quality is improved; aiming at the problems that the traditional optical lens surface defect detection model is excessively focused on local features, so that model training is difficult and convergence time is long, the scheme calculates the score of the defect class, measures the dispersion degree of feature vectors by calculating the square sum of the distances between the features and the centers of the corresponding classes, introduces a weighting coefficient and a constraint factor to define a loss function, and improves the accuracy of defect detection; aiming at the problems that the current model parameter searching algorithm is low in convergence speed and easy to fall into local optimum and low in optimizing accuracy, the method uses a sinusoidal chaotic mapping method to initialize individual positions, introduces a nonlinear convergence factor and a random delay step length optimizing position updating strategy, and enhances the global searching capability and the local utilization capability of the algorithm in iteration.
The technical scheme adopted by the invention is as follows: the invention provides an optical lens surface defect detection method based on image processing, which comprises the following steps:
step S1: image acquisition, namely acquiring an optical lens surface image and constructing a surface image data set;
step S2: image enhancement, namely introducing a compensation factor to correct a logarithmic function of an MSR algorithm, calculating an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, and carrying out normalization processing on the brightness of the image to obtain an optical lens surface enhanced image;
step S3: constructing an optical lens surface defect detection model, calculating the score of a defect class and the square sum of the distance between the feature and the center of the corresponding class, and introducing a weighting coefficient and a constraint factor to define a loss function;
step S4: model parameter searching, initializing an individual position by using a sine chaotic mapping method, introducing a nonlinear convergence factor and a random delay step length optimization position updating strategy, and determining model parameters;
step S5: and (3) detecting the surface defects of the optical lens, inputting the optical lens surface images acquired in real time into an optical lens surface defect detection model for classification, and detecting the defects based on the output defect type labels.
Further, in step S1, the image acquisition is acquisition of an optical lens surface image and a surface image dataset is constructed based on the optical lens surface image and a defect class of the optical lens surface image.
Further, in step S2, the image enhancement specifically includes the following steps:
step S21: dividing an image area, namely uniformly dividing each optical lens surface image in a surface image data set into N1 image sub-blocks, presetting a flatness threshold value psi 1, and dividing the image sub-blocks with flatness indexes larger than the flatness threshold value psi 1 into non-flat areas; otherwise, dividing into flat areas, and calculating a flatness index according to the following formula:
wherein beta is f Is the flatness index of image sub-block f, gamma and epsilon are the control flatness index range factors, delta f Is the standard deviation, beta, of image sub-block f f And delta f Satisfying the inverse relation, f is the image sub-block index;
step S22: calculating an optimal scale parameter, and calculating the optimal scale parameter of the Gaussian surrounding filter based on the flatness index of the image sub-block f by using the following formula:
wherein mu is f Is the optimal scale parameter of Gaussian surrounding filter corresponding to image sub-block f, mu max Sum mu min Maximum and minimum, respectively, of the optimal scale parameter, max (beta f ) And min (beta) f ) Respectively maximum and minimum values of the flatness index;
step S23: the adaptive weights are calculated using the following formula:
wherein mu is 1 、μ 2 Sum mu 3 Respectively minimum, intermediate and maximum values of flatness index, b f,1 、b f,2 And b f,3 Is three different scales, ω, of image sub-block f f,c Is the adaptive weight of image sub-block f on scale c, i and c are scale indices;
step S24: multiscale enhancement, the formula used is as follows:
in which W is e (x, y) is the enhancement effect of the optical lens surface map R, G and the B color channels,is a compensation factor, l e (x, y) is the luminance value of the e-th color channel of the optical lens surface image, e is the color channel index,/->Is the convolution operator, g e (x, y) is the effect of the e-th color channel of the optical lens surface image after being processed by a Gaussian surround filter, h is a normalization factor, and x and y are the abscissa index and the ordinate index of the optical lens surface image respectively;
step S25: brightness normalization is carried out on the optical lens surface image, so that a brightness normalized optical lens surface image M (x, y) is obtained;
step S26: constructing an enhancement data set, calculating an enhanced optical lens surface image, and constructing the enhancement data set based on the optical lens surface enhanced image, wherein the formula is as follows:
wherein J is e (x, y) is an optical lens surface enhanced image.
Further, in step S3, the construction of the optical lens surface defect detection model specifically includes the following steps:
step S31: initializing a model, wherein the preset model consists of an input layer, a hidden layer and an output layer, the input layer receives the surface enhanced image of the optical lens, the hidden layer is used for extracting the characteristics in the surface enhanced image of the optical lens, and the output layer is used for outputting the defect type corresponding to the surface enhanced image of the optical lens;
step S32: the loss function is defined using the formula:
where Loss is a Loss function, θ is the angle between defect categories, N3 is the feature quantity, p is the feature index, x p Is the p-th feature, yp is the p-th bitC, marking corresponding defect type labels yp Is the defect class center of the defect class yp, m is the margin parameter, w is the defect class ratio, d is the number of defect class labels, j is the index of the defect class labels, λ is the weighting coefficient, n is the constraint factor,is the score of the defect class yp.
Further, in step S4, the model parameter search specifically includes the following steps:
step S41: initializing a position, representing the position of an individual by using model parameters, initializing the position of the individual by using a sinusoidal chaotic mapping method, taking the model performance established based on the model parameters as an individual position fitness value, and initializing the position of the individual by using the following formula:
in the method, in the process of the invention,is the initial position of the a+1st individual, < >>Is the initial position of the a-th individual, a is the individual index, N2 is the number of individuals, o is the control factor,>an initial position of the 1 st individual randomly generated based on the individual search space;
step S42: calculating an optimal fitness value and a global optimal position, updating fitness values of individuals, selecting the highest fitness value as the optimal fitness value, taking an individual corresponding to the optimal fitness value as an optimal individual, and taking the position corresponding to the optimal individual as a global optimal position E best
Step S43: the position is updated as follows:
step S431: calculating nonlinear convergence factor, and presetting the most value of nonlinear convergence factorLarge value s max The formula used is as follows:
wherein s is a nonlinear convergence factor, T is the current iteration number, and T is the maximum iteration number;
step S432: the random delay step is calculated using the following formula:
in the method, in the process of the invention,is elite individual index, round () is a rounding function, +.>Is the distance between the qth individual and the optimal individual or elite individual in the nth iteration in the nth dimension, U is the individual search space dimension, U is the dimension index,is the position of the optimal individual in the u-th dimension at the t-th iteration,/for the iteration>Is the position of the qth individual in the nth iteration in the nth dimension, +.>Is the position of the elite individual in the u-th dimension at the t-th iteration,/for>Is the random delay step size, r, used for updating the position of elite individuals in the ith iteration 1 And r 2 Is a random number between (0, 1), P is a time lag factor, v 0 And v 1 The initial value and the end value of the acceleration coefficient are respectively, k is a random delay time and k is E [0, t-1];
Step S433: updating the individual location using the formula:
in the method, in the process of the invention,is the position of the (q) th individual in the (t+1) th iteration, r 3 And r 4 Is a random number between (0, 1), z is a chaotic vector;
step S44: determining model parameters, presetting an fitness value evaluation threshold delta, updating an optimal fitness value and a global optimal position, and constructing an optical lens surface defect detection model based on current model parameters when the optimal fitness value is higher than the fitness value evaluation threshold delta; otherwise, if the maximum iteration number T is reached, go to step S41; otherwise, the process goes to step S43.
Further, in step S5, the optical lens surface defect detection is to collect an optical lens surface image in real time, input the optical lens surface image into the optical lens surface defect detection model, and detect the optical lens surface based on the defect type label output by the optical lens surface defect detection model.
The invention provides an optical lens surface defect detection system based on image processing, which comprises an image acquisition module, an image enhancement module, a module for constructing an optical lens surface defect detection model, a model parameter search module and an optical lens surface defect detection module, wherein the image acquisition module is used for acquiring an image of the optical lens surface defect;
the image acquisition module acquires the surface image of the optical lens, constructs a surface image data set based on the surface image of the optical lens and the defect type of the surface image of the optical lens, and sends the data to the image enhancement module;
the image enhancement module introduces a compensation factor to correct a logarithmic function of an MSR algorithm, calculates an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, carrying out normalization processing on brightness of an image to obtain an optical lens surface enhanced image, and sending data to a module for constructing an optical lens surface defect detection model;
the module for constructing the optical lens surface defect detection model calculates the score and the square sum of the distance between the feature of the defect category and the center of the corresponding category, introduces a weighting coefficient and a constraint factor to define a loss function, and sends data to the model parameter searching module;
the model parameter searching module uses a sine chaotic mapping method to initialize individual positions, introduces nonlinear convergence factors and random delay step length optimization position updating strategies, determines model parameters, and sends data to the optical lens surface defect detecting module;
the optical lens surface defect detection module acquires an optical lens surface image in real time, inputs the optical lens surface image into the optical lens surface defect detection model, and detects defects on the optical lens surface based on the defect type label output by the optical lens surface defect detection model.
By adopting the scheme, the beneficial effects obtained by the invention are as follows:
(1) Aiming at the problems of loss or distortion of image details and reduced image quality caused by amplified image noise in the existing image enhancement method, the method introduces a compensation factor to correct the logarithmic function of the MSR algorithm, can better reserve and enhance the detail information in the image, calculates the optimal scale parameter based on the flatness index, thereby determining the self-adaptive weight, effectively inhibiting the noise in the image, better balancing the details and the noise in the image, carrying out normalization processing on the brightness of the image, leading the enhanced image to be more balanced and natural, and improving the image quality.
(2) Aiming at the problems that the traditional optical lens surface defect detection model is excessively focused on local features, so that model training is difficult and convergence time is long, the scheme calculates the score of the defect class, so that the higher-score class has larger contribution to the loss function, measures the dispersion degree of feature vectors by calculating the square sum of the distances between the features and the centers of the corresponding classes, introduces a weighting coefficient and a constraint factor to define the loss function, enables the loss function to more comprehensively reflect the performance of the model, can accurately detect and classify the defects of the optical lens surface image, reduces the misjudgment rate, and improves the accuracy of defect detection.
(3) Aiming at the problems that the current model parameter searching algorithm is low in convergence speed and easy to fall into local optimum and low in optimizing accuracy, the method initializes the individual position by using a sinusoidal chaotic mapping method, introduces a nonlinear convergence factor and a random delay step length optimizing position updating strategy, effectively prevents the algorithm from falling into a local optimum solution, improves convergence and solving accuracy, and enhances global searching capability and local utilization capability of the algorithm in iteration.
Drawings
FIG. 1 is a schematic flow chart of an optical lens surface defect detection method based on image processing;
FIG. 2 is a schematic diagram of an optical lens surface defect detection system based on image processing according to the present invention;
FIG. 3 is a flow chart of step S2;
FIG. 4 is a flow chart of step S3;
fig. 5 is a flow chart of step S4.
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate the invention and together with the embodiments of the invention, serve to explain the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the invention; all other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it should be understood that the terms "upper," "lower," "front," "rear," "left," "right," "top," "bottom," "inner," "outer," and the like indicate orientation or positional relationships based on those shown in the drawings, merely to facilitate description of the invention and simplify the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the invention.
Referring to fig. 1, the method for detecting surface defects of an optical lens based on image processing provided by the invention includes the following steps:
step S1: image acquisition, namely acquiring an optical lens surface image and constructing a surface image data set;
step S2: image enhancement, namely introducing a compensation factor to correct a logarithmic function of an MSR algorithm, calculating an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, and carrying out normalization processing on the brightness of the image to obtain an optical lens surface enhanced image;
step S3: constructing an optical lens surface defect detection model, calculating the score of a defect class and the square sum of the distance between the feature and the center of the corresponding class, and introducing a weighting coefficient and a constraint factor to define a loss function;
step S4: model parameter searching, initializing an individual position by using a sine chaotic mapping method, introducing a nonlinear convergence factor and a random delay step length optimization position updating strategy, and determining model parameters;
step S5: and (3) detecting the surface defects of the optical lens, inputting the optical lens surface images acquired in real time into an optical lens surface defect detection model for classification, and detecting the defects based on the output defect type labels.
In step S1, the image acquisition is to acquire an optical lens surface image, and construct a surface image dataset based on the optical lens surface image and a defect class of the optical lens surface image, referring to fig. 1.
Embodiment three, referring to fig. 1 and 3, the embodiment is based on the above embodiment, and in step S2, the image enhancement specifically includes the following steps:
step S21: dividing an image area, namely uniformly dividing each optical lens surface image in a surface image data set into N1 image sub-blocks, presetting a flatness threshold value psi 1, and dividing the image sub-blocks with flatness indexes larger than the flatness threshold value psi 1 into non-flat areas; otherwise, dividing into flat areas, and calculating a flatness index according to the following formula:
wherein beta is f Is the flatness index of image sub-block f, gamma and epsilon are the control flatness index range factors, delta f Is the standard deviation, beta, of image sub-block f f And delta f Satisfying the inverse relation, f is the image sub-block index;
step S22: calculating an optimal scale parameter, and calculating the optimal scale parameter of the Gaussian surrounding filter based on the flatness index of the image sub-block f by using the following formula:
wherein mu is f Is the optimal scale parameter of Gaussian surrounding filter corresponding to image sub-block f, mu max Sum mu min Maximum and minimum, respectively, of the optimal scale parameter, max (beta f ) And min (beta) f ) Respectively maximum and minimum values of the flatness index;
step S23: the adaptive weights are calculated using the following formula:
wherein mu is 1 、μ 2 Sum mu 3 Respectively minimum, intermediate and maximum values of flatness index, b f,1 、b f,2 And b f,3 Is three different scales, ω, of image sub-block f f,c Is the adaptive weight of image sub-block f on scale c, i and c are scale indices;
step S24: multiscale enhancement, the formula used is as follows:
in which W is e (x, y) is the enhancement effect of the optical lens surface map R, G and the B color channels,is a compensation factor, l e (x, y) is the luminance value of the e-th color channel of the optical lens surface image, e is the color channel index,/->Is the convolution operator, g e (x, y) is the effect of the e-th color channel of the optical lens surface image after being processed by a Gaussian surround filter, h is a normalization factor, and x and y are the abscissa index and the ordinate index of the optical lens surface image respectively;
step S25: brightness normalization is carried out on the optical lens surface image, so that a brightness normalized optical lens surface image M (x, y) is obtained;
step S26: constructing an enhancement data set, calculating an enhanced optical lens surface image, and constructing the enhancement data set based on the optical lens surface enhanced image, wherein the formula is as follows:
wherein J is e (x, y) is an optical lens surface enhanced image.
By executing the operation, aiming at the problems of loss or distortion of image details, amplification of image noise and reduction of enhanced image quality existing in the existing image enhancement method, the method introduces a compensation factor to correct a logarithmic function of an MSR algorithm, can better reserve and enhance detail information in an image, calculates an optimal scale parameter based on a flatness index, thereby determining self-adaptive weight, effectively inhibiting noise in the image, better balancing details and noise in the image, and carrying out normalization processing on brightness of the image, so that the enhanced image is more balanced and natural, and the image quality is improved.
In a fourth embodiment, referring to fig. 1 and 4, the method for constructing the optical lens surface defect detection model in step S3 specifically includes the following steps:
step S31: initializing a model, wherein the preset model consists of an input layer, a hidden layer and an output layer, the input layer receives the surface enhanced image of the optical lens, the hidden layer is used for extracting the characteristics in the surface enhanced image of the optical lens, and the output layer is used for outputting the defect type corresponding to the surface enhanced image of the optical lens;
step S32: the loss function is defined using the formula:
where Loss is a Loss function, θ is the angle between defect categories, N3 is the feature quantity, p is the feature index, x p Is the p-th feature, yp is the defect class label corresponding to the p-th feature, c yp Is the defect class center of the defect class yp, m is the margin parameter, w is the defect class ratio, d is the number of defect class labels, j is the index of the defect class labels, λ is the weighting coefficient, n is the constraint factor,is the score of the defect class yp.
By executing the operation, aiming at the problems that the traditional optical lens surface defect detection model has too much attention to local characteristics, so that model training is difficult and convergence time is long, the scheme calculates the score of the defect class, so that the higher-score class has larger contribution to the loss function, measures the dispersion degree of the feature vector by calculating the square sum of the distances between the feature and the center of the corresponding class, and introduces a weighting coefficient and a constraint factor to define the loss function, so that the loss function can more comprehensively reflect the performance of the model, accurately detect and classify the defects of the optical lens surface image, reduce the false judgment rate and improve the accuracy of defect detection.
Fifth embodiment referring to fig. 1 and 5, the embodiment is based on the above embodiment, and in step S4, the model parameter search specifically includes the following steps:
step S41: initializing a position, representing the position of an individual by using model parameters, initializing the position of the individual by using a sinusoidal chaotic mapping method, taking the model performance established based on the model parameters as an individual position fitness value, and initializing the position of the individual by using the following formula:
in the method, in the process of the invention,is the initial position of the a+1st individual, < >>Is the initial position of the a-th individual, a is the individual index, N2 is the number of individuals, o is the control factor,>an initial position of the 1 st individual randomly generated based on the individual search space;
step S42: calculating the optimal fitness value and the global optimal position, updating the fitness value of the individual, selecting the highest fitness value as the optimal fitness value, and corresponding the optimal fitness valueThe individual is taken as the optimal individual, and the corresponding position of the optimal individual is taken as the global optimal position E best
Step S43: the position is updated as follows:
step S431: calculating nonlinear convergence factor, and presetting the maximum value of the nonlinear convergence factor as s max The formula used is as follows:
wherein s is a nonlinear convergence factor, T is the current iteration number, and T is the maximum iteration number;
step S432: the random delay step is calculated using the following formula:
in the method, in the process of the invention,is elite individual index, round () is a rounding function, +.>Is the distance between the qth individual and the optimal individual or elite individual in the nth iteration in the nth dimension, U is the individual search space dimension, U is the dimension index,is the position of the optimal individual in the u-th dimension at the t-th iteration,/for the iteration>Is the bit of the qth individual in the nth iteration in the nth dimensionPut (I) at>Is the position of the elite individual in the u-th dimension at the t-th iteration,/for>Is the random delay step size, r, used for updating the position of elite individuals in the ith iteration 1 And r 2 Is a random number between (0, 1), P is a time lag factor, v 0 And v 1 The initial value and the end value of the acceleration coefficient are respectively, k is a random delay time and k is E [0, t-1];
Step S433: updating the individual location using the formula:
in the method, in the process of the invention,is the position of the (q) th individual in the (t+1) th iteration, r 3 And r 4 Is a random number between (0, 1), z is a chaotic vector;
step S44: determining model parameters, presetting an fitness value evaluation threshold delta, updating an optimal fitness value and a global optimal position, and constructing an optical lens surface defect detection model based on current model parameters when the optimal fitness value is higher than the fitness value evaluation threshold delta; otherwise, if the maximum iteration number T is reached, go to step S41; otherwise, the process goes to step S43.
By executing the operation, aiming at the problems that the current model parameter searching algorithm is low in convergence speed and easy to fall into local optimum and low in optimum solving accuracy, the method uses a sinusoidal chaotic mapping method to initialize individual positions, introduces nonlinear convergence factors and random delay step length optimizing position updating strategies, effectively prevents the algorithm from falling into local optimum solutions, improves convergence and solving accuracy, and enhances global searching capacity and local utilization capacity of the algorithm in iteration.
In step S5, the optical lens surface defect detection is to collect the optical lens surface image in real time, input the image into the optical lens surface defect detection model, and detect the defect on the optical lens surface based on the defect type label output by the optical lens surface defect detection model, as shown in fig. 1.
An embodiment seven, referring to fig. 2, based on the above embodiment, the optical lens surface defect detection system provided by the invention based on image processing includes an image acquisition module, an image enhancement module, a module for constructing an optical lens surface defect detection model, a model parameter search module and an optical lens surface defect detection module;
the image acquisition module acquires the surface image of the optical lens, constructs a surface image data set based on the surface image of the optical lens and the defect type of the surface image of the optical lens, and sends the data to the image enhancement module;
the image enhancement module introduces a compensation factor to correct a logarithmic function of an MSR algorithm, calculates an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, carrying out normalization processing on brightness of an image to obtain an optical lens surface enhanced image, and sending data to a module for constructing an optical lens surface defect detection model;
the module for constructing the optical lens surface defect detection model calculates the score and the square sum of the distance between the feature of the defect category and the center of the corresponding category, introduces a weighting coefficient and a constraint factor to define a loss function, and sends data to the model parameter searching module;
the model parameter searching module uses a sine chaotic mapping method to initialize individual positions, introduces nonlinear convergence factors and random delay step length optimization position updating strategies, determines model parameters, and sends data to the optical lens surface defect detecting module;
the optical lens surface defect detection module acquires an optical lens surface image in real time, inputs the optical lens surface image into the optical lens surface defect detection model, and detects defects on the optical lens surface based on the defect type label output by the optical lens surface defect detection model.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
The invention and its embodiments have been described above with no limitation, and the actual construction is not limited to the embodiments of the invention as shown in the drawings. In summary, if one of ordinary skill in the art is informed by this disclosure, a structural manner and an embodiment similar to the technical solution should not be creatively devised without departing from the gist of the present invention.

Claims (6)

1. An optical lens surface defect detection method based on image processing is characterized in that: the method comprises the following steps:
step S1: image acquisition, namely acquiring an optical lens surface image and constructing a surface image data set;
step S2: image enhancement, namely introducing a compensation factor to correct a logarithmic function of an MSR algorithm, calculating an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, and carrying out normalization processing on the brightness of the image to obtain an optical lens surface enhanced image;
step S3: constructing an optical lens surface defect detection model, calculating the score of a defect class and the square sum of the distance between the feature and the center of the corresponding class, and introducing a weighting coefficient and a constraint factor to define a loss function;
step S4: model parameter searching, initializing an individual position by using a sine chaotic mapping method, introducing a nonlinear convergence factor and a random delay step length optimization position updating strategy, and determining model parameters;
step S5: the method comprises the steps of detecting the surface defects of an optical lens, inputting an optical lens surface image acquired in real time into an optical lens surface defect detection model for classification, and detecting defects based on an output defect type label;
in step S4, the model parameter search specifically includes the following steps:
step S41: initializing a position, representing the position of an individual by using model parameters, initializing the position of the individual by using a sinusoidal chaotic mapping method, taking the model performance established based on the model parameters as an individual position fitness value, and initializing the position of the individual by using the following formula:
in the method, in the process of the invention,is the initial position of the a+1st individual, < >>Is the initial position of the a-th individual, a is the individual index, N2 is the number of individuals, o is the control factor,>an initial position of the 1 st individual randomly generated based on the individual search space;
step S42: calculating the optimal fitness value and the global optimal position, updating the fitness value of the individual, selecting the highest fitness value as the optimal fitness value, and determining the mostThe individual corresponding to the optimal fitness value is taken as an optimal individual, and the position corresponding to the optimal individual is taken as a global optimal position E best
Step S43: the position is updated as follows:
step S431: calculating nonlinear convergence factor, and presetting the maximum value of the nonlinear convergence factor as s max The formula used is as follows:
wherein s is a nonlinear convergence factor, T is the current iteration number, and T is the maximum iteration number;
step S432: the random delay step is calculated using the following formula:
in the method, in the process of the invention,is elite individual index, round () is a rounding function, +.>Is the distance between the qth individual and the optimal individual or elite individual in the nth iteration in the nth dimension, U is the individual search space dimension, U is the dimension index,is the position of the optimal individual in the u-th dimension at the t-th iteration,/for the iteration>Is the position of the qth individual in the nth iteration in the nth dimension, +.>Is the position of the elite individual in the u-th dimension at the t-th iteration,/for>Is the random delay step size, r, used for updating the position of elite individuals in the ith iteration 1 And r 2 Is a random number between (0, 1), P is a time lag factor, v 0 And v 1 The initial value and the end value of the acceleration coefficient are respectively, k is a random delay time and k is E [0, t-1];
Step S433: updating the individual location using the formula:
in the method, in the process of the invention,is the position of the (q) th individual in the (t+1) th iteration, r 3 And r 4 Is a random number between (0, 1), z is a chaotic vector;
step S44: determining model parameters, presetting an fitness value evaluation threshold delta, updating an optimal fitness value and a global optimal position, and constructing an optical lens surface defect detection model based on current model parameters when the optimal fitness value is higher than the fitness value evaluation threshold delta; otherwise, if the maximum iteration number T is reached, go to step S41; otherwise go to step S43;
in step S2, the image enhancement specifically includes the following steps:
step S21: dividing an image area, namely uniformly dividing each optical lens surface image in a surface image data set into N1 image sub-blocks, presetting a flatness threshold value psi 1, and dividing the image sub-blocks with flatness indexes larger than the flatness threshold value psi 1 into non-flat areas; otherwise, dividing into flat areas, and calculating a flatness index according to the following formula:
wherein beta is f Is the flatness index of image sub-block f, gamma and epsilon are the control flatness index range factors, delta f Is the standard deviation, beta, of image sub-block f f And delta f Satisfying the inverse relation, f is the image sub-block index;
step S22: calculating an optimal scale parameter, and calculating the optimal scale parameter of the Gaussian surrounding filter based on the flatness index of the image sub-block f by using the following formula:
wherein mu is f Is the optimal scale parameter of Gaussian surrounding filter corresponding to image sub-block f, mu max Sum mu min Maximum and minimum, respectively, of the optimal scale parameter, max (beta f ) And min (beta) f ) Respectively maximum and minimum values of the flatness index;
step S23: the adaptive weights are calculated using the following formula:
wherein mu is 1 、μ 2 Sum mu 3 Respectively minimum, intermediate and maximum values of flatness index, b f,1 、b f,2 And b f,3 Is three different scales, ω, of image sub-block f f,c Is the adaptive weight of image sub-block f on scale c, i and c are scale indices;
step S24: multiscale enhancement, the formula used is as follows:
in which W is e (x, y) is the enhancement effect of the optical lens surface map R, G and the B color channels,is a compensation factor, l e (x, y) is the luminance value of the e-th color channel of the optical lens surface image, e is the color channel index,/->Is the convolution operator, g e (x, y) is the effect of the e-th color channel of the optical lens surface image after being processed by a Gaussian surround filter, h is a normalization factor, and x and y are the abscissa index and the ordinate index of the optical lens surface image respectively;
step S25: brightness normalization is carried out on the optical lens surface image, so that a brightness normalized optical lens surface image M (x, y) is obtained;
step S26: constructing an enhancement data set, calculating an enhanced optical lens surface image, and constructing the enhancement data set based on the optical lens surface enhanced image, wherein the formula is as follows:
wherein J is e (x, y) is an optical lens surface enhanced image.
2. The method for detecting surface defects of an optical lens based on image processing according to claim 1, wherein: in step S3, the construction of the optical lens surface defect detection model specifically includes the following steps:
step S31: initializing a model, wherein the preset model consists of an input layer, a hidden layer and an output layer, the input layer receives the surface enhanced image of the optical lens, the hidden layer is used for extracting the characteristics in the surface enhanced image of the optical lens, and the output layer is used for outputting the defect type corresponding to the surface enhanced image of the optical lens;
step S32: the loss function is defined using the formula:
where Loss is a Loss function, θ is the angle between defect categories, N3 is the feature quantity, p is the feature index, x p Is the p-th feature, yp is the defect class label corresponding to the p-th feature, c yp Is the defect class center of the defect class yp, m is the margin parameter, w is the defect class ratio, d is the number of defect class labels, j is the index of the defect class labels, λ is the weighting coefficient, n is the constraint factor,is the score of the defect class yp.
3. The method for detecting surface defects of an optical lens based on image processing according to claim 1, wherein: in step S1, the image acquisition is acquisition of an optical lens surface image and a surface image dataset is constructed based on the optical lens surface image and a defect class of the optical lens surface image.
4. The method for detecting surface defects of an optical lens based on image processing according to claim 1, wherein: in step S5, the optical lens surface defect detection is to collect an optical lens surface image in real time, input the optical lens surface image into the optical lens surface defect detection model, and detect the optical lens surface based on the defect type label output by the optical lens surface defect detection model.
5. An optical lens surface defect detection system based on image processing, for implementing an optical lens surface defect detection method based on image processing as claimed in any one of claims 1 to 4, wherein: the method comprises an image acquisition module, an image enhancement module, a module for constructing an optical lens surface defect detection model, a model parameter search module and an optical lens surface defect detection module.
6. An optical lens surface defect detecting system based on image processing according to claim 5, wherein:
the image acquisition module acquires the surface image of the optical lens, constructs a surface image data set based on the surface image of the optical lens and the defect type of the surface image of the optical lens, and sends the data to the image enhancement module;
the image enhancement module introduces a compensation factor to correct a logarithmic function of an MSR algorithm, calculates an optimal scale parameter based on a flatness index, thereby determining an adaptive weight, carrying out normalization processing on brightness of an image to obtain an optical lens surface enhanced image, and sending data to a module for constructing an optical lens surface defect detection model;
the module for constructing the optical lens surface defect detection model calculates the score and the square sum of the distance between the feature of the defect category and the center of the corresponding category, introduces a weighting coefficient and a constraint factor to define a loss function, and sends data to the model parameter searching module;
the model parameter searching module uses a sine chaotic mapping method to initialize individual positions, introduces nonlinear convergence factors and random delay step length optimization position updating strategies, determines model parameters, and sends data to the optical lens surface defect detecting module;
the optical lens surface defect detection module acquires an optical lens surface image in real time, inputs the optical lens surface image into the optical lens surface defect detection model, and detects defects on the optical lens surface based on the defect type label output by the optical lens surface defect detection model.
CN202311571461.XA 2023-11-23 2023-11-23 Optical lens surface defect detection method and system based on image processing Active CN117314891B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311571461.XA CN117314891B (en) 2023-11-23 2023-11-23 Optical lens surface defect detection method and system based on image processing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311571461.XA CN117314891B (en) 2023-11-23 2023-11-23 Optical lens surface defect detection method and system based on image processing

Publications (2)

Publication Number Publication Date
CN117314891A CN117314891A (en) 2023-12-29
CN117314891B true CN117314891B (en) 2024-04-12

Family

ID=89286784

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311571461.XA Active CN117314891B (en) 2023-11-23 2023-11-23 Optical lens surface defect detection method and system based on image processing

Country Status (1)

Country Link
CN (1) CN117314891B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117584136B (en) * 2024-01-18 2024-03-29 泰山学院 Robot fault detection method and system based on artificial intelligence
CN118009934A (en) * 2024-02-02 2024-05-10 惠州市双诚鑫科技有限公司 Method and system for detecting surface roughness of optical lens

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106530250A (en) * 2016-11-07 2017-03-22 湖南源信光电科技有限公司 Low illumination color image enhancement method based on improved Retinex
CN111351801A (en) * 2020-03-11 2020-06-30 春光线缆有限公司 Wire and cable defect detection system
CN112836629A (en) * 2021-02-01 2021-05-25 清华大学深圳国际研究生院 Image classification method
CN114330111A (en) * 2021-12-06 2022-04-12 江南大学 Power transmission line electric field calculation method based on sparrow search algorithm and simulated charge method
CN115379197A (en) * 2022-04-12 2022-11-22 北京朝歌数码科技股份有限公司 Method and device for detecting lens surface of camera product on production line

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106530250A (en) * 2016-11-07 2017-03-22 湖南源信光电科技有限公司 Low illumination color image enhancement method based on improved Retinex
CN111351801A (en) * 2020-03-11 2020-06-30 春光线缆有限公司 Wire and cable defect detection system
CN112836629A (en) * 2021-02-01 2021-05-25 清华大学深圳国际研究生院 Image classification method
CN114330111A (en) * 2021-12-06 2022-04-12 江南大学 Power transmission line electric field calculation method based on sparrow search algorithm and simulated charge method
CN115379197A (en) * 2022-04-12 2022-11-22 北京朝歌数码科技股份有限公司 Method and device for detecting lens surface of camera product on production line

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"基于Kmeans-EMD与IWOA-Elman的碾压速度异常值检测与修正";乔天诚等;《水资源与水工程学报》;第33卷(第3期);第124-131页 *
"结合细节信息的自适应Retinex算法水下图像增强";许丽等;《计算机工程与应用》;第58卷(第11期);第224-233页 *

Also Published As

Publication number Publication date
CN117314891A (en) 2023-12-29

Similar Documents

Publication Publication Date Title
CN117314891B (en) Optical lens surface defect detection method and system based on image processing
CN110766058B (en) Battlefield target detection method based on optimized RPN (resilient packet network)
CN110211126B (en) Image segmentation method based on intuitive fuzzy C-means clustering
CN115830459B (en) Mountain forest grass life community damage degree detection method based on neural network
CN116091455A (en) Steel mesh surface defect judging method based on machine vision
CN117689655B (en) Metal button surface defect detection method based on computer vision
CN116912568A (en) Noise-containing label image recognition method based on self-adaptive class equalization
CN114677525B (en) Edge detection method based on binary image processing
CN115953409A (en) Injection molding surface defect detection method based on image processing
CN117557820A (en) Quantum dot optical film damage detection method and system based on machine vision
CN116309668A (en) Complex image multi-threshold segmentation method based on improved gray wolf optimization algorithm
CN106292673B (en) A kind of method for optimizing route and system
CN108986083A (en) SAR image change detection based on threshold optimization
CN109063749B (en) Robust convolution kernel number adaptation method based on angular point radiation domain
CN110070120B (en) Depth measurement learning method and system based on discrimination sampling strategy
CN116823820A (en) Aluminum-carbon integral stopper rod contour bending detection method
CN107067397A (en) A kind of image grading method based on infrared image complexity
CN116242381A (en) Path planning method, system, electronic equipment and storage medium
CN114067092B (en) Fatty liver B-mode ultrasound image classification method based on DenseNet and lightGBM
CN107085832A (en) A kind of Fast implementation of the non local average denoising of digital picture
CN111695552A (en) Multi-feature fusion underwater target modeling and optimizing method
CN118114031B (en) Radio waveform prediction method and system based on machine learning
CN117078567B (en) Photovoltaic panel image self-adaptive enhancement method based on image processing
CN117527570B (en) Sensor cluster position optimization method based on edge reinforcement learning
CN114820397B (en) Image enhancement method and system based on attention degree

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20240308

Address after: 473000 floor 2, building e, photoelectric Incubation Park, Nanyang City, Henan Province

Applicant after: Nanyang Yongtai photoelectric Co.,Ltd.

Country or region after: China

Address before: 518100, Room 318, Block D, Hongtaifu Building, Fengshang Era, Xin'an Street, Bao'an District, Shenzhen, Guangdong Province, China

Applicant before: SHENZHEN YONGTAI PHOTOELECTRIC Co.,Ltd.

Country or region before: China

Applicant before: Nanyang Yongtai photoelectric Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant