A Visual Inspection Method, Device and System for a Sighting Device Lens

By combining front and backlight images at different wavelengths, using grayscale values, gradient values and edge detection algorithms, combined with dynamic time regularization algorithms and image fusion technology, the internal and surface defects of the sight lens are accurately identified, solving the problem of inaccurate recognition of surface defects in the prior art, and improving the accuracy and completeness of detection.

CN119804500BActive Publication Date: 2025-07-18HUNAN MANJI ELECTRONIC TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411861684.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-07-18
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

In the prior art, when the surface defect of the sight lens is recognized by the front light image, abnormal reflection and scattering of the internal defects lead to inaccurate and incomplete identification of surface defects, affecting the accuracy of quality detection.

Method used

The front and backlight images at different wavelengths are combined, and the backlight fusion image of the inner defect area and the frontlight image of the surface defect area is obtained. The grayscale value, gradient value and edge detection algorithm are used, combined with dynamic time regularization algorithm and image fusion technology, the internal and surface defects of the sight lens are accurately identified.

Benefits of technology

It improves the accuracy and completeness of the sight lens defect detection, reduces the interference of internal defects on surface defect identification, enhances the visibility of defects, and ensures the accuracy of quality detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119804500B_ABST
    Figure CN119804500B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of image analysis, and particularly relates to a visual inspection method, device and system for a sight lens. The method acquires a front-illuminated image and a back-illuminated image of the sight lens; obtains an internal defect area according to the gray values of pixel points in the back-illuminated image; obtains a back-illuminated fusion image according to the gray distribution of the internal defect area in the back-illuminated image at each wavelength; obtains a surface defect area based on the gradient values of pixel points and the positions of edge pixel points in the front-illuminated image, the size of the internal defect area and the gray distribution in the back-illuminated fusion image; and obtains the defects in the sight lens according to the gray distribution of the back-illuminated fusion image and the surface defect area in the front-illuminated image at each wavelength. On the basis of first obtaining the internal defect area of the sight lens, the present invention obtains the surface defect area, reduces the interference of internal defects on the recognition of surface defects, and improves the accuracy of obtaining the defects of the sight lens.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image analysis, and particularly to a visual inspection method, device and system for a sight lens. Background Art

[0002] In current industrial production, the quality inspection of sight lenses is crucial to ensure that the sight lenses meet the requirements of accuracy and reliability. In existing methods, the visual inspection method for sight lenses usually involves two imaging techniques: front illumination detection and back illumination detection, which are used to identify surface defects and internal defects of the sight lenses and detect the quality of the sight lenses.

[0003] In the existing method, the front illumination image and the back illumination image are obtained by manually selecting the optimal wavelength. The back illumination image is processed by the Otsu threshold to obtain the internal defects of the sight lens, such as bubbles and cracks; the front illumination image is processed by edge detection to obtain the surface defects of the sight lens, such as scratches and stains. However, in actual situations, the principle of front illumination is based on the performance of reflected light for defect determination. When there are internal defects such as bubbles and cracks in the area where some surface defects are located, abnormal reflection and scattering will occur, weakening the performance of the surface defects in the front illumination image, resulting in inaccurate and incomplete identification of the surface defects of the sight lens through the front illumination image, and affecting the accurate detection of the quality of the sight lens. Summary of the Invention

[0004] In order to solve the technical problem of inaccurate and incomplete identification of the surface defects of the sight lens through the front illumination image, the purpose of the present invention is to provide a visual inspection method, device and system for a sight lens, and the specific technical solutions adopted are as follows:

[0005] In a first aspect, an embodiment of the present invention provides a visual inspection method for a sight lens, the method comprising the following steps:

[0006] Obtain the front illumination image and the back illumination image of the sight lens at different wavelengths;

[0007] According to the gray value of each pixel point in the back illumination image at each wavelength, obtain the internal defect area of the sight lens; according to the gray distribution of the internal defect area in the back illumination image at each wavelength, obtain the back illumination fusion image;

[0008] Based on the gradient value of each pixel point and the position of the edge pixel points in the front illumination image at each wavelength, the size of each internal defect area, the gray difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray distribution of the internal defect area in the back illumination fusion image, obtain the surface defect area of the sight lens;

[0009] Obtain the defects in the aiming lens according to the gray-scale distribution of the back-illuminated fusion image and the front-illuminated images of the surface defect areas at each wavelength.

[0010] Furthermore, the method for obtaining the internal defect area is as follows:

[0011] Obtain the average gray-scale value of all pixel points in the back-illuminated image at each wavelength as the target gray-scale value of the back-illuminated image at each wavelength;

[0012] Construct a two-dimensional coordinate system with the specified position in the back-illuminated image at each wavelength as the origin; wherein, the sizes of the back-illuminated images at each wavelength are the same;

[0013] For any coordinate in the two-dimensional coordinate system, obtain the difference between the gray-scale value of the pixel point at this coordinate in the back-illuminated image at each wavelength and the target gray-scale value of the back-illuminated image at the same wavelength as the gray-scale difference value of the pixel point at this coordinate at each wavelength;

[0014] Arrange the gray-scale difference values in ascending order according to the corresponding wavelengths to obtain a gray-scale difference value sequence as the wavelength-gray-scale difference value sequence of the pixel point at this coordinate;

[0015] Take the pixel points with a gray-scale value of 0 after threshold segmentation of the back-illuminated image at the specified wavelength as the initial internal defect pixel points of the aiming lens;

[0016] Take the coordinates corresponding to the initial internal defect pixel points as target coordinates. For any non-target coordinate, obtain the matching degree between the pixel point at this non-target coordinate and the pixel points at each target coordinate in the wavelength-gray-scale difference value sequence by the DTW algorithm, and use them as the suspected internal defect reference values of the pixel point at this non-target coordinate;

[0017] Take the result of normalizing the average value of the suspected internal defect reference values as the suspected internal defect degree of the pixel point at this non-target coordinate;

[0018] Obtain the internal defect pixel points of the aiming lens based on the suspected internal defect degree;

[0019] Take the area jointly composed of the initial internal defect pixel points and the internal defect pixel points as the internal defect area of the aiming lens.

[0020] Furthermore, the method for obtaining the internal defect pixel points of the aiming lens based on the suspected internal defect degree is as follows:

[0021] Divide the value range of the suspected internal defect degree evenly from small to large into a first preset number of reference intervals, and obtain the number of suspected internal defect degrees included in each reference interval as the first quantity corresponding to the reference interval;

[0022] Obtain the difference between the first quantity of each reference interval and the first quantity of its previous adjacent reference interval as the first difference;

[0023] Take the boundary value between the two reference intervals corresponding to the largest first difference as the suspected internal defect degree threshold;

[0024] When the suspected internal defect degree is greater than the suspected internal defect degree threshold, take the pixel points on the corresponding non-target coordinates as the internal defect pixel points of the aiming lens.

[0025] Further, the method for obtaining the backlight fusion image is as follows:

[0026] For the backlight image at any wavelength, take the average value of the gray values of the pixel points corresponding to the internal defect area in the backlight image as the internal defect gray reference value of the backlight image;

[0027] Obtain the average value of the gray values of all other pixel points except the pixel points corresponding to the internal defect area in the backlight image as the normal gray reference value of the backlight image;

[0028] Obtain the difference between the internal defect gray reference value and the normal gray reference value of the backlight image as the first eigenvalue of the backlight image;

[0029] Take the backlight image at the wavelength corresponding to the largest first eigenvalue as the backlight fusion image.

[0030] Further, the method for obtaining the surface defect area is as follows:

[0031] Construct a two-dimensional coordinate system with the specified position of the front light image at each wavelength as the origin; among them, the front light image and the backlight image at each wavelength have the same size;

[0032] When the pixel points at the same coordinates in the front light image at each wavelength are all edge pixel points, take the pixel points at the corresponding coordinates as the initial surface defect pixel points of the aiming lens;

[0033] Arrange the gradient values of the pixel points corresponding to each coordinate in the front light image at each wavelength in ascending order of wavelength to obtain the wavelength-gradient value sequence of the pixel points at each coordinate;

[0034] Take the coordinates corresponding to the initial surface defect pixels as reference coordinates. For any non-reference coordinate and any reference coordinate, use the DTW algorithm to obtain the matching degree between the pixel at the non-reference coordinate and the pixel at the reference coordinate in the wavelength-gradient value sequence as the reference matching degree;

[0035] According to the size of each internal defect area and the gray-scale difference of each internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength, obtain the overall surface interference degree of each internal defect area;

[0036] According to the positional relationship between the coordinates of the frontlight image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixels, and the gray-scale distribution of the internal defect area where the internal defect pixels are located in the backlight fusion image, obtain the surface defect interference degree of the pixel at each coordinate;

[0037] For any coordinate in the two-dimensional coordinate system, take the product of the surface defect interference degree of the pixel at this coordinate and the overall surface interference degree of the internal defect area where the pixel at this coordinate is located as the target surface defect degree of the pixel at this coordinate;

[0038] Take the result of normalizing the sum of the target surface defect degrees of the pixel at the non-reference coordinate and the pixel at the reference coordinate as the adjustment weight;

[0039] Take the product of the reference matching degree and the adjustment weight as the matching degree adjustment value;

[0040] Take the sum of the reference matching degree and the matching degree adjustment value as the corrected matching degree between the pixel at the non-reference coordinate and the pixel at the reference coordinate;

[0041] Take the result of normalizing the mean of the corrected matching degrees between the pixel at the non-reference coordinate and the pixels at each reference coordinate as the suspected surface defect degree of the pixel at the non-reference coordinate;

[0042] Evenly divide the value range of the suspected surface defect degree from small to large into a second preset number of target intervals, and obtain the number of suspected surface defect degrees included in each target interval as the second number corresponding to the target interval;

[0043] Obtain the difference between the second number of each target interval and the second number of its previous adjacent target interval as the second difference;

[0044] Take the boundary value between the two target intervals corresponding to the largest second difference as the suspected surface defect degree threshold;

[0045] When the suspected surface defect degree is greater than the suspected surface defect degree threshold, the pixel points on the corresponding non-reference coordinates are used as the surface defect pixel points of the sight lens;

[0046] The area composed of the initial surface defect pixel points and the surface defect pixel points is used as the surface defect area of the sight lens.

[0047] Further, the method for obtaining the overall surface interference degree is as follows:

[0048] For any internal defect area, the average gray value of the pixel points in the backlight image corresponding to the longest wavelength of the internal defect area is obtained as the first gray value of the internal defect area;

[0049] The average gray value of the pixel points in the backlight image corresponding to the shortest wavelength of the internal defect area is obtained as the second gray value of the internal defect area;

[0050] The result of negatively correlating and normalizing the difference between the first gray value and the second gray value is used as the stability degree of the internal defect area;

[0051] The average value of the normalized result of the area of the internal defect area and the stability degree is used as the overall surface interference degree of the internal defect area.

[0052] Further, the method for obtaining the surface defect interference degree is as follows:

[0053] When the coordinates of the front illumination image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel points, the coordinates where the coordinates of the front illumination image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel points are all used as special coordinates; among them, the internal defect pixel points include the initial internal defect pixel points;

[0054] For any special coordinate, the internal defect area where the internal defect pixel points on the special coordinate are located is used as the reference internal defect area, and the line segments from the centroid of the reference internal defect area to each of its edge pixel points are all used as reference line segments;

[0055] The reference line segment passing through the internal defect pixel points on the special coordinate is used as the target line segment;

[0056] The gray values of the pixel points passed by the target line segment in the backlight fusion image are curve-fitted according to the order of the target line segment from the centroid to the edge pixel points to obtain the target curve;

[0057] The absolute value of the tangent slope of the gray value corresponding to the pixel points on the special coordinate on the target curve is used as the surface defect interference degree of the pixel points on the special coordinate;

[0058] When the coordinates of the current illuminated image in the two-dimensional coordinate system are different from the coordinates corresponding to the internal defect pixels, the surface defect interference degree of the pixels at the corresponding coordinates is defaulted to 0.

[0059] Further, the method for obtaining the defects in the aiming lens according to the backlit fusion image and the gray-scale distribution of the frontlit images at each wavelength in the surface defect region is as follows:

[0060] For the frontlit image at any wavelength, the average value of the gray-scale values of the pixels corresponding to the surface defect region in the frontlit image is used as the surface defect gray-scale reference value of the frontlit image;

[0061] The average value of the gray-scale values of all other pixels except the pixels corresponding to the surface defect region in the frontlit image is obtained as the normal gray-scale reference value of the frontlit image;

[0062] The difference between the surface defect gray-scale reference value and the normal gray-scale reference value of the frontlit image is obtained as the second eigenvalue of the frontlit image;

[0063] The frontlit image corresponding to the wavelength with the largest second eigenvalue is used as the frontlit fusion image;

[0064] The backlit fusion image and the frontlit fusion image are fused into one image as the target image;

[0065] Defect detection is performed on the target image to obtain the defects in the aiming lens.

[0066] In a second aspect, another embodiment of the present invention provides a visual inspection device for an aiming lens, which includes: a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of any of the above methods are implemented.

[0067] In a third aspect, another embodiment of the present invention provides a visual inspection system for an aiming lens, which includes:

[0068] An image acquisition module, configured to acquire frontlit images and backlit images of the aiming lens at different wavelengths;

[0069] A backlit fusion image acquisition module, configured to obtain the internal defect region of the aiming lens according to the gray-scale value of each pixel in the backlit image at each wavelength; and obtain the backlit fusion image according to the gray-scale distribution of the internal defect region in the backlit image at each wavelength;

[0070] A surface defect area acquisition module, configured to acquire the surface defect area of the sight lens based on the gradient value of each pixel point in the front illumination image at each wavelength, the position of the edge pixel points, the size of each internal defect area, the gray-scale difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray-scale distribution of the internal defect area in the back illumination fusion image;

[0071] A processing module, configured to acquire the defects in the sight lens according to the gray-scale distribution of the back illumination fusion image and the surface defect area in the front illumination images at each wavelength.

[0072] The present invention has the following beneficial effects:

[0073] According to the gray-scale value of each pixel point in the back illumination image at each wavelength, the present invention acquires the internal defect area of the sight lens, which is beneficial to subsequent analysis of the interference of the internal defects on the surface defect recognition of the sight lens, so as to more accurately identify the surface defects of the sight lens; in order to improve the accuracy of subsequent acquisition of the defects of the sight lens, the back illumination fusion image is acquired according to the gray-scale distribution of the internal defect area in the back illumination images at each wavelength, so that the internal defect area is the most prominent, and at the same time, it is beneficial to more detailed analysis of the interference degree of each internal defect pixel point in the internal defect area on the surface defect recognition; furthermore, based on the gradient value of each pixel point in the front illumination image at each wavelength, the position of the edge pixel points, the size of each internal defect area, the gray-scale difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray-scale distribution of the internal defect area in the back illumination fusion image, the surface defect area of the sight lens is accurately acquired, effectively reducing the interference of the internal defect area on the recognition of the surface defect area; improving the integrity and accuracy of the surface defect area; in order to accurately acquire the defects in the sight lens, the front illumination fusion image is accurately determined according to the gray-scale distribution of the surface defect area in the front illumination images at each wavelength, so that the surface defect area is the most prominent; further, the back illumination fusion image and the front illumination fusion image are fused to enhance the visibility of the defects in the sight lens, improve the accuracy of the defect detection of the sight lens, and then accurately acquire the defects in the sight lens. Description of the Drawings

[0074] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0075] Figure 1Schematic flowchart of a visual inspection method for a sight lens provided by an embodiment of the present invention;

[0076] Figure 2 Flowchart of a method for obtaining a surface defect area provided by an embodiment of the present invention;

[0077] Figure 3 Flowchart of a method for obtaining a corrected matching degree provided by an embodiment of the present invention;

[0078] Figure 4 Structural diagram of a visual inspection system for a sight lens provided by an embodiment of the present invention;

[0079] Figure 5 Schematic diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners

[0080] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the intended invention purpose, the following combines the accompanying drawings and preferred embodiments to detail the specific implementation manners, structures, features and effects of a visual inspection method, device and system for a sight lens proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.

[0081] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.

[0082] The following specifically describes the specific solutions of a visual inspection method, device and system for a sight lens provided by the present invention with reference to the accompanying drawings.

[0083] Embodiment 1:

[0084] The present invention proposes a visual inspection method for a sight lens. Please refer to Figure 1 , which shows a schematic flowchart of a visual inspection method for a sight lens provided by an embodiment of the present invention. The method includes the following steps:

[0085] Step S1: Obtain the front-illuminated image and the back-illuminated image of the sight lens at different wavelengths.

[0086] Specifically, fix the sight lens on the stage, and irradiate the sight lens with front illumination light and back illumination light respectively to obtain the front illumination image and back illumination image of the sight lens. The specific operations are as follows: Turn off the back illumination light and turn on the front illumination light. Irradiate the surface of the sight lens with the light source. When there are defects on the surface of the sight lens, the defects on the surface of the sight lens will generate scattered light; when there are no defects on the surface of the sight lens, reflected light will be generated on the surface of the sight lens; the CMOS image sensor only receives the scattered light and does not receive the reflected light. Therefore, when there are defects on the surface of the sight lens, the scattered light passes through the telecentric lens and presents on the CMOS image sensor to form a front illumination image with a dark background and bright defects. Turn off the front illumination light and turn on the back illumination light. The light source is incident from the back of the sight lens. When there are no defects inside the sight lens, the light source undergoes transmission; when there are defects inside the sight lens, the light source undergoes refraction; the CMOS image sensor only receives the transmitted light and does not receive the refracted light. Therefore, when there are defects inside the sight lens, the transmitted light passes through the telecentric lens and presents on the CMOS image sensor to form a back illumination image with a bright background and dark defects. Therefore, the front illumination image mainly detects the surface defects of the sight lens, such as scratches and stains, etc.; the back illumination image mainly detects the internal defects of the sight lens, such as bubbles and cracks, etc.

[0087] Among them, the light source selects a red low-angle ring light as the front illumination light and a red parallel light as the back illumination light. The acquisition system selects an object-side telecentric lens with a working distance of 110 mm, a magnification of 0.8x, and a depth of field of 1.52 nm.

[0088] In actual situations, collecting the front illumination image and back illumination image of the sight lens with a light source at a fixed wavelength will result in inaccurate positioning of some defects. At the same time, the reflection, scattering, and transmission phenomena of sight lenses with different structural properties are different at different wavelengths. Therefore, the defects obtained from the front illumination image and back illumination image of the sight lens at a fixed wavelength are inaccurate. Furthermore, in this embodiment, the front illumination image and back illumination image of the sight lens at different wavelengths are obtained.

[0089] In this embodiment, the wavelength range is set from 380 nm to 740 nm. Set 380 nm as the initial wavelength, set the step size to 5 nm, and increase the wavelength from the initial wavelength according to the step size until the wavelength reaches 740 nm. Then, the front illumination image and back illumination image of the sight lens at each wavelength are obtained in turn. It is known that the wavelength range from 380 nm to 740 nm is the visible light wavelength range. Some sight lenses may be optimized for specific wavelengths. For example, for the green light band in sunlight, the wavelength range can be gradually collected from 495 nm to 570 nm at this time, and the step size can also be adjusted. The implementer can set the wavelength range and step size according to the actual situation, and no limitation is made here.

[0090] In order to facilitate the subsequent accurate and efficient identification of defects in the sight lens, in this embodiment, the front-illumination images and back-illumination images of the sight lens at different wavelengths are both grayscale processed. Among them, grayscale processing is a well-known technology and will not be elaborated here.

[0091] Step S2: Obtain the internal defect area of the sight lens according to the grayscale value of each pixel point in the back-illumination image at each wavelength; obtain the back-illumination fusion image according to the grayscale distribution of the internal defect area in the back-illumination image at each wavelength.

[0092] Specifically, in actual situations, the change in wavelength will change the light performance such as the transmittance and reflectivity of the sight lens. Among them, the internal defects in the sight lens change significantly with the change in wavelength and are minimally affected by surface defects. Since the principle of the front-illumination image is based on the performance of reflected light, when there are internal defects in the sight lens such as bubbles or inclusions, it will cause abnormal reflection or weakening of the scattering performance of the front-illumination light, and then the surface defects in the obtained front-illumination image are inaccurate, indirectly indicating that the detection of surface defects in the sight lens is greatly affected by internal defects. Therefore, in this embodiment, first, the internal defect area of the sight lens is obtained according to the grayscale value of each pixel point in the back-illumination image at each wavelength, and then based on the performance of the internal defect area, the recognition effect of surface defects in the front-illumination image is optimized, and finally the fusion result of the front-illumination image and the back-illumination image is optimized to accurately obtain the defects of the sight lens.

[0093] In order to accurately reflect the internal defect area and enable more accurate subsequent identification of surface defects of the sight lens and more accurate acquisition of the defects of the sight lens, in this embodiment, the grayscale distribution of the internal defect area in the back-illumination image at each wavelength is analyzed. When the performance of the internal defect area in the back-illumination image is more obvious, it indicates that the back-illumination image at the corresponding wavelength is more accurate in the subsequent identification of the defects of the sight lens. Therefore, in this embodiment, the back-illumination fusion image is obtained according to the grayscale distribution of the internal defect area in the back-illumination image at each wavelength.

[0094] Preferably, in an implementable manner of this embodiment, the method for obtaining the internal defect area is as follows: Obtain the average gray value of all pixel points in the backlight image at each wavelength as the target gray value of the backlight image at each wavelength; Construct a two-dimensional coordinate system with the specified position in the backlight image at each wavelength as the origin; where the sizes of the backlight images at each wavelength are the same; In this embodiment, the specified position is set to the lower left corner of each backlight image, and the implementer can set the specified position according to the actual situation, which is not limited here. It should be noted that the coordinate points corresponding to the pixel points at the same position in the backlight images at each wavelength are the same. For any coordinate in the two-dimensional coordinate system, obtain the difference between the gray value of the pixel point at this coordinate in the backlight image at each wavelength and the target gray value of the backlight image at the same wavelength as the gray difference value of the pixel point at this coordinate at each wavelength; Arrange the gray difference values in ascending order according to the corresponding wavelengths to obtain a gray difference value sequence as the wavelength-gray difference value sequence of the pixel point at this coordinate; where when the area where the pixel point at a certain coordinate is located is the normal area of the sight lens, the curve fitted by the wavelength-gray difference value sequence of the pixel point at this coordinate is almost a horizontal straight line;

[0095] In actual situations, the change in the wavelength of the backlight will significantly affect the light transmittance of the sight lens. Among them, when the wavelength of the backlight is longer, the edge of the internal defect is softer; when the wavelength of the backlight is shorter, the edge of the internal defect is sharper. Therefore, it can be inferred that the internal defects of the sight lens are more obvious when the wavelength of the backlight is shorter. In this embodiment, in order to initially and accurately determine the internal defect pixel points of the sight lens, the initial wavelength of 380 nm is then set as the specified wavelength, and then the pixel points with a gray value of 0 after threshold segmentation of the backlight image at the specified wavelength are used as the initial internal defect pixel points of the sight lens; where threshold segmentation is a well-known technology and will not be elaborated here. It should be noted that the position where the initial internal defect pixel points are located must be the internal defect area of the sight lens. Therefore, the pixel points in the backlight images at each wavelength corresponding to the coordinates of the initial internal defect pixel points are all initial internal defect pixel points;

[0096] It is known that backlight with different wavelengths has different effects on the light transmittance of the aiming device lens. To avoid incomplete recognition of internal defective pixel points in the aiming device lens, in this embodiment, non-initial internal defective pixel points are compared with initial internal defective pixel points to screen out the internal defective pixel points among the non-initial internal defective pixel points, and the internal defective area of the aiming device lens is accurately obtained. Therefore, the coordinates corresponding to the initial internal defective pixel points are all used as target coordinates. For any non-target coordinate, the matching degree of the wavelength-gray value difference sequence between the pixel point at this non-target coordinate and the pixel points at each target coordinate is obtained through the Dynamic Time Warping (DTW) algorithm, and it is used as the suspected internal defect reference value of the pixel point at this non-target coordinate. The larger the suspected internal defect reference value, the more similar the wavelength-gray value difference sequence of the pixel point at this non-target coordinate is to the wavelength-gray value difference sequence corresponding to the corresponding initial internal defective pixel point, indirectly indicating that the pixel point at this non-target coordinate is more likely to be an internal defective pixel point. Among them, the Dynamic Time Warping (DTW) algorithm is a well-known technology and will not be elaborated here. To comprehensively analyze the possibility that the pixel point at this non-target coordinate is an internal defective pixel point, the normalized result of the average value of the suspected internal defect reference values is used as the suspected internal defect degree of the pixel point at this non-target coordinate. In this embodiment, the average value of the suspected internal defect reference values is normalized through the norm normalization function. Among them, the larger the suspected internal defect degree, the more likely the pixel point at this non-target coordinate is an internal defective pixel point of the aiming device lens. Therefore, in this embodiment, the internal defective pixel points of the aiming device lens are obtained based on the suspected internal defect degree. Finally, the area jointly composed of the initial internal defective pixel points and the internal defective pixel points is used as the internal defective area of the aiming device lens. It should be noted that the connected component determination is used in the process of obtaining the internal defective area. Among them, the acquisition of the connected component is a well-known technology and will not be elaborated here.

[0097] In a feasible implementation manner of this embodiment, the method for obtaining the internal defect pixels of the sight lens based on the suspected internal defect degree is as follows: The value range of the suspected internal defect degree is evenly divided into a first preset number of reference intervals from small to large. It is known that the value range of the suspected internal defect degree is from 0 to 1. In this embodiment, the first preset number is set to 10, and the implementer can set the size of the first preset number according to the actual situation, which is not limited here. Therefore, the value range of the suspected internal defect degree is evenly divided into 10 reference intervals from small to large, which are [0~0.1), [0.1~0.2), …, [0.9~1]. Obtain the number of suspected internal defect degrees included in each reference interval as the first number corresponding to the reference interval; obtain the absolute value of the difference between the first number of each reference interval and the first number of its previous adjacent reference interval as the first difference; take the boundary value between the two reference intervals corresponding to the largest first difference as the suspected internal defect degree threshold; for example, if the first difference between [0.4~0.5) and [0.5,0.6) is the largest, then take 0.5 as the suspected internal defect degree threshold. It should be noted that selecting the boundary value between the two reference intervals corresponding to the largest first difference as the suspected internal defect degree threshold can more accurately distinguish the internal defect pixels of the sight lens from the normal pixels. When the suspected internal defect degree is greater than the suspected internal defect degree threshold, the pixels at the corresponding non-target coordinates are used as the internal defect pixels of the sight lens, and the internal defect pixels are accurately screened out from the non-initial internal defect pixels.

[0098] Preferably, in a feasible implementation manner of this embodiment, the method for obtaining the back-illuminated light fusion image is as follows: For the back-illuminated light image at any wavelength, take the average value of the gray values of the pixels corresponding to the internal defect area in the back-illuminated light image as the internal defect gray reference value of the back-illuminated light image; obtain the average value of the gray values of all other pixels except the pixels corresponding to the internal defect area in the back-illuminated light image as the normal gray reference value of the back-illuminated light image; the greater the difference between the internal defect gray reference value and the normal gray reference value of the back-illuminated light image, the more obvious the internal defect area is in the back-illuminated light image. Furthermore, in this embodiment, obtain the absolute value of the difference between the internal defect gray reference value and the normal gray reference value of the back-illuminated light image as the first feature value of the back-illuminated light image; the larger the first feature value, the more likely the back-illuminated light image is the back-illuminated light fusion image for accurately obtaining the defects of the sight lens in the subsequent process; therefore, in this embodiment, the back-illuminated light image at the wavelength corresponding to the largest first feature value is used as the back-illuminated light fusion image.

[0099] Step S3: Based on the gradient value of each pixel point in the front illumination image at each wavelength, the position of the edge pixel points, the size of each internal defect area, the gray-scale difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray-scale distribution of the internal defect area in the back illumination fused image, obtain the surface defect area of the sight lens.

[0100] In actual situations, as the wavelength of the front illumination changes, the surface defects of the sight lens may appear enhanced or weakened in the front illumination image, that is, during the change of the front illumination wavelength, the edges of the surface defects in the front illumination image will change from clear to blurred. Therefore, in this embodiment, first, the Canny edge detection algorithm is used to obtain the edge pixel points in the front illumination image at each wavelength. Then, based on the positions of the edge pixel points in the front illumination image at each wavelength, the initial surface defect pixel points of the sight lens are preliminarily determined. Finally, based on the similarity of the gradient values of the non-initial surface defect pixel points and the initial surface defect pixel points in the front illumination image at each wavelength, the surface defect pixel points among the non-initial surface defect pixel points are screened out, so as to accurately detect the surface defect area of the sight lens. Among them, the Canny edge detection algorithm is a well-known technology and will not be elaborated here. It should be noted that the gradient value of each pixel point in the front illumination image at each wavelength can be obtained through the Canny edge detection algorithm.

[0101] Considering that the internal defects of the sight lens will interfere with the identification of surface defects, that is, weaken the performance of surface defects in the front illumination image. Therefore, in this embodiment, further combined with the size of each internal defect area, the gray-scale difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray-scale distribution of the internal defect area in the back illumination fused image, the identification of the surface defect area of the sight lens is optimized to more accurately obtain the surface defect area of the sight lens. Furthermore, in this embodiment, based on the gradient value of each pixel point in the front illumination image at each wavelength, the position of the edge pixel points, the size of each internal defect area, the gray-scale difference of each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray-scale distribution of the internal defect area in the back illumination fused image, the surface defect area of the sight lens is obtained.

[0102] Preferably, in a feasible implementation manner of this embodiment, for the method of obtaining the surface defect area, please refer to Figure 2 which shows a flowchart of a method for obtaining the surface defect area provided in this embodiment. The method includes the following steps:

[0103] Step S201: Obtain the initial surface defect pixel points.

[0104] First, a two-dimensional coordinate system is constructed with the specified position in the front illumination image at each wavelength as the origin. The specified position here is the same as that in step S2. Since the sizes of the front illumination images at each wavelength are the same as those of the back illumination images, the coordinate distributions of the pixel points in the front illumination images are exactly the same as those of the pixel points in the back illumination images. Given that the front illumination images have a dark background and bright defects, the edge pixel points in the back illumination images are more likely to be the surface defect pixel points of the sight lens. Considering that the edge pixel points in the front illumination images obtained by the front illumination lights of different wavelengths are different, in order to accurately obtain the surface defect pixel points of the sight lens, when the pixel points at the same coordinates in the front illumination images at each wavelength are all edge pixel points, the pixel points at the corresponding coordinates are used as the initial surface defect pixel points of the sight lens.

[0105] So far, the initial surface defect pixel points of the sight lens are determined.

[0106] Step S202: Obtain the reference matching degree.

[0107] Given that the front illumination lights of different wavelengths will affect the performance of the surface defect pixel points of the sight lens, in order to completely identify the surface defect pixel points of the sight lens, the gradient values of the pixel points corresponding to each coordinate in the front illumination images at each wavelength in the two-dimensional coordinate system are arranged in ascending order of wavelength, and a wavelength-gradient value sequence of the pixel points at each coordinate is obtained; then the coordinates corresponding to the initial surface defect pixel points are used as reference coordinates. For any non-reference coordinate and any reference coordinate, the matching degree of the wavelength-gradient value sequence between the pixel points at the non-reference coordinate and the pixel points at the reference coordinate is obtained through the Dynamic Time Warping (DTW) algorithm as the reference matching degree. The greater the reference matching degree, the more similar the wavelength-gradient value sequence of the pixel points at the non-reference coordinate is to that of the pixel points at the reference coordinate, indirectly indicating that the pixel points at the non-reference coordinate are more likely to be the surface defect pixel points of the sight lens.

[0108] Step S203: Obtain the corrected matching degree.

[0109] Considering that the internal defect area interferes with the identification of the surface defect area of the sight lens, in this embodiment, the reference matching degree is corrected based on the internal defect area to obtain the corrected matching degree, which is beneficial to accurately analyzing whether the pixel points at the non-reference coordinates are the surface defect pixel points of the sight lens in the subsequent process.

[0110] Preferably, in a feasible implementation manner of this embodiment, for the method of obtaining the corrected matching degree, please refer to Figure 3 , which shows a flowchart of a method for obtaining the corrected matching degree provided in this embodiment. The method includes the following steps:

[0111] Step S203-1: Obtain the overall surface interference degree of each internal defect area according to the size of each internal defect area and the gray-scale difference of each internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength.

[0112] The area size of each internal defect area is obtained through a contour algorithm. Here, the contour algorithm is a well-known technology and will not be elaborated further. When the area of a certain internal defect area is larger, it indicates that the influence of this internal defect area on the front light is greater, and the interference generated when identifying the surface defect pixel points of the sight lens is greater. At the same time, when the gray-scale difference of this internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength is smaller, it indicates that this internal defect area is more stable, indirectly reflecting that the interference generated by this internal defect area when identifying the surface defect pixel points of the sight lens is greater. Therefore, in this embodiment, the overall surface interference degree of each internal defect area is obtained according to the size of each internal defect area and the gray-scale difference of each internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength. The greater the overall surface interference degree, the greater the interference generated by the corresponding internal defect area when identifying the surface defect pixel points of the sight lens.

[0113] Preferably, in a feasible implementation manner of this embodiment, the method for obtaining the overall surface interference degree is as follows: For any internal defect area, obtain the average gray-scale value of the pixel points of this internal defect area in the backlight image corresponding to the longest wavelength as the first gray-scale value of this internal defect area; obtain the average gray-scale value of the pixel points of this internal defect area in the backlight image corresponding to the shortest wavelength as the second gray-scale value of this internal defect area. When the first gray-scale value and the second gray-scale value are more equal, it indicates that this internal defect area is more stable and thus the interference caused when identifying the surface defect pixel points is greater, that is, it weakens the appearance of the surface defect pixel points in the front light image. Furthermore, in this embodiment, the result of taking the absolute value of the difference between the first gray-scale value and the second gray-scale value and performing negative correlation and normalization is used as the stability degree of this internal defect area; the greater the stability degree, the greater the interference degree of this internal defect area on the recognition of surface defects in the front light image. It is known that the larger the area of this internal defect area, it also indicates that the interference degree of this internal defect area on the recognition of surface defects in the front light image is greater. Then, obtain the average value of the result of normalizing the area of this internal defect area and the stability degree as the overall surface interference degree of this internal defect area.

[0114] Among them, the calculation formula for the overall surface interference degree is: In the formula, A n is the overall surface interference degree of the nth internal defect area; s n is the area of the nth internal defect area; h n,1is the first grayscale value of the nth internal defect area; h n,2 is the second grayscale value of the nth internal defect area; || is the absolute value function; exp(-|h n,1 -h n,2 |) is the stability degree of the nth internal defect area; norm is the normalization function; exp is the exponential function with the natural constant as the base.

[0115] Thus, the overall surface interference degree of each internal defect area is obtained.

[0116] Step S203-2: According to the positional relationship between the coordinates of the front-illuminated image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the grayscale distribution of the internal defect area where the internal defect pixel points are located in the back-illuminated fusion image, obtain the surface defect interference degree of the pixel points at each coordinate.

[0117] In order to accurately identify the surface defect pixel points in the front-illuminated image, in this embodiment, first, according to the positional relationship between the coordinates of the front-illuminated image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, the pixel points in the front-illuminated image that coincide with the internal defect pixel points are determined. Then, combined with the grayscale distribution of the internal defect pixel points in the back-illuminated fusion image, the interference degree of the internal defect pixel points on the identification of the surface defect pixel points is analyzed, which is beneficial to accurately obtaining the possibility of each non-initial surface defect pixel point being a surface defect pixel point in the subsequent process. Furthermore, in this embodiment, according to the positional relationship between the coordinates of the front-illuminated image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the grayscale distribution of the internal defect area where the internal defect pixel points are located in the back-illuminated fusion image, the surface defect interference degree of the pixel points at each coordinate is obtained, which accurately reflects the interference degree of the internal defects on the pixel points at each coordinate when analyzing whether they are surface defect pixel points.

[0118] Preferably, in an implementable manner of this embodiment, the method for obtaining the surface defect interference degree is as follows: when the coordinates of the current front-illuminated image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel points, the coordinates of the front-illuminated image in the two-dimensional coordinate system that are the same as the coordinates corresponding to the internal defect pixel points are all used as special coordinates; among them, the internal defect pixel points include initial internal defect pixel points; for any special coordinate, the internal defect area where the internal defect pixel point is located at this special coordinate is used as the reference internal defect area, and the centroid and edge pixel points of the reference internal defect area are obtained through the contour algorithm, and then the line segments from the centroid of the reference internal defect area to each of its edge pixel points are all used as reference line segments; the reference line segment passing through the internal defect pixel point at this special coordinate is used as the target line segment; the gray values of the pixel points passed by the target line segment in the back-illuminated fusion image are curve-fitted according to the order of the target line segment from the centroid to the edge pixel point to obtain the target curve; among them, the method of fitting the curve is a well-known technology and will not be elaborated here. The absolute value of the tangent slope of the gray value corresponding to the pixel point at this special coordinate on the target curve is used as the surface defect interference degree of the pixel point at this special coordinate; the greater the surface defect interference degree, it indicates that the internal defect pixel point corresponding to this special coordinate has a greater impact on the front-illuminated light, and the pixel point at this special coordinate is more interfered by the internal defect when identifying whether it is a surface defect pixel point;

[0119] When the coordinates of the current front-illuminated image in the two-dimensional coordinate system are not the same as the coordinates corresponding to the internal defect pixel points, it indicates that at this time, the internal defect will not affect the gray value of the pixel points in the front-illuminated image. In this embodiment, the surface defect interference degree of the pixel points at the corresponding coordinates, that is, the coordinates that are not the same as the coordinates corresponding to the internal defect pixel points, is directly defaulted to 0.

[0120] Thus, the surface defect interference degree of the pixel points at each coordinate is obtained.

[0121] Step S203-3: Obtain the target surface defect degree.

[0122] In order to accurately represent the interference degree of the internal defect on the pixel points at each coordinate, for any coordinate in the two-dimensional coordinate system, the product of the surface defect interference degree of the pixel point at this coordinate and the overall surface interference degree of the internal defect area where the pixel point at this coordinate is located is used as the target surface defect degree of the pixel point at this coordinate. The greater the target surface defect degree, the greater the interference degree of the internal defect on the pixel point at this coordinate when analyzing whether it is a surface defect pixel point. It should be noted that if the pixel point at this coordinate is not in the internal defect area, the target surface defect degree of the pixel point at this coordinate is defaulted to 0.

[0123] So far, the target surface defect degree of the pixel points on each coordinate is obtained.

[0124] Step S203-4: Obtain the correction matching degree.

[0125] For a pixel point on a non-reference coordinate and a pixel point on a reference coordinate, the result of normalizing the sum of the target surface defect degrees of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is used as the adjustment weight; the larger the adjustment weight, the greater the degree of interference of internal defects on the pixel point on the non-reference coordinate and the pixel point on the reference coordinate. In order to reduce the weakening effect of internal defects on the recognition of surface defects, the product of the reference matching degree and the adjustment weight of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is used as the matching degree adjustment value; then, the sum of the reference matching degree and the matching degree adjustment value of the pixel point on the non-reference coordinate and the pixel point on the reference coordinate is used as the correction matching degree between the pixel point on the non-reference coordinate and the pixel point on the reference coordinate. The larger the correction matching degree, the more similar the performance of the non-initial surface defect pixel point corresponding to the non-reference coordinate and the initial surface defect pixel point corresponding to the reference coordinate, and the more likely the non-initial surface defect pixel point corresponding to the non-reference coordinate is the surface defect pixel point of the aiming lens.

[0126] Among them, the calculation formula of the correction matching degree is: In the formula, D j,m ′ is the correction matching degree between the pixel point on the jth non-reference coordinate and the pixel point on the mth reference coordinate; D j,m is the reference matching degree between the pixel point on the jth non-reference coordinate and the pixel point on the mth reference coordinate; is the target surface defect degree of the pixel point on the jth non-reference coordinate; is the target surface defect degree of the pixel point on the mth reference coordinate; norm is the normalization function; is the adjustment weight; is the matching degree adjustment value.

[0127] Step S204: Obtain the surface defect pixel points.

[0128] In order to analyze the possibility that the pixel points at each non-reference coordinate are surface defect pixel points, and then for any non-reference coordinate, the normalized result of the average value of the corrected matching degrees between the pixel points at this non-reference coordinate and the pixel points at each reference coordinate is used as the suspected surface defect degree of the pixel points at this non-reference coordinate. The greater the suspected surface defect degree, the more likely the pixel points at this non-reference coordinate are surface defect pixel points. It should be noted that in this embodiment, the norm normalization function is used to normalize the average value of the corrected matching degrees between the pixel points at this non-reference coordinate and the pixel points at each reference coordinate. Thus, the suspected surface defect degree of the pixel points at each non-reference coordinate is obtained. Among them, the value range of the suspected surface defect degree is from 0 to 1.

[0129] In order to screen out the surface defect pixel points among the non-initial surface defect pixel points through the suspected surface defect degree, so as to make the surface defect recognition of the aiming lens more complete. Furthermore, in this embodiment, the value range of the suspected surface defect degree is evenly divided into a second preset number of target intervals from small to large. In this embodiment, the second preset number is set to 10, and the implementer can set the size of the second preset number according to the actual situation, which is not limited here. Therefore, the value range of the suspected surface defect degree is evenly divided into 10 target intervals from small to large, which are [0~0.1), [0.1~0.2), …, [0.9~1]. Obtain the number of suspected surface defect degrees included in each target interval as the second number corresponding to the target interval; obtain the absolute value of the difference between the second number of each target interval and the second number of its previous adjacent target interval as the second difference; take the boundary value between the two target intervals corresponding to the largest second difference as the suspected surface defect degree threshold. When the suspected surface defect degree is greater than the suspected surface defect degree threshold, the pixel points at the corresponding non-reference coordinate are used as the surface defect pixel points of the aiming lens; accurately screen out the surface defect pixel points from the non-initial surface defect pixel points.

[0130] Step S205: Obtain the surface defect area.

[0131] The area formed by the initial surface defect pixel points and the surface defect pixel points together is used as the surface defect area of the aiming lens. It should be noted that the connected domain determination is used in the process of obtaining the surface defect area.

[0132] Step S4: Obtain the defects in the aiming lens according to the gray distribution of the backlight fusion image and the front light image at each wavelength in the surface defect area.

[0133] In order to enhance the visibility of defects in the sight lens and improve the accuracy of defect detection in the sight lens, in this embodiment, first, based on the gray-scale distribution of the front-illumination image of the surface defect area at each wavelength, a front-illumination fusion image is obtained; then, the front-illumination fusion image and the back-illumination fusion image are fused into one image through an image fusion algorithm; among them, the image fusion algorithm is a well-known technology and will not be elaborated here. Finally, the fused image is inspected for defects, ensuring the integrity and accuracy of the defects and accurately obtaining the defects in the sight lens.

[0134] Preferably, in an implementable manner of this embodiment, the method for obtaining the front-illumination fusion image is as follows: for the front-illumination image at any wavelength, the mean value of the gray-scale values of the corresponding pixel points of the surface defect area in this front-illumination image is used as the surface defect gray-scale reference value of this front-illumination image; the mean value of the gray-scale values of all other pixel points except the pixel points corresponding to the surface defect area in this front-illumination image is obtained as the normal gray-scale reference value of this front-illumination image; when the difference between the surface defect gray-scale reference value and the normal gray-scale reference value of this front-illumination image is larger, it indicates that the surface defect area is more obvious in this front-illumination image. Therefore, in this embodiment, the absolute value of the difference between the surface defect gray-scale reference value and the normal gray-scale reference value of this front-illumination image is used as the second eigenvalue of this front-illumination image; the larger the second eigenvalue, the more likely this front-illumination image is to be the front-illumination fusion image for accurately obtaining the defects of the sight lens in the subsequent fusion. Therefore, in this embodiment, the front-illumination image at the wavelength corresponding to the largest second eigenvalue is used as the front-illumination fusion image.

[0135] The back-illumination fusion image and the front-illumination fusion image are fused into one image through an image fusion algorithm as the target image; the target image is inspected for defects, and then the defects in the sight lens are obtained, making the defect recognition of the sight lens more accurate and complete, and then accurately detecting the quality of the sight lens.

[0136] In summary, in this embodiment, the front-illumination image and the back-illumination image of the sight lens are obtained; the internal defect area is obtained according to the gray-scale values of the pixel points in the back-illumination image; the back-illumination fusion image is obtained according to the gray-scale distribution of the internal defect area in the back-illumination image at each wavelength; the surface defect area is obtained based on the gradient values of the pixel points in the front-illumination image, the positions of the edge pixel points, the size of the internal defect area, and the gray-scale distribution in the back-illumination fusion image; the defects in the sight lens are obtained according to the gray-scale distribution of the back-illumination fusion image and the surface defect area in the front-illumination image at each wavelength. The present invention obtains the surface defect area on the basis of first obtaining the internal defect area of the sight lens, reducing the interference of the internal defects on the recognition of the surface defects and improving the accuracy of obtaining the defects of the sight lens.

[0137] Embodiment 2:

[0138] The present invention also provides a visual inspection system for a sight lens. Please refer to Figure 4 , which shows a structural diagram of a visual inspection system for a sight lens provided by an embodiment of the present invention. The system includes: an image acquisition module 10, a backlight fusion image acquisition module 20, a surface defect area acquisition module 30, and a processing module 40.

[0139] The image acquisition module 10 is configured to acquire a front illumination image and a back illumination image of the sight lens at different wavelengths.

[0140] The backlight fusion image acquisition module 20 is configured to obtain the internal defect area of the sight lens according to the gray value of each pixel point in the backlight image at each wavelength; and obtain the backlight fusion image according to the gray distribution of the internal defect area in the backlight image at each wavelength.

[0141] The surface defect area acquisition module 30 is configured to obtain the surface defect area of the sight lens based on the gradient value of each pixel point and the position of the edge pixel points in the front illumination image at each wavelength, the size of each internal defect area, the gray difference of each internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength, and the gray distribution of the internal defect area in the backlight fusion image.

[0142] The processing module 40 is configured to obtain the defects in the sight lens according to the gray distribution of the backlight fusion image and the surface defect area in the front illumination image at each wavelength.

[0143] It should be noted that: for the system provided in the above embodiment, only the division of the above functional modules is used for illustration. In actual applications, the above functions can be allocated to different functional modules as needed, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the visual inspection system for a sight lens provided in the above embodiment and the embodiment of the visual inspection method for a sight lens belong to the same concept. For the specific implementation process, please refer to the method embodiment, which will not be elaborated here.

[0144] Embodiment 3:

[0145] The present invention also provides a visual inspection device for a sight lens. The device includes a memory and a processor. The memory stores executable program code, and the processor is configured to call and execute the executable program code to perform a visual inspection method for a sight lens provided in an embodiment of the present application. The device may specifically be a chip, a component, or a module. The chip may include a processor and a memory connected thereto. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can perform a visual inspection method for a sight lens provided in the above embodiment.

[0146] In addition, embodiments of the present application also protect a computer device. Please refer to Figure 5 , the computer device includes a memory 401, a processor 402, and a computer program 403 stored in the memory 401 and running on the processor 402. When the processor 402 executes the computer program 403, the computer device can execute any one of the visual inspection methods for a sight lens introduced above.

[0147] Embodiment 4:

[0148] This embodiment also provides a computer-readable storage medium. The computer-readable storage medium stores computer program code. When the computer program code runs on a computer, the computer is caused to execute the above-related method steps to implement a visual inspection method for a sight lens provided in the above embodiment.

[0149] Embodiment 5:

[0150] This embodiment also provides a computer program product. When the computer program product runs on a computer, the computer is caused to execute the above-related steps to implement a visual inspection method for a sight lens provided in the above embodiment.

[0151] Among them, the device, computer-readable storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here.

[0152] It should be noted that the above sequence of embodiments of the present invention is only for description and does not represent the superiority or inferiority of the embodiments. The processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0153] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the key points of each embodiment are the differences from other embodiments.

Claims

1. A visual inspection method for a sight lens, characterized in that, The method includes the following steps: Obtain the front-illuminated image and the back-illuminated image of the sight lens at different wavelengths; Obtain the internal defect area of the sight lens according to the gray value of each pixel point in the back-illuminated image at each wavelength; obtain the back-illuminated fusion image according to the gray distribution of the internal defect area in the back-illuminated image at each wavelength; Based on the gradient value of each pixel point and the position of the edge pixel points in the front-illuminated image at each wavelength, the size of each internal defect area, the gray difference of each internal defect area in the back-illuminated images corresponding to the longest wavelength and the shortest wavelength, and the gray distribution of the internal defect area in the back-illuminated fusion image, obtain the surface defect area of the sight lens; Obtain the defects in the sight lens according to the gray distribution of the back-illuminated fusion image and the surface defect area in the front-illuminated image at each wavelength; The method for obtaining the internal defect area is as follows: Obtain the average gray value of all pixel points in the back-illuminated image at each wavelength as the target gray value of the back-illuminated image at each wavelength; Construct a two-dimensional coordinate system with the specified position of the back-illuminated image at each wavelength as the origin; wherein, the sizes of the back-illuminated images at each wavelength are the same; For any coordinate in the two-dimensional coordinate system, obtain the difference between the gray value of the pixel point at this coordinate in the back-illuminated image at each wavelength and the target gray value of the back-illuminated image at the same wavelength as the gray difference value of the pixel point at this coordinate at each wavelength; Arrange the gray difference values in ascending order according to the corresponding wavelengths to obtain a gray difference value sequence as the wavelength-gray difference value sequence of the pixel point at this coordinate; The pixel points with a gray value of 0 after threshold segmentation of the back-illuminated image at the specified wavelength are used as the initial internal defect pixel points of the sight lens; Take the coordinates corresponding to the initial internal defect pixel points as the target coordinates. For any non-target coordinate, obtain the matching degree of the wavelength-gray difference value sequence between the pixel point at this non-target coordinate and the pixel points at each target coordinate through the DTW algorithm, and all of them are used as the suspected internal defect reference value of the pixel point at this non-target coordinate; Take the normalized result of the average value of the suspected internal defect reference values as the suspected internal defect degree of the pixel point at this non-target coordinate; Obtain the internal defect pixel points of the sight lens based on the suspected internal defect degree; Take the area jointly composed of the initial internal defect pixel points and the internal defect pixel points as the internal defect area of the sight lens.

2. The visual inspection method of a sight lens according to claim 1, characterized in that, The method for obtaining the internal defect pixel points of the sight lens based on the suspected internal defect degree is as follows: Evenly divide the value range of the suspected internal defect degree from small to large into the first preset number of reference intervals, and obtain the number of suspected internal defect degrees included in each reference interval as the first number of the corresponding reference interval; Obtain the difference between the first number of each reference interval and the first number of its previous adjacent reference interval, and all of them are used as the first difference; Take the boundary value between the two reference intervals corresponding to the largest first difference as the suspected internal defect degree threshold; When the degree of suspected internal defect is greater than the threshold of the degree of suspected internal defect, the pixel points at the corresponding non-target coordinates are used as the internal defect pixel points of the aiming lens.

3. The visual inspection method for a sight lens as described in claim 1, characterized in that, The method for obtaining the backlight fusion image is as follows: For the backlight image at any wavelength, the mean value of the gray values of the pixel points corresponding to the internal defect area in the backlight image is used as the internal defect gray reference value of the backlight image; The mean value of the gray values of all other pixel points except the pixel points corresponding to the internal defect area in the backlight image is obtained as the normal gray reference value of the backlight image; The difference between the internal defect gray reference value and the normal gray reference value of the backlight image is obtained as the first eigenvalue of the backlight image; The backlight image corresponding to the wavelength with the largest first eigenvalue is used as the backlight fusion image.

4. The visual inspection method for a sight lens according to claim 1, characterized in that, The method for obtaining the surface defect area is as follows: A two-dimensional coordinate system is constructed with the specified position of the front light image at each wavelength as the origin; wherein, the front light image and the backlight image at each wavelength have the same size; When the pixel points at the same coordinates in the front light image at each wavelength are all edge pixel points, the pixel points at the corresponding coordinates are used as the initial surface defect pixel points of the aiming lens; The gradient values of the pixel points corresponding to each coordinate in the front light image at each wavelength are arranged in ascending order according to the wavelength, and a wavelength-gradient value sequence of the pixel points at each coordinate is obtained; The coordinates corresponding to the initial surface defect pixel points are all used as reference coordinates. For any non-reference coordinate and any reference coordinate, the matching degree of the wavelength-gradient value sequence between the pixel points at the non-reference coordinate and the pixel points at the reference coordinate is obtained through the DTW algorithm as the reference matching degree; According to the size of each internal defect area and the gray difference of each internal defect area in the backlight images corresponding to the longest wavelength and the shortest wavelength, the surface overall interference degree of each internal defect area is obtained; According to the positional relationship between the coordinates of the front light image in the two-dimensional coordinate system and the coordinates corresponding to the internal defect pixel points, and the gray distribution of the internal defect area where the internal defect pixel points are located in the backlight fusion image, the surface defect interference degree of the pixel points at each coordinate is obtained; For any coordinate in the two-dimensional coordinate system, the product of the surface defect interference degree of the pixel points at the coordinate and the surface overall interference degree of the internal defect area where the pixel points at the coordinate are located is used as the target surface defect degree of the pixel points at the coordinate; The result of normalizing the sum of the target surface defect degrees of the pixel points at the non-reference coordinate and the pixel points at the reference coordinate is used as the adjustment weight; The product of the reference matching degree and the adjustment weight is used as the matching degree adjustment value; The sum of the reference matching degree and the matching degree adjustment value is used as the corrected matching degree between the pixel points at the non-reference coordinate and the pixel points at the reference coordinate; The result of normalizing the mean value of the corrected matching degrees between the pixel points at the non-reference coordinate and the pixel points at each reference coordinate is used as the suspected surface defect degree of the pixel points at the non-reference coordinate; The value range of the suspected surface defect degree is evenly divided into a second preset number of target intervals from small to large, and the number of suspected surface defect degrees included in each target interval is obtained as the second quantity corresponding to the target interval; The difference between the second quantity of each target interval and the second quantity of its previous adjacent target interval is obtained as the second difference; The boundary value between the two target intervals corresponding to the largest second difference is used as the suspected surface defect degree threshold; When the suspected surface defect degree is greater than the suspected surface defect degree threshold, the pixel points on the corresponding non-reference coordinates are used as the surface defect pixel points of the aiming lens; The area jointly formed by the initial surface defect pixel points and the surface defect pixel points is used as the surface defect area of the aiming lens.

5. A visual inspection method for a sight lens as described in claim 4, characterized in that, The method for obtaining the overall surface interference degree is as follows: For any internal defect area, the average gray value of the pixel points in the backlight image corresponding to the longest wavelength is obtained as the first gray value of the internal defect area; The average gray value of the pixel points in the backlight image corresponding to the shortest wavelength is obtained as the second gray value of the internal defect area; The result of negatively correlating and normalizing the difference between the first gray value and the second gray value is used as the stability degree of the internal defect area; The average value of the normalized result of the area of the internal defect area and the stability degree is used as the overall surface interference degree of the internal defect area.

6. The visual inspection method of a sight lens according to claim 4, characterized in that, The method for obtaining the surface defect interference degree is as follows: When the coordinates of the front light image in the two-dimensional coordinate system are the same as the coordinates corresponding to the internal defect pixel points, the coordinates of the front light image in the two-dimensional coordinate system that are the same as the coordinates corresponding to the internal defect pixel points are used as special coordinates; among them, the internal defect pixel points include the initial internal defect pixel points; For any special coordinate, the internal defect area where the internal defect pixel points on the special coordinate are located is used as the reference internal defect area, and the line segments from the centroid of the reference internal defect area to each edge pixel point are obtained as reference line segments; The reference line segment passing through the internal defect pixel points on the special coordinate is used as the target line segment; The gray values of the pixel points passed by the target line segment in the backlight fusion image are curve-fitted according to the order of the target line segment from the centroid to the edge pixel points to obtain a target curve; The absolute value of the tangent slope of the gray value corresponding to the pixel points on the special coordinate on the target curve is used as the surface defect interference degree of the pixel points on the special coordinate; When the coordinates of the front light image in the two-dimensional coordinate system are different from the coordinates corresponding to the internal defect pixel points, the surface defect interference degree of the pixel points on the corresponding coordinates is defaulted to 0.

7. The visual inspection method of a sight lens according to claim 1, characterized in that The method for obtaining the defects in the aiming lens according to the gray distribution of the backlight fusion image and the front light image of the surface defect area at each wavelength is as follows: For the front light image at any wavelength, the average gray value of the pixel points corresponding to the surface defect area in the front light image is used as the surface defect gray reference value of the front light image; Obtain the average gray value of all pixel points in the front illumination image except for the pixel points corresponding to the surface defect area as the normal gray reference value of the front illumination image; Obtain the difference between the surface defect gray reference value and the normal gray reference value of the front illumination image as the second eigenvalue of the front illumination image; Take the front illumination image at the wavelength corresponding to the maximum second eigenvalue as the front illumination fusion image; Fuse the back illumination fusion image and the front illumination fusion image into one image as the target image; Perform defect detection on the target image to obtain the defects in the aiming lens; 8. A visual inspection device for a sight lens, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the visual inspection method for an aiming lens according to any one of claims 1-7 above; 9. A visual inspection system for a sight lens, characterized in that, The system includes: An image acquisition module for acquiring the front illumination image and the back illumination image of the aiming lens at different wavelengths; A back illumination fusion image acquisition module for obtaining the internal defect area of the aiming lens according to the gray value of each pixel point in the back illumination image at each wavelength; and obtaining the back illumination fusion image according to the gray distribution of the internal defect area in the back illumination image at each wavelength; A surface defect area acquisition module for obtaining the surface defect area of the aiming lens based on the gradient value of each pixel point and the position of the edge pixel points in the front illumination image at each wavelength, the size of each internal defect area, the gray difference between each internal defect area in the back illumination images corresponding to the longest wavelength and the shortest wavelength, and the gray distribution of the internal defect area in the back illumination fusion image; A processing module for obtaining the defects in the aiming lens according to the gray distribution of the back illumination fusion image and the surface defect area in the front illumination image at each wavelength; The method for obtaining the internal defect area is: Obtain the average gray value of all pixel points in the back illumination image at each wavelength as the target gray value of the back illumination image at each wavelength; Construct a two-dimensional coordinate system with the specified position of the back illumination image at each wavelength as the origin; where the sizes of the back illumination images at each wavelength are the same; For any coordinate in the two-dimensional coordinate system, obtain the difference between the gray value of the pixel point at this coordinate in the back illumination image at each wavelength and the target gray value of the back illumination image at the same wavelength as the gray difference value of the pixel point at this coordinate at each wavelength; Arrange the gray difference values in ascending order according to the corresponding wavelengths to obtain a gray difference value sequence as the wavelength-gray difference value sequence of the pixel point at this coordinate; Take the pixel points with a gray value of 0 after threshold segmentation of the back illumination image at the specified wavelength as the initial internal defect pixel points of the aiming lens; Take the coordinates corresponding to the initial internal defect pixel points as the target coordinates. For any non-target coordinate, obtain the matching degree between the pixel point at this non-target coordinate and the pixel points at each target coordinate through the DTW algorithm as the suspected internal defect reference value of the pixel point at this non-target coordinate; The result of normalizing the mean value of the suspected internal defect reference values is used as the degree of suspected internal defect of the pixel point at the non-target coordinate. Based on the degree of suspected internal defect, the internal defect pixel points of the aiming lens are obtained. The area composed of the initial internal defect pixel points and the internal defect pixel points is used as the internal defect area of the aiming lens.

Citation Information

Patent Citations

  • Defect detection method for precision lens

    CN117686514A