A method and system for detecting defects in optical lenses
By performing usability evaluation, region extraction, and filtering on optical lens images, combined with edge detection and feature information extraction, and using a recognition model for defect detection, the problems of low efficiency and low accuracy in optical lens detection are solved, achieving efficient defect recognition.
Patent Information
- Application Number
- CN202410667384.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-05-28
AI Technical Summary
Existing technologies have low efficiency in detecting optical lens defects and low accuracy in defect identification. Noise and blur in the image also affect the detection results.
By acquiring several initial images of the optical lens, usability evaluation is performed to determine the optimal image. Key areas are extracted and noise is classified and filtered. Edge detection and threshold segmentation are performed to extract defect image feature information. Defect detection is then performed using a preset recognition model.
It effectively removes image noise, preserves feature information, and improves the accuracy and speed of defect detection.
Smart Images

Figure CN118587175B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of defect detection, and specifically relates to a method and system for detecting defects in optical lenses. Background Technology
[0002] Optical lenses are lenses made using optical glass. Optical glass is defined as glass with specific requirements for optical properties such as refractive index, dispersion, transmittance, spectral transmittance, and light absorption, and possessing uniform optical properties. It can alter the direction of light propagation and change the relative spectral distribution of ultraviolet, visible, or infrared light. In a narrow sense, optical glass refers to colorless optical glass; in a broader sense, it also includes colored optical glass, laser glass, quartz optical glass, radiation-resistant glass, ultraviolet-infrared optical glass, fiber optic glass, acousto-optic glass, magneto-optic glass, and photochromic glass. Optical glass is used to manufacture lenses, prisms, mirrors, and windows in optical instruments. Components made of optical glass are key elements in optical instruments.
[0003] Currently, the inspection of optical lenses is usually done by visual observation, but this is inefficient and has a low accuracy rate in defect identification. Therefore, there are also methods that use equipment to capture images of optical lenses and identify defects based on these images. However, due to the special nature of optical lenses, during the shooting process, light interference can cause significant noise or blurring in the images, which in turn affects the accuracy of subsequent defect identification. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a method and system for detecting defects in optical lenses, which solves the technical problems in the prior art.
[0005] On one hand, the present invention provides the following technical solution: a method for detecting defects in optical lenses, comprising: Acquire several initial images of the optical lens, evaluate the usability of the initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score; The optimal image is then subjected to key region extraction to obtain a region-extracted image; The noise category of each pixel in the extracted image of the region is identified, and the extracted image of the region is subjected to classification filtering based on the noise category to obtain a filtered image; Edge detection is performed on the filtered image to obtain a gradient map. The gradient map is then divided into windows and thresholded to obtain a defect image. Extract the feature information of the defective image, store the feature information and the corresponding defective image in the recognition dataset, obtain the template recognition image, input the template recognition image into the preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result.
[0006] Compared with existing technologies, the beneficial effects of this invention are as follows: First, this invention acquires several initial images of the optical lens, evaluates their usability to obtain evaluation scores, and determines the optimal image based on these scores. Then, it extracts key regions from the optimal image to obtain region-extracted images. Next, it identifies the noise category of each pixel in the region-extracted image and performs classification filtering based on the noise category to obtain a filtered image. Then, it performs edge detection on the filtered image to obtain a gradient map, and sequentially divides the gradient map into windows and thresholds to obtain defect images. Finally, it extracts the feature information of the defect images, stores the feature information and the corresponding defect images in a recognition dataset, obtains template recognition images, inputs the template recognition images into a preset recognition model for training, and inputs the recognition dataset into the trained preset recognition model for defect detection to output defect detection results. This invention, through a series of image processing steps, effectively removes noise from images, preserves as much feature information and edge details as possible, improves the accuracy of defect detection, and also speeds up the defect detection process.
[0007] Preferably, the step of acquiring several initial images of the optical lens, performing usability evaluation on the several initial images to obtain an evaluation score, and determining the optimal image based on the evaluation score includes: Acquire several initial images of the optical lens and calculate the first score value of the several initial images. : ; In the formula, Represents pixels Pixel values; Calculate the second score value of several initial images : ; In the formula, Represents pixels grayscale value, pixel grayscale value, Indicates the preset pixel distance; Based on the first score Compared with the second score Calculate evaluation score and the evaluation score The initial image corresponding to the maximum value is taken as the optimal image: ; In the formula, This indicates the weight of the score.
[0008] Preferably, the step of extracting key regions from the optimal image to obtain a region-extracted image includes: Each pixel of the optimal image is scanned, and the pixel value of the pixel is determined to be greater than the grayscale threshold based on the scanning results. Pixels with pixel values greater than the grayscale threshold are stored in a set of candidate pixels. Three non-collinear pixels are randomly selected from the set of candidate pixels as region judgment points. Based on the three regional judgment points, candidate circular regions are determined, and the center and radius of the candidate circular regions are calculated until all pixels in the candidate pixel set have been selected, so as to obtain several candidate circular regions. The centers of all the candidate circular regions are accumulated to obtain the accumulated result. Based on the centers of all the candidate circular regions, the center regions are determined. Non-maximum suppression is performed on the center regions of the same connected region to obtain several center positions. Determine whether the cumulative result corresponding to the center position is greater than the cumulative threshold. Discard the center positions whose cumulative results are not greater than the cumulative threshold to obtain the true center position. Based on the true center position, determine the region to extract the image.
[0009] Preferably, in the step of determining whether the cumulative result corresponding to the center position is greater than the cumulative threshold, the cumulative threshold... for: ; In the formula, For the judgment coefficient, The radius of the circular region to be selected.
[0010] Preferably, the step of identifying the noise category of each pixel in the region-extracted image and performing classification filtering on the region-extracted image based on the noise category to obtain a filtered image includes: The grayscale value of each pixel in the image is extracted from the region, and a noise discrimination value for the corresponding pixel is determined based on the grayscale value. : ; In the formula, Represents pixels grayscale value, pixel Neighboring pixels grayscale value, Indicates the difference threshold. This represents the number of pixels whose grayscale value difference with their neighboring pixels is greater than a difference threshold. Indicates the number of neighboring pixels; If the noise discriminant value of a pixel If the value is greater than the threshold, a first rectangular window is determined with the pixel as the center, and the pixels within the first rectangular window are filtered using median filtering to obtain a filtered image. If the noise discriminant value of a pixel If the value is not greater than the threshold, a second rectangular window is determined with that pixel as the center. The pixels within the second rectangular window are then filtered using a bilateral filtering method to obtain the filtered image.
[0011] Preferably, the step of performing edge detection on the filtered image to obtain a gradient map, and then sequentially dividing the gradient map into windows and thresholding it to obtain a defect image includes: The Sobel operator is used to perform edge detection on the filtered image to obtain a gradient map; The gradient map is segmented using an initial segmentation threshold to obtain several initial defect images; Each initial defect image is divided into local windows, and each local window is automatically thresholded using the maximum inter-class variance method to obtain segmentation edge images; Non-maximum suppression and boundary tracking are sequentially performed on the segmented edge image to obtain the defect image.
[0012] Preferably, in the step of extracting feature information of the defect image, the feature information includes the perimeter, area, roundness, rectangularity, height, width, and elongation of the defect image.
[0013] Secondly, the present invention provides the following technical solution: an optical lens defect detection system, the system comprising: The evaluation module is used to acquire several initial images of the optical lens, evaluate the usability of the initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score. An extraction module is used to extract key regions from the optimal image to obtain a region-extracted image; A noise reduction module is used to identify the noise category of each pixel in the region extraction image, and perform classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; The segmentation module is used to perform edge detection on the filtered image to obtain a gradient map, and then to perform windowing and thresholding on the gradient map to obtain a defect image. The detection module is used to extract feature information from the defect image, store the feature information and the corresponding defect image in the recognition dataset, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result.
[0014] Thirdly, the present invention provides the following technical solution: a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the optical lens defect detection method as described above.
[0015] Fourthly, the present invention provides the following technical solution: a storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the optical lens defect detection method described above. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of the optical lens defect detection method provided in Embodiment 1 of the present invention; Figure 2 This is a structural block diagram of the optical lens defect detection system provided in Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the hardware structure of a computer provided for another embodiment of the present invention.
[0018] The embodiments of the present invention will be further described below with reference to the accompanying drawings. Detailed Implementation
[0019] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain embodiments of the present invention, and should not be construed as limiting the present invention.
[0020] In the description of the embodiments of the present invention, it should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the present invention.
[0021] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of the present invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0022] In the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of the present invention according to the specific circumstances.
[0023] Example 1 In Embodiment 1 of the present invention, as Figure 1 As shown, a method for detecting defects in optical lenses includes: S1. Acquire several initial images of the optical lens, evaluate the usability of the initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score. Specifically, in the process of acquiring several initial images of the optical lens, the initial images contain the optical lens. At the same time, the initial images can be taken from different distances, different positions and different angles. However, in order to improve the accuracy of subsequent defect identification, it is necessary to score each initial image and select the best image from them.
[0024] Step S1 includes: S11. Acquire several initial images of the optical lens and calculate the first score value of the several initial images. : ; In the formula, Represents pixels Pixel values; Specifically, the first score is mainly used to evaluate the energy and information entropy of the image. The content inside the absolute value symbol in the above formula represents the information entropy of the image. When the image noise is greater and the image is more blurred, the information entropy will be greater. Therefore, the smaller the information entropy, the better. And according to the above formula, the larger the first score, the better.
[0025] S12. Calculate the second score value of several initial images. : ; In the formula, Represents pixels grayscale value, pixel grayscale value, Indicates the preset pixel distance; Specifically, the second rating value It mainly reflects the local gray-level difference of the image. When the image noise is greater and the image is more blurred, the local gray-level difference will be smaller. Therefore, the larger the second score, the better.
[0026] S13, Based on the first score value Compared with the second score Calculate evaluation score and the evaluation score The initial image corresponding to the maximum value is taken as the optimal image: ; In the formula, Indicates the weighting of the scores; Specifically, in this embodiment, .
[0027] S2. Extract key regions from the optimal image to obtain a region-extracted image; Step S2 includes: S21. Scan each pixel of the optimal image and determine whether the pixel value of the pixel is greater than the grayscale threshold based on the scanning result. S22. Store the pixels with pixel values greater than the grayscale threshold into the candidate pixel set, and arbitrarily select three non-collinear pixels from the candidate pixel set as region judgment points. Specifically, since the pixels on the same image belong to the same plane, a circle can be determined by selecting three region judgment points, and all three region judgment points are on this circle.
[0028] S23. Determine the candidate circular regions based on the three region judgment points, and calculate the center and radius of the candidate circular regions until all pixels in the candidate pixel set have been selected, so as to obtain several candidate circular regions.
[0029] S24. Accumulate the centers of all the candidate circular regions to obtain the cumulative result. Determine the center region based on the centers of all the candidate circular regions. Perform non-maximum suppression on the center regions of the same connected region to obtain several center positions. Specifically, each candidate circular region has a center. For a pixel within the same connected region, the center of the candidate circular region should be within a certain range, which is the center region.
[0030] S25. Determine whether the cumulative result corresponding to the center position is greater than the cumulative threshold. Discard the center positions whose cumulative results are not greater than the cumulative threshold to obtain the true center position. Based on the true center position, determine the region to extract the image. Specifically, when the center position is greater than the cumulative threshold, it indicates that the circle corresponding to the center can contain the feature information of the connected region. Therefore, after determining the center, the region of several centers can be determined and the image can be extracted based on the corresponding radius. Wherein, the cumulative threshold for: ; In the formula, For the judgment coefficient, The radius of the circular region to be selected.
[0031] S3. Identify the noise category of each pixel in the region extraction image, and perform classification filtering on the region extraction image based on the noise category to obtain a filtered image; Step S3 includes: S31. Extract the pixel grayscale value of each pixel in the image from the region, and determine the noise discrimination value of the corresponding pixel based on the pixel grayscale value. : ; In the formula, Represents pixels grayscale value, pixel Neighboring pixels grayscale value, Indicates the difference threshold. This represents the number of pixels whose grayscale value difference with their neighboring pixels is greater than a difference threshold. Indicates the number of neighboring pixels; Specifically, pixels in different regions may have different regional noise. Therefore, different regional noises are classified and separated, and then different filtering methods are used to filter different images to obtain filtered images.
[0032] S32, If the noise discrimination value of a pixel If the value is greater than the threshold, a first rectangular window is determined with that pixel as the center. Median filtering is then used to filter the pixels within the first rectangular window to obtain a filtered image.
[0033] S33, If the noise discrimination value of a pixel If the value is not greater than the threshold, a second rectangular window is determined with that pixel as the center. The pixels within the second rectangular window are then filtered using a bilateral filtering method to obtain the filtered image.
[0034] S4. Perform edge detection on the filtered image to obtain a gradient map, and then divide the gradient map into windows and threshold segments to obtain a defect image. Step S4 includes: S41. The Sobel operator is used to perform edge detection on the filtered image to obtain a gradient map.
[0035] S42. The gradient map is segmented using an initial segmentation threshold to obtain several initial defect images; Specifically, the initial segmentation threshold is a relatively small threshold.
[0036] S43. Divide each of the initial defect images into local windows, and perform automatic thresholding on each local window using the maximum inter-class variance method to obtain segmented edge images; Specifically, after obtaining the initial defect image, the average gray value between the local window and the segmented background image is calculated as the new segmentation threshold. Segmentation is performed based on the new segmentation threshold, and the segmentation threshold is iteratively updated until the difference between the new segmentation threshold and the segmentation threshold of the previous iteration is less than a preset value, thus obtaining the segmented edge image.
[0037] S44. Perform non-maximum suppression and boundary tracking sequentially on the segmented edge image to obtain the defect image.
[0038] S5. Extract the feature information of the defect image, store the feature information and the corresponding defect image in the recognition dataset, obtain the template recognition image, input the template recognition image into the preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result. Specifically, when extracting the feature information of the defect image, the boundary of the defect image can be converted into an 8-direction chain code representation. After representation, the perimeter and area of the defect target, as well as other feature information, can be calculated relatively easily. The feature information includes the perimeter, area, roundness, rectangularity, height, width, and elongation of the defect image; perimeter for: ; area for: ; Roundness for: ; elongation for: ; In the formula, , These represent the number of even-numbered chain codes and the number of odd-numbered chain codes, respectively. , These represent the offsets of the x and y coordinates, respectively. For the first The ordinate of each boundary pixel. The number of boundary pixels, , These are the height and width, respectively. After obtaining the above feature information, it is packaged with the corresponding defect image and stored in the recognition dataset. Then, template recognition images are obtained, which contain template images of various defects and feature information. The template recognition images are used to train a preset recognition model, which is an SVM classifier. Then, the data in the recognition dataset is input into the trained SVM classifier for detection and recognition, and the corresponding detection results are obtained. The detection results include the location of the defect and the category of the defect. The defect category can be obtained through the model, and the defect location can be determined based on the position of the defect image in the initial image.
[0039] The optical lens defect detection method provided in Embodiment 1 of this invention first acquires several initial images of the optical lens, performs usability evaluation on these initial images to obtain evaluation scores, and determines the optimal image based on the evaluation scores. Then, it extracts key regions from the optimal image to obtain region-extracted images. Next, it identifies the noise category of each pixel in the region-extracted image, performs classification filtering on the region-extracted image based on the noise category to obtain a filtered image. Then, it performs edge detection on the filtered image to obtain a gradient map, and sequentially divides the gradient map into windows and thresholds to obtain defect images. Finally, it extracts feature information from the defect images, stores the feature information and the corresponding defect images in a recognition dataset, obtains template recognition images, inputs the template recognition images into a preset recognition model for training, and inputs the recognition dataset into the trained preset recognition model for defect detection to output defect detection results. This invention, through a series of image processing steps, can effectively remove noise from images, retain as much feature information and edge details as possible, improve the accuracy of defect detection, and also accelerate the defect detection speed.
[0040] Example 2 like Figure 2 As shown, in Embodiment 2 of the present invention, an optical lens defect detection system is provided, the system comprising: Evaluation module 1 is used to acquire several initial images of the optical lens, evaluate the usability of the several initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score. Extraction module 2 is used to extract key regions from the optimal image to obtain a region-extracted image; The noise reduction module 3 is used to identify the noise category of each pixel in the region extraction image, and perform classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; The segmentation module 4 is used to perform edge detection on the filtered image to obtain a gradient map, and then to perform windowing and thresholding on the gradient map to obtain a defect image. The detection module 5 is used to extract feature information from the defect image, store the feature information and the corresponding defect image in the recognition dataset, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result.
[0041] The evaluation module 1 includes: The first evaluation submodule is used to acquire several initial images of the optical lens and calculate the first score value of the several initial images. : ; In the formula, Represents pixels Pixel values; The second evaluation submodule is used to calculate the second score value for several initial images. : ; In the formula, Represents pixels grayscale value, pixel grayscale value, Indicates the preset pixel distance; The third evaluation submodule is used to evaluate based on the first score value. Compared with the second score Calculate evaluation score and the evaluation score The initial image corresponding to the maximum value is taken as the optimal image: ; In the formula, This indicates the weight of the score.
[0042] The extraction module 2 includes: The scanning submodule is used to scan each pixel of the optimal image and determine whether the pixel value of the pixel is greater than the grayscale threshold based on the scanning result. The filtering submodule is used to store pixels with pixel values greater than the grayscale threshold into a set of candidate pixels, and arbitrarily select three non-collinear pixels from the set of candidate pixels as region judgment points. The region submodule is used to determine the candidate circular region based on the three region judgment points, and calculate the center and radius of the candidate circular region until all pixels in the candidate pixel set have been selected, so as to obtain several candidate circular regions. The accumulation submodule is used to accumulate the centers of all the candidate circular regions to obtain the accumulation result, determine the center region based on the centers of all the candidate circular regions, and perform non-maximum suppression on the center regions of the same connected region to obtain several center positions. The discard submodule is used to determine whether the cumulative result corresponding to the center position is greater than the cumulative threshold. Center positions whose cumulative results are not greater than the cumulative threshold are discarded to obtain the true center position. Based on the true center position, the region is determined and the image is extracted.
[0043] The noise reduction module 3 includes: The category determination submodule is used to extract the pixel grayscale value of each pixel in the image of the region, and determine the noise discrimination value of the corresponding pixel based on the pixel grayscale value. : ; In the formula, Represents pixels grayscale value, pixel Neighboring pixels grayscale value, Indicates the difference threshold. This represents the number of pixels whose grayscale value difference with their neighboring pixels is greater than a difference threshold. Indicates the number of neighboring pixels; The first filtering submodule is used to determine the noise value of a pixel. If the value is greater than the threshold, a first rectangular window is determined with the pixel as the center, and the pixels within the first rectangular window are filtered using median filtering to obtain a filtered image. The second filtering submodule is used to determine the noise value of a pixel. If the value is not greater than the threshold, a second rectangular window is determined with that pixel as the center. The pixels within the second rectangular window are then filtered using a bilateral filtering method to obtain the filtered image.
[0044] The segmentation module 4 includes: An edge submodule is used to perform edge detection on the filtered image using the Sobel operator to obtain a gradient map; The first segmentation submodule is used to segment the gradient map using an initial segmentation threshold to obtain several initial defect images; The second segmentation submodule is used to divide each of the initial defect images into local windows, and to perform automatic threshold segmentation on each local window using the maximum inter-class variance method to obtain segmentation edge images; The tracking submodule is used to sequentially perform nonmaximum suppression and boundary tracking on the segmented edge image to obtain the defect image.
[0045] In other embodiments of the present invention, the present invention provides the following technical solution: a computer, including a memory 102, a processor 101, and a computer program stored in the memory 102 and executable on the processor 101, wherein the processor 101 executes the computer program to implement the optical lens defect detection method as described above.
[0046] Specifically, the processor 101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of the present invention.
[0047] The memory 102 may include a large-capacity memory for data or instructions. For example, and not limitingly, the memory 102 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), flash memory, an optical disk drive, a magneto-optical disk drive, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 102 may include removable or non-removable (or fixed) media. Where appropriate, the memory 102 may be internal or external to a data processing device. In a particular embodiment, the memory 102 is non-volatile memory. In a particular embodiment, the memory 102 includes read-only memory (ROM) and random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable read-only memory (PROM), an erasable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), an electrically alterable read-only memory (EAROM), or flash memory, or a combination of two or more of these. Where appropriate, the RAM can be Static Random-Access Memory (SRAM) or Dynamic Random-Access Memory (DRAM). DRAM can be Fast Page Mode Dynamic Random Access Memory (FPMDRAM), Extended Data Out Dynamic Random Access Memory (EDODRAM), Synchronous Dynamic Random-Access Memory (SDRAM), etc.
[0048] The memory 102 can be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 101.
[0049] The processor 101 implements the above-mentioned optical lens defect detection method by reading and executing computer program instructions stored in the memory 102.
[0050] In some embodiments, the computer may further include a communication interface 103 and a bus 100. For example, Figure 3 As shown, the processor 101, memory 102, and communication interface 103 are connected through bus 100 and complete communication with each other.
[0051] The communication interface 103 is used to enable communication between the various modules, devices, units, and / or equipment in the embodiments of the present invention. The communication interface 103 can also enable data communication with other components such as external devices, image / data acquisition devices, databases, external storage, and image / data processing workstations.
[0052] Bus 100 includes hardware, software, or both, that couples components of a computer device together. Bus 100 includes, but is not limited to, at least one of the following: data bus, address bus, control bus, expansion bus, and local bus. For example, and not as a limitation, bus 100 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 100 may include one or more buses. Although specific buses are described and illustrated in the embodiments of the present invention, the present invention is contemplated by any suitable bus or interconnect.
[0053] The computer can execute the optical lens defect detection method of the present invention based on the acquired optical lens defect detection system, thereby realizing optical lens defect detection.
[0054] In some other embodiments of the present invention, in conjunction with the above-described optical lens defect detection method, the present invention provides the following technical solution: a storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the above-described optical lens defect detection method.
[0055] Those skilled in the art will understand that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0056] More specific examples of readable media (a non-exhaustive list) include: electrical connections (electronic devices) with one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0057] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0058] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0059] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A method for detecting defects in optical lenses, characterized in that, include: Acquire several initial images of the optical lens, evaluate the usability of the initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score; The optimal image is then subjected to key region extraction to obtain a region-extracted image; The noise category of each pixel in the extracted image of the region is identified, and the extracted image of the region is subjected to classification filtering based on the noise category to obtain a filtered image; Edge detection is performed on the filtered image to obtain a gradient map. The gradient map is then divided into windows and thresholded to obtain a defect image. Extract the feature information of the defect image, store the feature information and the corresponding defect image in the recognition dataset, obtain the template recognition image, input the template recognition image into the preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result. The steps of acquiring several initial images of the optical lens, evaluating the usability of the initial images to obtain evaluation scores, and determining the optimal image based on the evaluation scores include: Acquire several initial images of the optical lens and calculate the first score value of the several initial images. : ; In the formula, Represents pixels Pixel values; Calculate the second score value of several initial images : ; In the formula, Represents pixels grayscale value, Represents pixels grayscale value, Indicates the preset pixel distance; Based on the first score Compared with the second score Calculate evaluation score and the evaluation score The initial image corresponding to the maximum value is taken as the optimal image: ; In the formula, This indicates the weight of the score.
2. The optical lens defect detection method according to claim 1, characterized in that, The step of extracting key regions from the optimal image to obtain a region-extracted image includes: Each pixel of the optimal image is scanned, and the pixel value of the pixel is determined to be greater than the grayscale threshold based on the scanning results. Pixels with pixel values greater than the grayscale threshold are stored in a set of candidate pixels. Three non-collinear pixels are randomly selected from the set of candidate pixels as region judgment points. Based on the three regional judgment points, candidate circular regions are determined, and the center and radius of the candidate circular regions are calculated until all pixels in the candidate pixel set have been selected, so as to obtain several candidate circular regions. The centers of all the candidate circular regions are accumulated to obtain the accumulated result. Based on the centers of all the candidate circular regions, the center regions are determined. Non-maximum suppression is performed on the center regions of the same connected region to obtain several center positions. Determine whether the cumulative result corresponding to the center position is greater than the cumulative threshold. Discard the center positions whose cumulative results are not greater than the cumulative threshold to obtain the true center position. Based on the true center position, determine the region to extract the image.
3. The optical lens defect detection method according to claim 2, characterized in that, In the step of determining whether the cumulative result corresponding to the center position is greater than the cumulative threshold, the cumulative threshold... for: ; In the formula, For the judgment coefficient, The radius of the circular region to be selected.
4. The optical lens defect detection method according to claim 1, characterized in that, The step of identifying the noise category of each pixel in the region extraction image and performing classification filtering on the region extraction image based on the noise category to obtain a filtered image includes: The grayscale value of each pixel in the image is extracted from the region, and a noise discrimination value for the corresponding pixel is determined based on the grayscale value. : ; In the formula, Represents pixels grayscale value, Represents pixels Neighboring pixels grayscale value, Indicates the difference threshold. This represents the number of pixels whose grayscale value difference with their neighboring pixels is greater than a threshold. Indicates the number of neighboring pixels; If the noise discriminant value of a pixel If the value is greater than the threshold, a first rectangular window is determined with the pixel as the center, and the pixels within the first rectangular window are filtered using median filtering to obtain a filtered image. If the noise discriminant value of a pixel If the value is not greater than the threshold, a second rectangular window is determined with that pixel as the center. The pixels within the second rectangular window are then filtered using a bilateral filtering method to obtain the filtered image.
5. The optical lens defect detection method according to claim 1, characterized in that, The steps of performing edge detection on the filtered image to obtain a gradient map, and then dividing the gradient map into windows and thresholding it to obtain a defect image include: The Sobel operator is used to perform edge detection on the filtered image to obtain a gradient map; The gradient map is segmented using an initial segmentation threshold to obtain several initial defect images; Each initial defect image is divided into local windows, and each local window is automatically thresholded using the maximum inter-class variance method to obtain segmentation edge images; Non-maximum suppression and boundary tracking are sequentially performed on the segmented edge image to obtain the defect image.
6. The optical lens defect detection method according to claim 1, characterized in that, In the step of extracting feature information of the defect image, the feature information includes the perimeter, area, roundness, rectangularity, height, width, and elongation of the defect image.
7. An optical lens defect detection system, wherein the system employs the optical lens defect detection method as described in claim 1, characterized in that, The system includes: The evaluation module is used to acquire several initial images of the optical lens, evaluate the usability of the initial images to obtain an evaluation score, and determine the optimal image based on the evaluation score. An extraction module is used to extract key regions from the optimal image to obtain a region-extracted image; A noise reduction module is used to identify the noise category of each pixel in the region extraction image, and perform classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; The segmentation module is used to perform edge detection on the filtered image to obtain a gradient map, and then to perform windowing and thresholding on the gradient map to obtain a defect image. The detection module is used to extract feature information from the defect image, store the feature information and the corresponding defect image in the recognition dataset, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition dataset into the trained preset recognition model for defect detection, and output the defect detection result.
8. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the optical lens defect detection method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the optical lens defect detection method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Optical member inspection method
JP2003130756A
System and method for inspecting defects
KR1020160049571A
