Optical lens defect detection method and system
Through usability evaluation, key area extraction, noise classification filtering and edge detection of optical lens images, the noise and blur problems in optical lens detection are solved and the accuracy and efficiency of defect detection are improved.
Patent Information
- Application Number
- CN202410667384.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-28
AI Technical Summary
Existing optical lens detection methods are inefficient and have low defect identification accuracy. There is noise and blur in the image, which affects the accuracy of defect identification.
By obtaining the initial image of the optical lens for usability evaluation, determine the optimal image, extract key areas, identify noise categories for classification filtering, perform edge detection and threshold segmentation, extract feature information and input the preset recognition model for defect detection.
It effectively removes image noise, retains feature information and edge details, and improves the accuracy and speed of defect detection.
Smart Images

Figure CN118587175A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of defect detection, and specifically relates to an optical lens defect detection method and system. Background Art
[0002] Optical lenses are lenses made of optical glass. The definition of optical glass is glass with specific requirements for optical properties such as refractive index, dispersion, transmittance, spectral transmittance and light absorption, and with uniform optical properties. Glass that can change the propagation direction of light and the relative spectral distribution of ultraviolet, visible or infrared light. Optical glass in a narrow sense refers to colorless optical glass; in a broad sense, optical glass also includes colored optical glass, laser glass, quartz optical glass, radiation-resistant glass, ultraviolet infrared optical glass, fiber optical glass, acousto-optic glass, magneto-optic glass and photochromic glass. Optical glass can be used to manufacture lenses, prisms, reflectors and windows in optical instruments. Components made of optical glass are key elements in optical instruments.
[0003] At present, the inspection of optical lenses is usually carried out through naked eye observation, but its efficiency is low and the defect recognition accuracy is low. Therefore, there are some devices that take images of optical lenses and identify defects based on the images. However, due to the particularity of optical lenses, the interference of light during the shooting process causes large noise in the image or the image is blurred, which in turn affects the accuracy of subsequent defect recognition. Summary of the invention
[0004] In order to solve the above technical problems, the present invention provides an optical lens defect detection method and system for solving the technical problems in the prior art.
[0005] On the one hand, the present invention provides the following technical solution, a method for detecting defects in an optical lens, comprising: Acquire a plurality of initial images of the optical lens, perform usability evaluation on the plurality of initial images to obtain evaluation scores, and determine an optimal image based on the evaluation scores; Extracting key areas from the optimal image to obtain an area-extracted image; 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; Performing edge detection on the filtered image to obtain a gradient map, and sequentially performing window division and threshold segmentation on the gradient map to obtain a defect image; Extract feature information of the defect image, store the feature information and the corresponding defect image in a recognition data set, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition data set into the trained preset recognition model for defect detection, and output a defect detection result.
[0006] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention first obtains several initial images of the optical lens, performs usability evaluation on the several initial images to obtain evaluation scores, and determines the optimal image based on the evaluation scores; then, performs key area extraction on the optimal image to obtain a regional extraction image; then, the noise category of each pixel point in the regional extraction image is identified, and the regional extraction image is classified and filtered based on the noise category to obtain a filtered image; then, edge detection is performed on the filtered image to obtain a gradient map, and the gradient map is windowed and threshold segmented in sequence to obtain a defect image; finally, feature information of the defect image is extracted, and the feature information and the corresponding defect image are stored in a recognition data set to obtain a template recognition image, and the template recognition image is input into a preset recognition model for training, and the recognition data set is input into the trained preset recognition model for defect detection to output a defect detection result. The present invention can effectively remove noise in the image by performing a series of processing on the image, retain the feature information and edge details contained in the image as much as possible, improve the accuracy of defect detection, and also speed up the speed of defect detection.
[0007] Preferably, the step of acquiring a plurality of initial images of the optical lens, performing usability evaluation on the plurality of initial images to obtain evaluation scores, and determining the optimal image based on the evaluation scores comprises: Obtain several initial images of the optical lens and calculate the first scoring values of the several initial images : ; In the formula, Represents pixel The pixel value of Calculate the second score value of several initial images : ; In the formula, Represents pixel The gray value of Pixels The gray value of Indicates the preset pixel distance; Based on the first scoring value With the second rating value Calculate review scores , and the evaluation score The initial image with the largest correspondence is taken as the optimal image: ; In the formula, Represents the scoring weight.
[0008] Preferably, the step of extracting key areas from the optimal image to obtain a region-extracted image comprises: Scan each pixel of the optimal image, and determine whether a pixel value of the pixel is greater than a grayscale threshold based on the scanning result; Storing pixel points whose pixel values are greater than the grayscale threshold into a candidate pixel point set, and arbitrarily selecting three non-collinear pixel points in the candidate pixel point set as region judgment points; Determine a circular area to be selected based on the three area judgment points, and calculate the center and radius of the circular area to be selected until all pixels in the set of pixel points to be selected are selected, so as to obtain a plurality of circular areas to be selected; The centers of all the circular regions to be selected are accumulated to obtain an accumulated result, a center region is determined based on the centers of all the circular regions to be selected, and non-maximum suppression is performed on the center region of the same connected region to obtain a number of center positions; It is determined whether the cumulative result corresponding to the center position of the circle is greater than the cumulative threshold, and the center position of the circle whose cumulative result is not greater than the cumulative threshold is discarded to obtain the true center position of the circle, and the area extraction image is determined based on the true center position.
[0009] Preferably, in the step of determining whether the cumulative result corresponding to the center position of the circle is greater than the cumulative threshold, the cumulative threshold for: ; In the formula, is the judgment coefficient, is the radius of the circular area to be selected.
[0010] Preferably, the step of identifying the noise category of each pixel in the region extraction image and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image comprises: The pixel grayscale value of each pixel in the region extraction image is determined based on the pixel grayscale value to determine the noise discrimination value of the corresponding pixel : ; In the formula, Represents pixel The gray value of Pixels Neighborhood pixels The gray value of represents the difference threshold, Indicates the number of pixels whose grayscale value difference between the pixel and its neighboring pixels is greater than the difference threshold. Indicates the number of neighborhood pixels; If the noise discrimination value of the pixel If the pixel value is greater than the judgment threshold, a first rectangular window is determined with the pixel point as the center, and the pixel points in the first rectangular window are filtered by median filtering to obtain a filtered image; If the noise discrimination value of the pixel If the pixel value is not greater than the judgment threshold, a second rectangular window is determined with the pixel point as the center, and the pixel points in the second rectangular window are filtered by using bilateral filtering to obtain a filtered image.
[0011] Preferably, the step of performing edge detection on the filtered image to obtain a gradient map, and sequentially performing window division and threshold segmentation on the gradient map to obtain a defect image comprises: Using the Sobel operator to perform edge detection on the filtered image to obtain a gradient map; Using an initial segmentation threshold to segment the gradient image to obtain a number of initial defect images; Dividing each of the initial defect images into local windows, and performing automatic threshold segmentation on each of the local windows using the maximum inter-class variance method to obtain a segmented edge image; Non-maximum suppression and boundary tracking are sequentially performed on the segmented edge image to obtain a defect image.
[0012] Preferably, in the step of extracting characteristic information of the defect image, the characteristic information includes the perimeter, area, roundness, rectangularity, height, width and elongation of the defect image.
[0013] In a second aspect, the present invention provides the following technical solution, an optical lens defect detection system, the system comprising: An evaluation module, used for acquiring a plurality of initial images of the optical lens, performing usability evaluation on the plurality of initial images to obtain evaluation scores, and determining an optimal image based on the evaluation scores; An extraction module, used for extracting key areas of the optimal image to obtain an area extraction image; A denoising module, used for identifying the noise category of each pixel in the region extraction image, and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; A segmentation module, used for performing edge detection on the filtered image to obtain a gradient map, and performing window division and threshold segmentation on the gradient map in sequence to obtain a defect image; The detection module is used to extract the feature information of the defect image, store the feature information and the corresponding defect image in a recognition data set, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition data set into the trained preset recognition model for defect detection, and output a defect detection result.
[0014] In a third aspect, the present invention provides the following technical solution: a computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the optical lens defect detection method as described above when executing the computer program.
[0015] In a fourth aspect, the present invention provides the following technical solution: a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the optical lens defect detection method as described above. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 A flowchart of an optical lens defect detection method provided in Embodiment 1 of the present invention; Figure 2 A structural block diagram of an optical lens defect detection system provided in Embodiment 2 of the present invention; Figure 3 A schematic diagram of the hardware structure of a computer provided in 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 DESCRIPTION
[0019] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the 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", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and 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 referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0021] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0022] In the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the embodiments of the present invention can be understood according to specific circumstances.
[0023] Embodiment 1 In the first embodiment of the present invention, Figure 1 As shown, a method for detecting defects in an optical lens comprises: S1. Acquire a plurality of initial images of an optical lens, perform usability evaluation on the plurality of initial images to obtain evaluation scores, and determine an optimal image based on the evaluation scores; Specifically, in the process of obtaining several initial images of the optical lens, the initial images contain the optical lens, and the initial images can be taken from different distances, different positions and different angles. However, in order to improve the subsequent defect recognition accuracy, each initial image needs to be scored and the best image is selected.
[0024] Wherein, the step S1 comprises: S11, obtaining several initial images of the optical lens, and calculating first scoring values of the several initial images : ; In the formula, Represents pixel The pixel value of Specifically, the first score value is mainly used to evaluate the energy and information entropy of the image. The content in 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. According to the above formula, the larger the first score value, the better.
[0025] S12, calculating the second scoring values of several initial images : ; In the formula, Represents pixel The gray value of Pixels The gray value of Indicates the preset pixel distance; Specifically, the second rating value It mainly reflects the local grayscale difference of the image. When the image noise is greater and the image is more blurred, the local grayscale difference will be smaller. Therefore, the larger the second score value, the better.
[0026] S13, based on the first scoring value With the second rating value Calculate review scores , and the evaluation score The initial image with the largest correspondence is taken as the optimal image: ; In the formula, Indicates the scoring weight; Specifically, in this embodiment, .
[0027] S2, extracting key areas of the optimal image to obtain a region-extracted image; Wherein, the step S2 comprises: S21, scanning each pixel point of the optimal image, and judging whether the pixel value of the pixel point is greater than the grayscale threshold based on the scanning result; S22, storing pixel points whose pixel values are greater than the grayscale threshold into a set of candidate pixel points, and arbitrarily selecting three non-collinear pixel points from the set of candidate pixel points as region determination 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 the three region judgment points are all on the circle.
[0028] S23, determining a circular area to be selected based on the three area judgment points, and calculating the center and radius of the circular area to be selected, until all pixels in the set of pixel points to be selected are selected, so as to obtain a plurality of circular areas to be selected.
[0029] S24, accumulating the centers of all the circular regions to be selected to obtain an accumulation result, determining a center region based on the centers of all the circular regions to be selected, and performing non-maximum suppression on the center region of the same connected region to obtain a number of center positions; Specifically, each circular region to be selected has a center, and for a pixel point in the same connected region, the center of the circular region to be selected should be within a range, and the range is the center region.
[0030] S25, determining whether the cumulative result corresponding to the circle center position is greater than the cumulative threshold, discarding the circle center position whose cumulative result is not greater than the cumulative threshold to obtain the true circle center position, and determining the region to extract the image based on the true circle center position; 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 in the connected area. Therefore, after determining the center, the area extraction images of several center areas can be determined according to the corresponding radius. Among them, the cumulative threshold for: ; In the formula, is the judgment coefficient, is the radius of the circular area to be selected.
[0031] S3, identifying the noise category of each pixel in the region extraction image, and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; Wherein, the step S3 comprises: S31, extracting the pixel gray value of each pixel in the region image, and determining the noise discrimination value of the corresponding pixel based on the pixel gray value : ; In the formula, Represents pixel The gray value of Pixels Neighborhood pixels The gray value of represents the difference threshold, Indicates the number of pixels whose grayscale value difference between the pixel and its neighboring pixels is greater than the difference threshold. Indicates the number of neighborhood pixels; Specifically, different regional noises may exist for pixels in different regions, so different regional noises are categorized and divided, and then different images are filtered using different filtering methods to obtain filtered images.
[0032] S32, if the noise discrimination value of the pixel point If the pixel value is greater than the judgment threshold, a first rectangular window is determined with the pixel point as the center, and the pixel points in the first rectangular window are filtered by median filtering to obtain a filtered image.
[0033] S33, if the noise discrimination value of the pixel point If the pixel value is not greater than the judgment threshold, a second rectangular window is determined with the pixel point as the center, and the pixel points in the second rectangular window are filtered by using bilateral filtering to obtain a filtered image.
[0034] S4, performing edge detection on the filtered image to obtain a gradient map, and performing window division and threshold segmentation on the gradient map in sequence to obtain a defect image; Wherein, the step S4 comprises: S41, using the Sobel operator to perform edge detection on the filtered image to obtain a gradient map.
[0035] S42, segmenting the gradient image using an initial segmentation threshold to obtain a number of initial defect images; Specifically, the initial segmentation threshold is a smaller threshold.
[0036] S43, dividing each of the initial defect images into local windows, and performing automatic threshold segmentation on each of the local windows using the maximum inter-class variance method to obtain a segmented edge image; Specifically, after obtaining the initial defect image, the average grayscale value between the local window and the divided background image is calculated as the new segmentation threshold, and segmentation is performed according to 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 the preset value, and the segmented edge image can be obtained.
[0037] S44, performing non-maximum suppression and boundary tracking on the segmented edge image in sequence to obtain a defect image.
[0038] S5, extracting feature information of the defect image, storing the feature information and the corresponding defect image in a recognition data set, obtaining a template recognition image, inputting the template recognition image into a preset recognition model for training, inputting the recognition data set into the trained preset recognition model for defect detection, and outputting a defect detection result; Specifically, when extracting the characteristic information of the defect image, the boundary of the defect image can be converted into an 8-directional chain code representation, after which the perimeter and area of the defect target and other characteristic information can be calculated more conveniently; The characteristic 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, , are the number of even chain codes and odd chain codes respectively, , are the offsets of the horizontal and vertical axes, respectively. For the The vertical coordinate of the boundary pixel, is the number of boundary pixels, , are height and width respectively; After obtaining the above-mentioned feature information, it is packaged accordingly with the corresponding defect image and stored in the recognition data set, and then a template recognition image is obtained. The template recognition image contains template images and feature information of various defects. The template recognition image is used to train a preset recognition model. The preset recognition model is specifically an SVM classifier. Then, the data in the recognition data set is input into the trained SVM classifier for detection and recognition, and the corresponding detection results can be 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 according to the position of the defect image in the initial image.
[0039] The optical lens defect detection method provided in the first embodiment of the present invention first obtains several initial images of the optical lens, performs usability evaluation on the several initial images to obtain evaluation scores, and determines the optimal image based on the evaluation scores; then extracts key areas of the optimal image to obtain a regional extraction image; then identifies the noise category of each pixel point in the regional extraction image, and performs classification filtering processing on the regional extraction image based on the noise category to obtain a filtered image; then performs edge detection on the filtered image to obtain a gradient map, and performs window division and threshold segmentation on the gradient map in sequence to obtain a defect image; finally, extracts feature information of the defect image, stores the feature information and the corresponding defect image in a recognition data set, obtains a template recognition image, inputs the template recognition image into a preset recognition model for training, and inputs the recognition data set into the trained preset recognition model for defect detection to output a defect detection result. The present invention can effectively remove noise in the image by performing a series of processing on the image, retains the feature information and edge details contained in the image as much as possible, improves the accuracy of defect detection, and also speeds up the speed of defect detection.
[0040] Embodiment 2 like Figure 2 As shown, in the second embodiment of the present invention, an optical lens defect detection system is provided, and the system comprises: Evaluation module 1, used for acquiring a plurality of initial images of the optical lens, performing usability evaluation on the plurality of initial images to obtain evaluation scores, and determining the optimal image based on the evaluation scores; Extraction module 2, used for extracting key areas of the optimal image to obtain a region extraction image; A denoising 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 perform window segmentation and threshold segmentation on the gradient map in sequence to obtain a defect image; The detection module 5 is used to extract the feature information of the defect image, store the feature information and the corresponding defect image in the recognition data set, obtain the template recognition image, input the template recognition image into the preset recognition model for training, input the recognition data set into the trained preset recognition model for defect detection, and output the defect detection result.
[0041] The evaluation module 1 comprises: The first evaluation submodule is used to obtain a number of initial images of the optical lens and calculate the first scoring values of the initial images. : ; In the formula, Represents pixel The pixel value of The second evaluation submodule is used to calculate the second scoring values of several initial images : ; In the formula, Represents pixel The gray value of Pixels The gray value of Indicates the preset pixel distance; The third evaluation submodule is used to evaluate the With the second rating value Calculate review scores , and the evaluation score The initial image with the largest correspondence is taken as the optimal image: ; In the formula, Represents the scoring weight.
[0042] The extraction module 2 comprises: A scanning submodule, used for scanning each pixel point of the optimal image, and judging whether the pixel value of the pixel point is greater than a grayscale threshold based on the scanning result; A screening submodule, for storing pixel points whose pixel values are greater than a grayscale threshold into a candidate pixel point set, and arbitrarily selecting three non-collinear pixel points from the candidate pixel point set as area judgment points; A region submodule, used for determining a circular region to be selected based on the three region judgment points, and calculating the center and radius of the circular region to be selected, until all pixels in the set of pixels to be selected are selected, so as to obtain a plurality of circular regions to be selected; An accumulation submodule, used for accumulating the centers of all the circular areas to be selected to obtain an accumulation result, determining a center area based on the centers of all the circular areas to be selected, and performing non-maximum suppression on the center area of the same connected area to obtain a number of center positions; The discard submodule is used to determine whether the cumulative result corresponding to the center position of the circle is greater than the cumulative threshold, and discard the center position of the circle whose cumulative result is not greater than the cumulative threshold to obtain the true center position of the circle, and determine the area to extract the image based on the true center position.
[0043] The denoising module 3 comprises: The category determination submodule is used to extract the pixel grayscale value of each pixel in the image in the region, and determine the noise discrimination value of the corresponding pixel based on the pixel grayscale value. : ; In the formula, Represents pixel The gray value of Pixels Neighborhood pixels The gray value of represents the difference threshold, Indicates the number of pixels whose grayscale value difference between the pixel and its neighboring pixels is greater than the difference threshold. Indicates the number of neighborhood pixels; The first filtering submodule is used to determine the noise value of the pixel point. If the pixel value is greater than the judgment threshold, a first rectangular window is determined with the pixel point as the center, and the pixel points in the first rectangular window are filtered by median filtering to obtain a filtered image; The second filtering submodule is used to determine the noise value of the pixel point. If the pixel value is not greater than the judgment threshold, a second rectangular window is determined with the pixel point as the center, and the pixel points in the second rectangular window are filtered by using bilateral filtering to obtain a filtered image.
[0044] The segmentation module 4 comprises: An edge submodule, used for performing edge detection on the filtered image using a Sobel operator to obtain a gradient map; A first segmentation submodule, used to segment the gradient image using an initial segmentation threshold to obtain a plurality of initial defect images; A second segmentation submodule is used to divide each of the initial defect images into local windows, and perform automatic threshold segmentation on each of the local windows using the maximum inter-class variance method to obtain a segmented edge image; The tracking submodule is used to sequentially perform non-maximum suppression and boundary tracking on the segmented edge image to obtain a defect image.
[0045] In some other embodiments of the present invention, the embodiments of the present invention provide the following technical solution: a computer, comprising 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 implements the optical lens defect detection method as described above when executing the computer program.
[0046] Specifically, the processor 101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.
[0047] Among them, the memory 102 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 102 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a 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 a removable or non-removable (or fixed) medium. Where appropriate, the memory 102 may be inside or outside the data processing device. In a specific embodiment, the memory 102 is a non-volatile memory. In a specific embodiment, the memory 102 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0048] The memory 102 may 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 the 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. Figure 3 As shown, the processor 101, the memory 102, and the communication interface 103 are connected via a bus 100 and communicate with each other.
[0051] The communication interface 103 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present invention. The communication interface 103 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0052] The bus 100 includes hardware, software or both, and couples the components of the computer device to each other. The bus 100 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not 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 embodiments of the present invention describe and illustrate a particular bus, the present invention contemplates 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 further embodiments of the present invention, in combination with the above-mentioned optical lens defect detection method, the embodiments of the present invention provide the following technical solutions: a storage medium having a computer program stored thereon, and the computer program implements the above-mentioned optical lens defect detection method when executed by a processor.
[0055] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0056] More specific examples of readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0057] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0058] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described 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 above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for detecting defects in optical lenses, It is characterized in that include: Acquire a plurality of initial images of the optical lens, perform usability evaluation on the plurality of initial images to obtain evaluation scores, and determine an optimal image based on the evaluation scores; Extracting key areas from the optimal image to obtain an area-extracted image; Identifying the noise category of each pixel in the region extraction image, and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; Performing edge detection on the filtered image to obtain a gradient map, and sequentially performing window division and threshold segmentation on the gradient map to obtain a defect image; Extract feature information of the defect image, store the feature information and the corresponding defect image in a recognition data set, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition data set into the trained preset recognition model for defect detection, and output a defect detection result.
2. The optical lens defect detection method according to claim 1, It is characterized in that The step of acquiring a plurality of initial images of the optical lens, performing usability evaluation on the plurality of initial images to obtain evaluation scores, and determining the optimal image based on the evaluation scores comprises: Obtain several initial images of the optical lens and calculate the first scoring values of the several initial images : ; In the formula, Represents pixel The pixel value of Calculate the second score value of several initial images : ; In the formula, Represents pixel The gray value of Pixels The gray value of Indicates the preset pixel distance; Based on the first scoring value With the second rating value Calculate review scores , and the evaluation score The initial image with the largest correspondence is taken as the optimal image: ; In the formula, Represents the scoring weight.
3. The optical lens defect detection method according to claim 1, It is characterized in that The step of extracting key areas from the optimal image to obtain a region-extracted image comprises: Scan each pixel of the optimal image, and determine whether a pixel value of the pixel is greater than a grayscale threshold based on the scanning result; Storing pixel points whose pixel values are greater than the grayscale threshold into a candidate pixel point set, and arbitrarily selecting three non-collinear pixel points in the candidate pixel point set as region judgment points; Determine a circular area to be selected based on the three area judgment points, and calculate the center and radius of the circular area to be selected until all pixels in the set of pixel points to be selected are selected, so as to obtain a plurality of circular areas to be selected; The centers of all the circular regions to be selected are accumulated to obtain an accumulated result, a center region is determined based on the centers of all the circular regions to be selected, and non-maximum suppression is performed on the center region of the same connected region to obtain a number of center positions; It is determined whether the cumulative result corresponding to the center position of the circle is greater than the cumulative threshold, and the center position of the circle whose cumulative result is not greater than the cumulative threshold is discarded to obtain the true center position of the circle, and the area extraction image is determined based on the true center position.
4. The optical lens defect detection method according to claim 1, It is characterized in that In the step of determining whether the accumulated result corresponding to the center position of the circle is greater than the accumulated threshold, the accumulated threshold for: ; In the formula, is the judgment coefficient, is the radius of the circular area to be selected.
5. The optical lens defect detection method according to claim 1, It is characterized in that The step of identifying the noise category of each pixel in the region extraction image and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image includes: The pixel grayscale value of each pixel in the region extraction image is determined based on the pixel grayscale value to determine the noise discrimination value of the corresponding pixel : ; In the formula, Represents pixel The gray value of Pixels Neighborhood pixels The gray value of represents the difference threshold, Indicates the number of pixels whose grayscale value difference between the pixel and its neighboring pixels is greater than the difference threshold. Indicates the number of neighborhood pixels; If the noise discrimination value of the pixel If the pixel value is greater than the judgment threshold, a first rectangular window is determined with the pixel point as the center, and the pixel points in the first rectangular window are filtered by median filtering to obtain a filtered image; If the noise discrimination value of the pixel If the pixel value is not greater than the judgment threshold, a second rectangular window is determined with the pixel point as the center, and the pixel points in the second rectangular window are filtered by using bilateral filtering to obtain a filtered image.
6. The optical lens defect detection method according to claim 1, It is characterized in that The step of performing edge detection on the filtered image to obtain a gradient map, and sequentially performing window division and threshold segmentation on the gradient map to obtain a defect image comprises: Using the Sobel operator to perform edge detection on the filtered image to obtain a gradient map; Using an initial segmentation threshold to segment the gradient image to obtain a number of initial defect images; Dividing each of the initial defect images into local windows, and performing automatic threshold segmentation on each of the local windows using the maximum inter-class variance method to obtain a segmented edge image; Non-maximum suppression and boundary tracking are sequentially performed on the segmented edge image to obtain a defect image.
7. The optical lens defect detection method according to claim 1, It is 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.
8. An optical lens defect detection system, It is characterized in that The system comprises: An evaluation module, used for acquiring a plurality of initial images of the optical lens, performing usability evaluation on the plurality of initial images to obtain evaluation scores, and determining an optimal image based on the evaluation scores; An extraction module, used for extracting key areas of the optimal image to obtain an area extraction image; A denoising module, used for identifying the noise category of each pixel in the region extraction image, and performing classification filtering processing on the region extraction image based on the noise category to obtain a filtered image; A segmentation module, used for performing edge detection on the filtered image to obtain a gradient map, and performing window division and threshold segmentation on the gradient map in sequence to obtain a defect image; The detection module is used to extract the feature information of the defect image, store the feature information and the corresponding defect image in a recognition data set, obtain a template recognition image, input the template recognition image into a preset recognition model for training, input the recognition data set into the trained preset recognition model for defect detection, and output a defect detection result.
9. A computer comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the optical lens defect detection method as described in any one of claims 1 to 7 is implemented.
10. A storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the optical lens defect detection method as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Bridge crack identification method and system
CN119580105A
A bridge crack identification method and system
CN119580105B
Vehicle lamp lens flaw detection method and system based on traditional image processing
CN119693324A
Defect detection method and device, storage medium and electronic equipment
CN120563501A
Literature damage intelligent diagnosis method and device based on image recognition and knowledge graph
CN121685393A
