Methods, electronic devices, and storage media for detecting lens defects
By combining polar coordinate transformation and image enhancement processing with Gaussian filtering technology, lens defects can be automatically detected, solving the problems of inconsistent standards and missed detections caused by manual inspection, and improving the efficiency and accuracy of lens inspection.
Patent Information
- Application Number
- CN202510531531.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2045-04-25
AI Technical Summary
In existing technologies, lens defect detection relies on manual inspection, which leads to inconsistent inspection standards, a high rate of missed detections, and an inability to effectively ensure the quality of camera modules/lenses/lenses, thus affecting production efficiency.
By acquiring the feature image of the lens in the camera coordinate system, performing polar coordinate transformation and image enhancement processing, and combining Gaussian filter filtering technology, lens defects can be automatically detected.
It achieves efficient and accurate lens defect detection, reduces manual intervention, and improves the production efficiency and detection accuracy of camera modules/lenses/lenses.
Smart Images

Figure CN120451086B_ABST
Abstract
Description
Technical Field
[0001] This application generally relates to the field of image processing technology. More specifically, this application relates to a method for detecting lens defects, as well as an electronic device and a computer-readable storage medium for performing the aforementioned method. Background Technology
[0002] During the production of camera modules / lenses / lenses, defects such as scratches and dirt are inevitable due to processing techniques or other production operations. To ensure the quality of camera modules / lenses / lenses, a defect inspection process is usually added before they leave the factory. However, currently, defect identification mainly relies on manual labor. This manual method of identifying lens defects is limited by factors such as individual ability and visual fatigue, resulting in inconsistent inspection standards and a high rate of missed detections. This leads to poor accuracy and long inspection cycles, failing to effectively ensure the quality of camera modules / lenses / lenses leaving the factory. This increases the probability of camera modules / lenses being returned for repair, thus affecting the production efficiency of camera modules / lenses / lenses.
[0003] In view of this, there is an urgent need to provide a solution for detecting lens defects in order to achieve automated detection of defects in camera modules / lenses / lenses in an efficient and accurate manner. Summary of the Invention
[0004] In order to at least address one or more of the technical problems mentioned above, this application proposes a method, electronic device, and storage medium for detecting lens defects in several aspects.
[0005] In a first aspect, this application provides a method for detecting lens defects, comprising: acquiring a first feature image of the lens in a camera coordinate system; performing polar coordinate transformation on the first feature image to obtain a second feature image; performing image enhancement processing on the second feature image; and determining defect information of the lens based on the image after image enhancement processing.
[0006] In some embodiments, obtaining a first feature image of a lens in a camera coordinate system includes: obtaining an original grayscale image located in the camera coordinate system and containing the lens; performing boundary fitting processing on the original grayscale image to obtain boundary information of the lens; and extracting the first feature image from the original grayscale image based on the boundary information of the lens.
[0007] In some embodiments, performing boundary fitting processing on the original grayscale image includes: filtering and / or edge smoothing the original grayscale image; and performing boundary fitting processing on the filtered and / or edge smoothed original grayscale image.
[0008] In some embodiments, performing polar coordinate transformation on the first feature image to obtain a second feature image includes: converting the coordinates of each point in the first feature image into polar coordinates; and mapping all pixel grayscale values in the polar coordinate system to coordinates in the rectangular coordinate system to obtain the second feature image.
[0009] In some embodiments, image enhancement processing of the second feature image includes: performing Fourier transform processing on the second feature image to obtain a frequency domain image; performing filtering processing on the frequency domain image to obtain a filtered frequency domain image; and performing inverse Fourier transform processing on the filtered frequency domain image to obtain a spatial domain image.
[0010] In some embodiments, filtering the frequency domain image includes: convolving the frequency domain image based on a preset filter kernel to complete the filtering of the frequency domain image.
[0011] In some embodiments, the preset filter includes a Gaussian filter having a first convolution kernel and a second convolution kernel, and the first convolution kernel and the second convolution kernel have different convolution ranges. Convolving the frequency domain image based on the convolution kernel of the preset filter includes: convolving the frequency domain image based on the first convolution kernel and the second convolution kernel respectively, and performing subtraction processing on the image convolved by the first convolution kernel and the image convolved by the second convolution kernel; or performing subtraction processing on the first convolution kernel and the second convolution kernel to obtain a difference convolution kernel, and convolving the frequency domain image based on the difference convolution kernel.
[0012] In some embodiments, the image after image enhancement processing includes the spatial domain image. Determining the defect information of the lens based on the image after image enhancement processing includes: extracting the lens defect region from the spatial domain image using a local adaptive thresholding method; performing inverse polar coordinate transformation processing on the extracted lens defect region to obtain a transformed image; and determining the defect information of the lens based on the transformed image.
[0013] In a second aspect, this application provides an electronic device including: a processor; and a memory storing computer instructions for detecting lens defects, wherein when the computer instructions are executed by the processor, the electronic device causes the electronic device to perform the methods described in accordance with the foregoing and the following embodiments.
[0014] In a third aspect, this application provides a computer-readable storage medium containing program instructions for detecting lens defects, which, when executed by a processor, cause the methods described according to the foregoing and the following embodiments to be implemented.
[0015] Using the method, electronic device, and storage medium for detecting lens defects provided above, embodiments of this application perform polar coordinate transformation and image enhancement processing on the feature image of the lens in the camera coordinate system to determine the defect information of the lens based on the processed image. Therefore, the solution of this application, by transforming the first feature image of the lens in the camera coordinate system into a second feature image through polar coordinate transformation, can effectively avoid the interference of background noise in the first feature image. Simultaneously, by combining image enhancement processing technology to further process the first feature image, the contrast of the lens defect area in the image is enhanced, enabling the subsequent effective extraction of defect information of the camera module / lens / lens. It can be seen that the entire defect detection process does not require much manual intervention, and can efficiently and accurately achieve automated detection of defects in the camera module / lens / lens, ensuring the quality of the camera module / lens / lens and improving the production efficiency of the camera module / lens / lens.
[0016] Furthermore, in some embodiments, during the image enhancement process of the second feature image, a Gaussian filter with two convolutional kernels is used to filter the frequency domain image corresponding to the second feature image. This can make some low-contrast defect areas in the image more prominent, ensuring that these low-contrast defect areas can be effectively detected in subsequent processes, thereby further improving the defect detection accuracy. Attached Figure Description
[0017] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein: Figure 1 A schematic diagram of the frequency domain image of a lens in the related art is shown; Figure 2 A flowchart illustrating a method for detecting lens defects according to an embodiment of this application is shown; Figure 3 A flowchart illustrating another embodiment of the method for detecting lens defects is shown. Figure 4 A schematic diagram showing images before and after boundary fitting processing according to an embodiment of this application is illustrated; Figure 5 A partial schematic diagram of images before and after noise reduction processing according to an embodiment of this application is shown; Figure 6 A partial schematic diagram of an image before and after edge smoothing processing according to an embodiment of this application is shown; Figure 7A schematic diagram showing the images before and after polar coordinate transformation of an embodiment of this application is illustrated; Figure 8 A schematic diagram showing images before and after image enhancement processing according to an embodiment of this application is illustrated; Figure 9 This diagram illustrates a frequency domain image obtained by Fourier transforming a second feature image according to an embodiment of this application. Figure 10 A schematic diagram of the convolution kernel in a Gaussian filter according to an embodiment of this application is shown; Figure 11 A schematic diagram of a frequency domain image filtered by a Gaussian filter according to an embodiment of this application is shown; Figure 12 Schematic diagrams of images before and after inverse polar coordinate transformation of embodiments of this application are shown; and Figure 13 A schematic block diagram of the structure of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0020] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.
[0021] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0022] Exemplary application scenarios As mentioned in the background section, lens defect detection currently relies primarily on manual labor. In some implementation scenarios, the lens defect detection involved in this application includes, but is not limited to, defect detection of bare lenses or defect detection after lenses have been assembled into finished products. For example, it can be used for incoming lens inspection before the production of finished products such as camera modules, or for quality inspection after the production of finished products such as camera modules, specifically for defect detection of the end face of the lens. The inventors have discovered that the main reason why automated defect detection cannot be achieved is that there is too much background noise in the original image of the lens, and traditional filtering methods cannot remove this noise to extract the required defect area. Specifically, the original lens image is obtained after Fourier transform... Figure 1 The frequency domain diagram is shown. Figure 1 In this process, since most lenses are circular, and the modules containing these lenses also have a lot of circular noise, they create numerous ring-shaped background noise points in the low-frequency region of the frequency domain diagram. If a defect in the lens is located in this low-frequency region, it becomes very difficult to filter out all the background noise to extract the defective area. Therefore, defective lenses must be screened manually by the naked eye.
[0023] To address the problems in the aforementioned scenarios, the inventors discovered through research that polar coordinate transformation can be applied to the lens image to facilitate the removal of background noise from the transformed image by a filter, thereby improving the accurate extraction of defect areas. Based on this, a ranging scheme for detecting lens defects is proposed. The scheme transforms the first feature image of the lens in the camera coordinate system into a second feature image using polar coordinate transformation, effectively avoiding interference from background noise in the second feature image. Simultaneously, image enhancement techniques are used to further process the second feature image, enhancing the contrast of the lens defect area in the image, enabling the effective extraction of defect information from the camera module / lens / lens.
[0024] The following combination Figures 2-13 The scheme of this application is described in detail.
[0025] Figure 2 A flowchart illustrating a method 200 for detecting lens defects according to an embodiment of this application is shown.
[0026] like Figure 2 As shown, in step S201, the first feature image of the lens in the camera coordinate system is obtained.
[0027] In step S202, the first feature image can be transformed into polar coordinates to obtain the second feature image.
[0028] In step S203, image enhancement processing can be performed on the second feature image.
[0029] In step S204, defect information of the lens can be determined based on the image after image enhancement processing.
[0030] In this embodiment, commonly used image acquisition devices (such as a camera for capturing images of the lens and a fixture for fixing the lens) can be used to acquire images of the lens. In practical applications, during the process of acquiring images of the lens, the original image containing the lens inevitably contains some interfering factors (for example, the lens is installed in a finished module, and the original image may show other components besides the lens). To address this, after acquiring the original image of the lens using a camera, the area where the lens is located in the original image can be extracted to obtain the first feature image of the lens in the camera coordinate system. That is, the first feature image can be understood as an image containing only the lens.
[0031] After obtaining the aforementioned first feature image, polar coordinate transformation can be performed on it to obtain the second feature image of the lens. Since the first feature image of the lens in the camera coordinate system is typically circular or arc-shaped, and many noise points inherent in the module with the lens are similar in shape to the lens (e.g., also circular), directly converting the first feature image into a frequency domain image will result in many ring-shaped background noise points in the low-frequency region. These background noise points are difficult to filter out using traditional filtering methods, and once a lens defect appears in this low-frequency region, it cannot be effectively extracted.
[0032] In this embodiment, the first feature image undergoes polar coordinate transformation. For example, the coordinates of each point in the first feature image can be converted to polar coordinates. Then, all pixel grayscale values in the polar coordinate system are mapped to coordinates in the Cartesian coordinate system to generate the corresponding second feature image. The polar coordinate system is a coordinate system in a plane consisting of a pole, a polar axis, and a polar radius. A point O is chosen on the plane, called the pole. A ray Ox is drawn from O, called the polar axis. A unit length is then chosen, and the angle is usually defined as positive counterclockwise. Thus, the position of any point P on the plane can be determined by the length ρ of the line segment OP and the angle θ from Ox to OP. The X and Y axes in the Cartesian coordinate system correspond to θ and ρ, respectively, or the X-axis value is related to θ, and the Y-axis value is related to ρ. After polar coordinate transformation, the background in the second feature image generally appears as stripes (e.g., a rectangular image). In this case, the striped background in the second feature image is easier to filter out compared to circular or arc-shaped backgrounds.
[0033] After obtaining the second feature image, image enhancement processing can be performed on the second feature image to enhance the contrast of the lens defect area in the image, so that the lens defect area can be effectively distinguished from the background area, which facilitates the extraction of the lens defect area.
[0034] Therefore, by transforming the first feature image of the lens (such as the end face lens of the lens in the camera module, the end face lens of the lens, or the bare lens) in the camera coordinate system into polar coordinates to obtain the second feature image, the interference of background noise in the second feature image can be effectively avoided. Simultaneously, image enhancement processing technology is used to further process the second feature image, enhancing the contrast of the lens defect area in the second feature image, enabling the effective extraction of defect information from the camera module / lens / lens. It can be seen that the entire defect detection process does not require much manual intervention, achieving efficient and accurate automated detection of defects in the camera module / lens / lens, ensuring the quality of the camera module / lens / lens, and improving the production efficiency of the camera module / lens / lens.
[0035] Figure 3 A flowchart illustrating a method 300 for detecting lens defects according to another embodiment of this application is shown. It should be noted that... Figure 3 Method 300 in the text can be understood as a... Figure 2 Further limitations or extensions of Chinese method 200. Therefore, the preceding text, combined with... Figure 2 The relevant descriptions also apply to the following text.
[0036] In this embodiment, it is necessary to first obtain the first feature image of the lens in the camera coordinate system, which is obtained through the following steps S301 to S303.
[0037] In step S301, a raw grayscale image containing the lens can be acquired in the camera coordinate system. For example, a commercially available camera and a fixture for fixing the lens can be used to build the image acquisition device. In practical applications, the camera can be used to photograph the lens fixed by the fixture to obtain the raw grayscale image. Of course, the lens here can be a bare lens or a lens installed in some pre-built modules.
[0038] In step S302, the original grayscale image can be subjected to boundary fitting processing to obtain the boundary information of the lens.
[0039] In step S303, the first feature image can be extracted from the original grayscale image based on the boundary information of the lens.
[0040] In some embodiments, if the original grayscale image has less noise (e.g., the end face of the module with the lens is relatively flat) or the edges are relatively smooth, the original grayscale image can be directly subjected to boundary fitting processing to determine the boundary position of the lens in the image, so as to determine the area where the lens is located based on the boundary position of the lens, and the area where the lens is located is extracted from the original grayscale image to obtain the first feature image.
[0041] In other embodiments, during actual module imaging, the roughness of the module end face can lead to significant noise under bowl lighting. That is, the original grayscale image contains a lot of noise, which may affect the determination of lens boundaries. Therefore, the original grayscale image can be filtered (i.e., denoising) to reduce the interference of this noise. For example, morphological closing operations, mean filtering, or median filtering can be used to suppress noise. Preferably, a convolution kernel of a certain size can be used for closing operations to achieve filtering of the original grayscale image.
[0042] In some embodiments, considering that the edge pixels in the original grayscale image may be irregularly distributed (e.g., jagged edge contours), directly performing edge fitting would affect the accuracy of subsequent polar coordinate transformation. Therefore, edge smoothing can be performed on the original grayscale image. For example, opening operations can be performed using a convolution kernel of a certain size to complete the edge smoothing process.
[0043] Of course, the original grayscale image can also be subjected to the above-mentioned filtering and edge smoothing processes, and the original grayscale image after filtering and / or edge smoothing can be subjected to boundary fitting processing.
[0044] In addition, in this embodiment, the least squares method, Hough (fitting circle), and other fitting methods can be used to perform edge fitting processing on the original grayscale image, or the original grayscale image after filtering and / or edge smoothing. It should be noted that the specific edge fitting processing method is not limited here, and the appropriate fitting method can be selected according to the shape of the lens or application requirements to achieve edge fitting processing.
[0045] As an example Figure 4 A schematic diagram showing images before and after boundary fitting processing according to an embodiment of this application is illustrated. Figure 4 In the original grayscale image 401, the lens is circular. Therefore, a circle fitting method can be used to perform boundary fitting on the original grayscale image 401. Specifically, the original grayscale image 401 can first be filtered and / or edge smoothed. Before filtering or noise reduction, a local image of the original grayscale image 401 is as follows: Figure 5 As shown in image 501, multiple noise points exist. In this implementation scenario, denoising methods such as morphological closing, mean filtering, or median filtering can be used to obtain the filtered image 502.
[0046] If the edge pixels in the original grayscale image 401 may be irregularly distributed, then edge smoothing processing of the original grayscale image 401 is required. For example, the edge contours of the original grayscale image 401 may have a jagged distribution (such as...). Figure 6 (As shown in image 601). In this implementation scenario, morphological opening operations can be used for edge smoothing to obtain the original grayscale image 401 after edge smoothing. At this time, the local image of the original grayscale image 401 after edge smoothing is as follows. Figure 6 As shown in image 602.
[0047] After filtering and / or edge smoothing of the original grayscale image 401, edge fitting can be performed on the processed original grayscale image 401. For example, a circle fitting method can be used to determine the center position of the lens in the original grayscale image. Then, boundary information is determined based on the positional relationship between the lens and the center of the circle, and the determined boundary information is used to extract the first feature image 402 from the original grayscale image.
[0048] This completes the acquisition of the first feature image. Then, the first feature image can be transformed into polar coordinates to obtain the second feature image.
[0049] Specifically, return Figure 3 In step S304, the coordinates of each point in the first feature image can be converted into polar coordinates. Then, in step S305, all pixel grayscale values in the polar coordinate system are mapped to coordinates in the rectangular coordinate system to obtain the second feature image.
[0050] For example, such as Figure 7 As shown, the first feature image 701 is circular. After performing polar coordinate transformation on the first feature image 701 using the method described above, the second feature image 702 is obtained. Typically, the second feature image 702 is a rectangular lens image.
[0051] The principle of converting coordinates in the camera coordinate system to polar coordinates is as follows: the coordinates of each point in the image in the camera coordinate system are converted to polar coordinates, and all pixel grayscale values in the polar coordinate system are mapped to coordinates in the Cartesian coordinate system to generate the corresponding second feature image (e.g., a rectangular image). In the Cartesian coordinate system, the X and Y axes correspond to θ and ρ in the polar coordinate system, or the X-axis value is related to θ, and the Y-axis value is related to ρ.
[0052] Next, we can proceed as follows: Figure 3 Steps S306 to S308 in the process perform image enhancement processing on the second feature image.
[0053] In step S306, the second feature image is subjected to Fourier transform processing to obtain a frequency domain image.
[0054] In step S307, the aforementioned frequency domain image can be filtered to obtain a filtered frequency domain image.
[0055] In step S308, the filtered frequency domain image is subjected to inverse Fourier transform to obtain the spatial domain image.
[0056] For example, such as Figure 8 As shown, after image enhancement processing such as Fourier transform processing, filtering processing and inverse Fourier transform processing, the second feature image 801 can be used to obtain the spatial domain image 802.
[0057] Among them, the second feature image 801, after undergoing Fourier transform processing, can obtain the following: Figure 9 The frequency domain image shown is 900. The Fourier transform formula is: As is known from Fourier series, the larger n is, the faster the frequency, and the greater the high-frequency noise in the spatial domain. Then, the frequency domain image 900 can be filtered using neighborhood denoising, point operation algorithms, or by using a pre-defined filter's convolution kernel to complete the filtering process.
[0058] In this embodiment, preferably, the frequency domain image is filtered using a preset filter convolution kernel. The first and second convolution kernels have different convolution ranges. The frequency domain image can be convolved using the first and second convolution kernels respectively, and the difference between the image convolved by the first kernel and the image convolved by the second kernel can be calculated. Alternatively, the difference between the first and second convolution kernels can be calculated to obtain a difference convolution kernel, and the frequency domain image can be convolved using this difference convolution kernel.
[0059] For example, in Figure 10 In this context, the preset filter can be a Gaussian filter. This Gaussian filter has a two-dimensional Gaussian function model: Based on the two-dimensional Gaussian function model, combined with the frequency domain range of lens defects, and the requirement to avoid background noise information from the lens, the ranges of two Gaussian filter convolution kernels are designed (i.e., the ranges of the kernels are determined). Figure 10 The convolution ranges of the first convolution kernel 1001 and the second convolution kernel 1002 are calculated. Then, the first convolution kernel 1001 and the second convolution kernel are subtracted to obtain the difference convolution kernel 1003. Then, the difference convolution kernel 1003 is used to process the frequency domain image (such as...). Figure 9 The frequency domain image (900) is convolved to obtain the filtered frequency domain image (e.g., ...). Figure 11 The frequency domain image 1100 shown is obtained by performing a Fourier integral and a Gaussian kernel convolution H=G*F in the frequency domain. H is the frequency domain function resulting from the convolution of the Fourier integral with a Gaussian kernel.
[0060] Therefore, in the process of image enhancement of the second feature image, a Gaussian filter with two convolutional kernels is used to filter the frequency domain image corresponding to the second feature image. This can filter the frequency in a specific channel to reduce fixed noise, making some low-contrast defect areas in the image more prominent. This ensures that these low-contrast defect areas can be effectively detected in subsequent processes, further improving the defect detection accuracy.
[0061] After obtaining the filtered frequency domain image, an inverse Fourier transform can be performed on the filtered frequency domain image to obtain the spatial domain image (e.g., Figure 8 (e.g., spatial domain image 802). For example, formula After integration, the spatial domain image can be obtained. Among them, This is the frequency domain function resulting from the convolution of the aforementioned Fourier integral with a Gaussian kernel.
[0062] After obtaining the spatial domain image, return Figure 3 In step S309, the defect information of the lens can be determined based on the spatial domain image.
[0063] In some embodiments, a local adaptive threshold method may be used to extract the lens defect region from the spatial domain image. Next, inverse polar coordinate conversion processing is performed on the extracted lens defect region to obtain a converted image. Then, defect information of the lens is determined based on the converted image.
[0064] As an example, in Figure 12 , after the spatial domain image 1201 is obtained, the local adaptive threshold method may be used to extract the lens defect region and perform inverse polar coordinate conversion processing on the extracted lens defect region, so as to obtain a circular lens image 1202 of normal size, and output the defect position coordinates. As Figure 12 shown, the white rectangular wireframe in the circular lens image 1202 indicates the lens defect position.
[0065] The local adaptive threshold method includes: performing a mean filtering operation on the spatial domain image, calculating the difference between the average value A of the pixel block around the pixel (x, y) in the mean-filtered image (for example, of size blockSize_x × blockSize_y) and a subtraction constant C (the constant is the grayscale value of the pixel (x, y) in the spatial domain image), and comparing the magnitude of the difference with the adaptive threshold T(x, y). If A-C<T, it indicates that this pixel point is brighter than the surrounding pixels; otherwise, it indicates that this pixel point is darker than the surrounding pixels. If it is required to extract the relatively bright pixels as the pixel points of the lens defect region, all pixel points where A-C<T may be extracted. Compared with other defect extraction methods, the local adaptive threshold method can more accurately extract the defect position points in the spatial domain image.
[0066] In addition, the inverse polar coordinate conversion processing performed on the extracted lens defect region may be implemented by converting the image in the Cartesian coordinate system back to the polar coordinate system, and then converting the polar coordinates to Cartesian coordinates.
[0067] Therefore, by transforming the first feature image of the lens (such as the end face lens of the lens in the camera module, the end face lens of the lens, or the bare lens) in the camera coordinate system into polar coordinates to obtain the second feature image, the interference of background noise in the second feature image can be effectively avoided. Simultaneously, image enhancement processing techniques are used to further process the second feature image, enhancing the contrast of the lens defect area in the image, enabling the effective extraction of lens defect information in subsequent processing. The entire defect detection process requires minimal manual intervention, achieving efficient and accurate automated detection of defects in the camera module / lens / lens, ensuring the quality of the camera module / lens / lens. Furthermore, using a Gaussian filter with two convolutional kernels to filter the frequency domain image corresponding to the second feature image makes some low-contrast defect areas in the image more prominent, ensuring that these low-contrast defect areas can be effectively detected in subsequent processes, further improving defect detection accuracy. In addition, it can not only greatly improve production efficiency, reduce defects and missed detections, and enhance the degree of automation in production, but it is also an important measure to promote the transformation and upgrading of traditional manufacturing industries. It is of great significance for technological progress, improving the quality of the workforce, increasing enterprise production efficiency, promoting industrial restructuring, and advancing the transformation of industrial development.
[0068] Figure 13 A schematic block diagram of an electronic device 1300 according to an embodiment of the present disclosure is shown. Specifically, as follows... Figure 13 As shown, the electronic device 1300 may include a processor 1301 and a memory 1302. The memory 1302 stores computer instructions for detecting lens defects. When the computer instructions are executed by the processor 1301, the electronic device 1300 performs the following actions: acquiring a first feature image of the lens in a camera coordinate system; performing polar coordinate transformation on the first feature image to obtain a second feature image; performing image enhancement processing on the second feature image; and determining the defect information of the lens based on the image enhancement processed image.
[0069] Optionally, obtaining the first feature image of the lens in the camera coordinate system includes: obtaining an original grayscale image located in the camera coordinate system and containing the lens; performing boundary fitting processing on the original grayscale image to obtain the boundary information of the lens; and extracting the first feature image from the original grayscale image based on the boundary information of the lens.
[0070] Optionally, performing boundary fitting processing on the original grayscale image includes: filtering and / or edge smoothing the original grayscale image; and performing boundary fitting processing on the filtered and / or edge smoothed original grayscale image.
[0071] Optionally, performing polar coordinate transformation on the first feature image to obtain the second feature image includes: converting the coordinates of each point in the first feature image into polar coordinates; and mapping all pixel grayscale values in the polar coordinate system to coordinates in the rectangular coordinate system to obtain the second feature image.
[0072] Optionally, the image enhancement processing of the second feature image includes: performing Fourier transform processing on the second feature image to obtain a frequency domain image; performing filtering processing on the frequency domain image to obtain a filtered frequency domain image; and performing inverse Fourier transform processing on the filtered frequency domain image to obtain a spatial domain image.
[0073] Optionally, filtering the frequency domain image includes: convolving the frequency domain image based on a preset filter kernel to complete the filtering process of the frequency domain image.
[0074] Optionally, the preset filter includes a Gaussian filter with a first convolution kernel and a second convolution kernel, and the first convolution kernel and the second convolution kernel have different convolution ranges. Convolving the frequency domain image based on the convolution kernel of the preset filter includes: convolving the frequency domain image based on the first convolution kernel and the second convolution kernel respectively, and performing subtraction processing on the image after convolution by the first convolution kernel and the image after convolution by the second convolution kernel; or performing subtraction processing on the first convolution kernel and the second convolution kernel to obtain a difference convolution kernel, and convolving the frequency domain image based on the difference convolution kernel.
[0075] Optionally, the image after image enhancement processing includes the spatial domain image. Determining the defect information of the lens based on the image after image enhancement processing includes: extracting the lens defect region from the spatial domain image using a local adaptive thresholding method; performing inverse polar coordinate transformation processing on the extracted lens defect region to obtain a transformed image; and determining the defect information of the lens based on the transformed image.
[0076] Through the above implementation method, the electronic device can obtain a second feature image by transforming the first feature image of the lens in the camera coordinate system into polar coordinates. This effectively avoids the interference of background noise in the second feature image. Simultaneously, image enhancement processing technology is used to further process the second feature image, enhancing the contrast of the lens defect area in the image, enabling the effective extraction of lens defect information. The entire defect detection process requires minimal manual intervention, achieving efficient and accurate automated detection of defects in the camera module / lens / lens, ensuring lens quality and improving the production efficiency of camera modules / lenses / lenses.
[0077] It should be noted that the specific details of the operating method and steps of this electronic device are combined with the foregoing. Figures 2-12 The specific implementation methods described are the same or similar, so they will not be elaborated here.
[0078] Furthermore, this disclosure also provides a computer-readable storage medium storing program instructions configured to execute at runtime. Figure 2 and Figure 3 The method shown is for detecting defects in lenses.
[0079] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0080] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.
Claims
1. A method for detecting lens defects, characterized in that, include: Obtain the first feature image of the lens in the camera coordinate system; The first feature image is subjected to polar coordinate transformation to obtain the second feature image; Image enhancement processing of the second feature image includes: performing Fourier transform processing on the second feature image to obtain a frequency domain image; convolving the frequency domain image based on a preset filter kernel, wherein the preset filter includes a Gaussian filter with a first convolution kernel and a second convolution kernel, and the first convolution kernel and the second convolution kernel have different convolution ranges; convolving the frequency domain image based on the first convolution kernel and the second convolution kernel respectively; and performing subtraction processing on the image convolved by the first convolution kernel and the image convolved by the second convolution kernel; or performing subtraction processing on the first convolution kernel and the second convolution kernel to obtain a difference convolution kernel, and convolving the frequency domain image based on the difference convolution kernel; performing inverse Fourier transform processing on the filtered frequency domain image to obtain a spatial domain image; and Based on the image after image enhancement processing, the defect information of the lens is determined. The image after image enhancement processing includes the spatial domain image. Based on the image after image enhancement processing, the defect information of the lens is determined as follows: The lens defect region is extracted from the spatial domain image using a local adaptive thresholding method. The extracted lens defect region is subjected to inverse polar coordinate transformation to obtain the transformed image; and The defect information of the lens is determined based on the converted image.
2. The method for detecting lens defects according to claim 1, characterized in that, Obtaining the first feature image of the lens in the camera coordinate system includes: Obtain the original grayscale image located in the camera coordinate system and containing the lens; The original grayscale image is subjected to boundary fitting processing to obtain the boundary information of the lens; and Based on the boundary information of the lens, the first feature image is extracted from the original grayscale image.
3. The method for detecting lens defects according to claim 2, characterized in that, Boundary fitting processing of the original grayscale image includes: The original grayscale image is filtered and / or edge-smoothed; and Perform boundary fitting on the original grayscale image after filtering and / or edge smoothing.
4. The method for detecting lens defects according to claim 1, characterized in that, Performing polar coordinate transformation on the first feature image to obtain the second feature image includes: Convert the coordinates of each point in the first feature image to polar coordinates; and The grayscale values of all pixels in the polar coordinate system are mapped to coordinates in the rectangular coordinate system to obtain the second feature image.
5. An electronic device, characterized in that, Also includes: processor; as well as A memory storing computer instructions for detecting lens defects, which, when executed by the processor, cause the electronic device to perform the method according to any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that, It includes program instructions for detecting lens defects, which, when executed by a processor, cause the method according to any one of claims 1 to 4 to be implemented.
Citation Information
Patent Citations
Microcrack detection method, device and system and storage medium
CN113822890A
Semiconductor silicon wafer detection method and device based on frequency decoupling supervision and medium
CN116309612A
Pipeline defect detection method and device, electronic equipment and readable storage medium
CN117809018A
