Method for detecting lens defects, electronic equipment and storage medium
Through polar coordinate conversion and image enhancement processing combined with Gaussian filtering technology, the lens defects are automatically detected, which solves the problems of different detection standards and high missed detection rates caused by manual detection, and improves the lens production efficiency and quality.
Patent Information
- Application Number
- CN202510531531.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, lens defect detection relies on manual detection, resulting in different detection standards and high missed detection rates, which cannot effectively ensure the quality of the camera module/lens/lens, which affects production efficiency.
By acquiring the characteristic images of the lens under the camera coordinate system, polar coordinate conversion and image enhancement processing are performed, and combined with Gaussian filtering technology, lens defects are automatically detected.
It realizes efficient and accurate lens defect detection, reduces manual intervention, and improves the production efficiency and detection accuracy of the camera module/lens/lens.
Smart Images

Figure CN120451086A_ABST
Abstract
Description
Technical Field
[0001] The present application generally relates to the field of image processing technology. More specifically, the present application relates to a method for detecting lens defects, as well as an electronic device and a computer-readable storage medium for executing the method. Background Art
[0002] During the production process of camera modules / lenses / glasses, defects such as scratches and dirt are inevitable due to the processing technology or other production operations. In order to ensure the quality of camera modules / lenses / glasses, a lens defect detection process is usually added before leaving the factory. However, at present, defect identification still relies mainly on manual labor. This method of manual identification of lens defects is limited by factors such as personal ability and visual fatigue, and can lead to problems such as inconsistent detection standards and high missed detection rates. This results in poor defect detection accuracy and long detection cycles, making it impossible to effectively ensure the factory quality of camera modules / lenses / glasses, increasing the probability of camera modules / lenses / glasses being returned for repair, thereby affecting the production efficiency of camera modules / lenses / glasses.
[0003] In view of this, there is an urgent need to provide a solution for detecting lens defects so as to efficiently and accurately realize automated detection of defects in camera modules / lenses / lenses. Summary of the Invention
[0004] In order to at least solve one or more of the technical problems mentioned above, the present application proposes a method, an electronic device, and a storage medium for detecting lens defects in multiple aspects.
[0005] In a first aspect, the present application provides a method for detecting lens defects, comprising: obtaining a first characteristic image of the lens in a camera coordinate system; performing polar coordinate conversion processing on the first characteristic image to obtain a second characteristic image; performing image enhancement processing on the second characteristic 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 the 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 based on the boundary information of the lens, extracting the first feature image from the original grayscale image.
[0007] In some embodiments, performing boundary fitting processing on the original grayscale image includes: performing filtering and / or edge smoothing processing on 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 conversion processing 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.
[0009] In some embodiments, performing image enhancement processing on 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 convolution kernel of a preset filter to complete filtering the frequency domain image.
[0011] In some embodiments, wherein 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 difference processing on the image convolved with the first convolution kernel and the image convolved with the second convolution kernel; or performing difference 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, wherein 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 area from the spatial domain image using a local adaptive threshold method; performing inverse polar coordinate transformation on the extracted lens defect area to obtain a converted image; and determining the defect information of the lens based on the converted image.
[0013] In a second aspect, the present application provides an electronic device comprising: 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 executes the method described in the foregoing and following embodiments.
[0014] In a third aspect, the present application provides a computer-readable storage medium comprising program instructions for detecting lens defects. When the program instructions are executed by a processor, the method according to the above and following embodiments is implemented.
[0015] Through the method, electronic device and storage medium for detecting lens defects provided above, the embodiment of the present application performs polar coordinate conversion processing and image enhancement processing on the characteristic 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 the present application obtains the second characteristic image by polar coordinate conversion processing on the first characteristic image of the lens in the camera coordinate system, which can effectively avoid the interference of background noise in the first characteristic image, and further processes the first characteristic image in combination with image enhancement processing technology to enhance the contrast of the lens defect area in the image, so that the defect information of the camera module / lens / lens can be effectively extracted later. It can be seen that the entire defect detection process can efficiently and accurately realize the automated detection of defects of the camera module / lens / lens without introducing too much manual intervention, thereby 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 convolution kernels is used to filter the frequency domain image corresponding to the second feature image, which 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other objects, features and advantages of the exemplary embodiments of the present application will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 A schematic diagram showing a frequency domain image of a lens in the related art is shown; Figure 2 A schematic flow chart showing a method for detecting lens defects according to an embodiment of the present application is shown; Figure 3 A schematic flow chart showing a method for detecting lens defects according to another embodiment of the present application is shown; Figure 4 Schematic diagram showing an image before and after boundary fitting processing according to an embodiment of the present application; Figure 5 A partial schematic diagram of an image before and after noise reduction processing according to an embodiment of the present application is shown; Figure 6 A partial schematic diagram of an image before and after edge smoothing processing according to an embodiment of the present application is shown; Figure 7A schematic diagram showing an image before and after polar coordinate conversion processing according to an embodiment of the present application is shown; Figure 8 Schematic diagram showing an image before and after image enhancement processing according to an embodiment of the present application; Figure 9 A schematic diagram showing a frequency domain image obtained after Fourier transform processing of the second characteristic image of an embodiment of the present application; Figure 10 A schematic diagram of a convolution kernel in a Gaussian filter according to an embodiment of the present application is shown; Figure 11 A schematic diagram showing a frequency domain image after being filtered by a Gaussian filter according to an embodiment of the present application is shown; Figure 12 A schematic diagram showing an image before and after inverse polar coordinate conversion according to an embodiment of the present application; and Figure 13 A schematic structural block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0019] It should be understood that the terms "include" and "comprising" used in the description and claims of this application indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.
[0020] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this 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 further understood that the term "and / or" as used in this specification and claims refers to any and all possible combinations of one or more of the associated listed items, including and including these combinations.
[0021] As used in this specification and claims, the term “if” can be interpreted as “when” or “upon” or “in response to determining” or “in response to detecting,” depending on the context. Similarly, the phrase “if it is determined” or “if [described condition or event] is detected” can be interpreted as meaning “upon determination” or “in response to determining” or “upon detection of [described condition or event]” or “in response to detecting [described condition or event],” depending on the context.
[0022] Example application scenarios As described in the background technology above, the defect detection of lenses currently mainly relies on manual labor. In some implementation scenarios, the defect detection of lenses involved in this application includes but is not limited to defect detection on bare lenses, or defect detection on lenses after they are 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, defect detection can be performed on the end lenses of the lenses. The inventors have found that the main reason why automated defect detection cannot be achieved at present is that there is too much background noise information in the original image of the lens, and traditional filtering methods cannot filter out this noise information to extract the desired defect area. Specifically, the original lens image is obtained after Fourier transformation. Figure 1 The frequency domain diagram is shown in Figure 1 Since most lenses are circular, the noise generated by the modules in which they are installed is also circular. This creates a lot of ring-shaped background noise in the low-frequency region in the middle of the frequency domain graph. Once a defect in the lens is located in this low-frequency region, it is difficult to filter out all the background noise and extract the defective area. Therefore, the only way to screen for defective lenses is to rely on the naked eye.
[0023] To address the issues in these scenarios, the inventors discovered through research that a polar coordinate transformation can be performed on the lens image, allowing a filter to remove background noise from the transformed image, thereby facilitating the precise extraction of defect areas. Based on this, a ranging scheme for detecting lens defects was proposed. This scheme transforms the first characteristic image of the lens in the camera coordinate system into a second characteristic image through polar coordinate transformation, effectively eliminating interference from background noise in the second characteristic image. Furthermore, this second characteristic image is further processed using image enhancement techniques to enhance the contrast of the defective lens area in the image, enabling the subsequent effective extraction of defect information from the camera module, lens, or lens.
[0024] The following combination Figures 2 to 13 The solution of this application is described in detail.
[0025] Figure 2 FIG. 1 is a flow chart of a method 200 for detecting lens defects according to an embodiment of the present application.
[0026] like Figure 2 As shown, in step S201, a first characteristic image of the lens in the camera coordinate system is obtained.
[0027] In step S202 , polar coordinate conversion processing may be performed on the first feature image to obtain a second feature image.
[0028] In step S203 , image enhancement processing may be performed on the second feature image.
[0029] In step S204, defect information of the lens may be determined based on the image after image enhancement processing.
[0030] In this embodiment, commonly used image acquisition devices (e.g., a camera for capturing images of the lens and a jig for securing the lens) can be used to capture images of the lens. In practical applications, when capturing images of the lens, the original image containing the lens will inevitably contain some interference factors (e.g., when the lens is installed in a finished module, the original image may also contain other components besides the lens). To address this issue, after capturing the original image of the lens using a camera, the region containing the lens in the original image can be extracted to obtain a first feature image of the lens in the camera coordinate system. In other words, the first feature image can be understood as an image containing only the lens.
[0031] After obtaining the aforementioned first characteristic image, polar coordinate conversion can be performed on it to obtain the second characteristic image of the lens. Since the first characteristic image of the lens in the camera coordinate system is typically circular or arc-shaped, and the module in which the lens is mounted has many inherent noise points similar to the lens shape (e.g., also circular), directly converting the first characteristic image into a frequency domain image will result in a large amount of ring-shaped background noise in the low-frequency region of the frequency domain image. This background noise is difficult to filter out using traditional filtering methods, and if lens defects appear in this low-frequency region, they cannot be effectively extracted.
[0032] To address this issue, this embodiment performs polar coordinate conversion on the first feature image. For example, the coordinates of each point in the first feature image can be converted to polar coordinates. Then, the grayscale values of all pixels in the polar coordinate system are mapped to coordinates in a rectangular coordinate system to generate the corresponding second feature image. A polar coordinate system refers to a coordinate system within a plane consisting of a pole, a polar axis, and a polar radius. A point O is defined on the plane, called the pole. A ray Ox is drawn from O, called the polar axis. A unit length is then defined, with angles generally taken counterclockwise as positive. 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. In the rectangular coordinate system, the X and Y axes correspond to θ and ρ, or the X-axis value is related to θ and the Y-axis value is related to ρ. The background in the second feature image obtained after polar coordinate conversion generally appears as a strip (e.g., a rectangular image). In this case, the strip background in the second feature image is more easily filtered out than circular or arc-shaped backgrounds.
[0033] After obtaining the above-mentioned second characteristic image, the second characteristic image can be subjected to image enhancement processing 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, thereby facilitating the extraction of the lens defect area.
[0034] Thus, by converting the first characteristic image of a lens (e.g., the end lens of a camera module, the end lens of a lens, or a bare lens) in the camera coordinate system through polar coordinate conversion to obtain a second characteristic image, interference from background noise in the second characteristic image can be effectively avoided. Furthermore, the second characteristic image is further processed using image enhancement techniques to enhance the contrast of defective areas of the lens in the second characteristic image, enabling subsequent effective extraction of defect information about the camera module / lens / lens. This demonstrates that the entire defect detection process can efficiently and accurately achieve automated detection of camera module / lens / lens defects without requiring excessive human intervention, ensuring the quality of the camera module / lens / lens and improving their production efficiency.
[0035] Figure 3 FIG2 is a flow chart of a method 300 for detecting lens defects according to another embodiment of the present application. Figure 3 The method 300 can be understood as Figure 2 Therefore, the above combined with the method 200 further defines or expands Figure 2 The relevant description also applies to the following.
[0036] In this embodiment, it is necessary to first obtain a first characteristic image of the lens in the camera coordinate system. Specifically, the first characteristic image is obtained by following steps S301 to S303.
[0037] In step S301, an original grayscale image of the lens, located in the camera coordinate system, can be acquired. For example, an image acquisition device can be constructed using a common commercially available camera and a fixture for securing the lens. In practical applications, the camera can be used to capture the lens secured by the fixture to obtain the original grayscale image. Of course, the lens here can be a bare lens or a lens installed in a finished module.
[0038] In step S302, boundary fitting processing may be performed on the original grayscale image to obtain boundary information of the lens.
[0039] In step S303, the first feature image may be extracted from the original grayscale image based on the boundary information of the lens.
[0040] In some embodiments, if there are fewer noise points in the original grayscale image (for example, the end face of the module where the lens is installed is relatively flat) or the edge is 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, and the area where the lens is located can be determined based on the boundary position of the lens, and the area where the lens is located can be cut out from the original grayscale image to obtain a first feature image.
[0041] In other embodiments, in actual module imaging, the roughness of the module end face can lead to a high level of noise under bowl-light illumination. This means that the original grayscale image contains a high level of noise, which can affect the determination of the lens boundary. Therefore, filtering (i.e., noise reduction) can be performed on the original grayscale image to reduce the interference of this noise. For example, noise suppression can be achieved using methods such as morphological closing, mean filtering, or median filtering. Preferably, a convolution kernel of a certain size can be used for closing to filter the original grayscale image.
[0042] In some other embodiments, considering that edge pixels in the original grayscale image may be irregularly distributed (e.g., edge contours may be jagged), directly performing edge fitting may affect the accuracy of the subsequent polar coordinate transformation. Therefore, edge smoothing may be performed on the original grayscale image. For example, an opening operation may be performed using a convolution kernel of a certain size to achieve edge smoothing.
[0043] Of course, the above-mentioned filtering and edge smoothing processing may also be performed on the original grayscale image, and the boundary fitting processing may be performed on the filtered and / or edge smoothed original grayscale image.
[0044] In addition, in this embodiment, edge fitting processing can be performed on the original grayscale image, or the original grayscale image after filtering and / or edge smoothing, using fitting methods such as the least squares method and Hough (circle fitting). It should be noted that the specific edge fitting processing method is not limited here, and the corresponding fitting method can be selected to implement edge fitting processing based on the shape of the lens or application requirements.
[0045] As an example, Figure 4 Schematic diagram of an image before and after boundary fitting processing of an embodiment of the present application is shown. Figure 4 In the original grayscale image 401, the lens is circular. In this case, the circle fitting method can be used to perform boundary fitting on the original grayscale image 401. Specifically, the original grayscale image 401 can be filtered and / or edge smoothed. Before filtering or noise reduction, the local image of the original grayscale image 401 is as follows: Figure 5 As shown in the image 501 in FIG, there are multiple noise points. In this implementation scenario, morphological closing operation, mean filtering or median filtering can be used to perform noise reduction processing to obtain a filtered image 502.
[0046] If the edge pixels in the original grayscale image 401 are irregularly distributed, it is necessary to perform edge smoothing on the original grayscale image 401. For example, the edge contour of the original grayscale image 401 is jagged (e.g., Figure 6 In this implementation scenario, morphological opening operation can be used to perform 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 shown in FIG. Figure 6 As shown in image 602.
[0047] After filtering and / or edge smoothing 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. Boundary information is then determined based on the positional relationship between the lens and the center of the circle. This determined boundary information is then used to extract the first feature image 402 from the original grayscale image.
[0048] At this point, the acquisition of the first characteristic image is completed. Then, the first characteristic image can be subjected to polar coordinate conversion processing to obtain the second characteristic image.
[0049] Specifically, return Figure 3 At step S304, the coordinates of each point in the first feature image can be converted into polar coordinates. Then, at step S305, all pixel grayscale values in the polar coordinate system are mapped to coordinates in the rectangular coordinate system to obtain a second feature image.
[0050] As an example, Figure 7 As shown, the first characteristic image 701 is circular, and after the polar coordinate conversion process is performed on the first characteristic image 701 using the above method, the second characteristic image 702 is obtained. Usually, the second characteristic image 702 is a rectangular lens image.
[0051] The principle of converting the 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 the grayscale values of all pixels in the polar coordinate system are mapped to coordinates in the rectangular coordinate system to generate a corresponding second feature image (e.g., a rectangular image). The X and Y axes in the rectangular coordinate system correspond to θ and ρ in the polar coordinate system, or the value of the X axis is related to θ, and the value of the Y axis is related to ρ.
[0052] Next, you can Figure 3 Steps S306 to S308 in the above process perform image enhancement processing on the second feature image.
[0053] In step S306 , Fourier transform processing is performed on the second feature image to obtain a frequency domain image.
[0054] In step S307 , the aforementioned frequency domain image may be subjected to filtering processing to obtain a filtered frequency domain image.
[0055] In step S308 , an inverse Fourier transform is performed on the filtered frequency domain image to obtain a spatial domain image.
[0056] As an example, Figure 8 As shown, after the second feature image 801 undergoes image enhancement processing such as Fourier transform processing, filtering processing, and inverse Fourier transform processing, a spatial domain image 802 can be obtained.
[0057] Among them, after the second feature image 801 is processed by Fourier transform, the following can be obtained: Figure 9 The frequency domain image 900 is shown. The Fourier transform formula is: ). According to the Fourier series, a larger n indicates a faster frequency and a larger high-frequency noise converted in the spatial domain. Frequency domain image 900 can then be filtered using a domain denoising method or a point operation algorithm, or using a pre-set convolution kernel of a filter to complete the filtering of the frequency domain image.
[0058] In this embodiment, preferably, the frequency domain image is filtered using a convolution kernel of a preset filter. The first convolution kernel and the second convolution kernel have different convolution ranges. The frequency domain image can be convolved with the first and second convolution kernels, respectively, and a difference processing can be performed on the image convolved with the first and second convolution kernels. Alternatively, the first and second convolution kernels can be subtracted to obtain a difference convolution kernel, and the frequency domain image can be convolved with the difference convolution kernel.
[0059] For example, in Figure 10 In the example, the preset filter may be a Gaussian filter. The Gaussian filter has a two-dimensional Gaussian function model: According to the two-dimensional Gaussian function model, combined with the interval of lens defects in the frequency domain, and the need to avoid lens background noise information, two Gaussian filter convolution kernel ranges are designed (that is, determining Figure 10 The convolution range of the first convolution kernel 1001 and the second convolution kernel 1002 in the image is obtained by performing difference processing on the first convolution kernel 1001 and the second convolution kernel to obtain a difference convolution kernel 1003. Then, the difference convolution kernel 1003 is used to perform the convolution on the frequency domain image (such as Figure 9 The frequency domain image 900 in the image is convolved to obtain a filtered frequency domain image (such as Figure 11 The frequency domain image 1100 shown in FIG. 1 ). The filtered frequency domain image 1100 can be obtained by performing Fourier integral on the frequency domain and convolving the Gaussian kernel H=G*F. , H is the frequency domain function after Fourier integral and Gaussian kernel convolution.
[0060] Therefore, in the process of image enhancement processing of the second feature image, a Gaussian filter with two convolution kernels is used to filter the frequency domain image corresponding to the second feature image. The frequencies in a specific channel can be filtered to reduce fixed noise, making some low-contrast defect areas in the image more prominent, ensuring that these low-contrast defect areas can be effectively detected in subsequent processes, and further improving the defect detection accuracy.
[0061] After obtaining the filtered frequency domain image, the filtered frequency domain image can be subjected to inverse Fourier transform processing to obtain a spatial domain image (e.g. Figure 8 802 in the spatial domain). For example, the formula After integration, the spatial domain image can be obtained. It is the frequency domain function after the aforementioned Fourier integral is convolved with the Gaussian kernel.
[0062] After obtaining the spatial domain image, return Figure 3 In step S309 , defect information of the lens may be determined based on the spatial domain image.
[0063] In some embodiments, a local adaptive threshold method can be used to extract the lens defect region from the spatial domain image. Then, inverse polar coordinate transformation processing is performed on the extracted lens defect region to obtain a transformed image. Next, the defect information of the lens is determined based on the transformed image.
[0064] As an example, in Figure 12 , after obtaining the spatial domain image 1201, the local adaptive threshold method can be used to extract the lens defect region and perform inverse polar coordinate transformation processing on the extracted lens defect region to obtain a circular lens image 1202 of normal size, and the defect position coordinates are output. As Figure 12 shown, the white rectangular wireframe in the circular lens image 1202 indicates the lens defect position.
[0065] Among them, the local adaptive threshold method includes: performing a mean filtering operation on the spatial threshold 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 the subtraction constant C (the gray value of the pixel (x, y) in the spatial threshold image), and comparing the size of this difference with the adaptive threshold T(x, y). If A - C < T, it means that this pixel point is brighter than the surrounding pixels, otherwise it means that this pixel point is darker than the surrounding pixels. If it is necessary to extract the brighter pixels as the pixel points of the lens defect region, then all pixel points with A - C < T can be extracted. Compared with other defect extraction methods, the local adaptive threshold method can more accurately extract the defect position points in the spatial threshold image. [[ID=1st]]
[0066] In addition, the inverse polar coordinate transformation processing performed on the extracted lens defect region can be realized by converting the image in the rectangular coordinate system back to the polar coordinate system and then converting the polar coordinate back to the rectangular coordinate.
[0067] Thus, by converting the first characteristic image of a lens (e.g., the end lens of a lens in a camera module, the end lens of a lens, or a bare lens) in the camera coordinate system into a second characteristic image through polar coordinate conversion, the interference of background noise in the second characteristic image can be effectively avoided. At the same time, the second characteristic image is further processed using image enhancement processing technology to enhance the contrast of the lens defect area in the image, allowing the lens defect information to be effectively extracted later. The entire defect detection process can efficiently and accurately achieve automated detection of camera module / lens / lens defects without introducing excessive human intervention, ensuring the quality of the camera module / lens / lens. In addition, using a Gaussian filter with two convolution kernels to filter the frequency domain image corresponding to the second characteristic image 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, further improving defect detection accuracy. In addition, it can not only greatly improve production efficiency, reduce missed defects and enhance the degree of production automation, but is also an important measure to promote the transformation and upgrading of traditional manufacturing industries. It is of great significance to technological progress, improving the quality of the labor force, improving enterprise production efficiency, promoting industrial structure adjustment, and promoting industrial transformation and development mode.
[0068] Figure 13 Schematically shows a schematic block diagram of an electronic device 1300 according to an embodiment of the present disclosure. Figure 13 As shown, 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 executes the following steps: acquiring a first feature image of the lens in a camera coordinate system; performing polar coordinate conversion processing 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.
[0069] Optionally, obtaining a first characteristic image of the 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 based on the boundary information of the lens, extracting the first characteristic image from the original grayscale image.
[0070] Optionally, performing boundary fitting processing on the original grayscale image includes: performing filtering and / or edge smoothing processing on the original grayscale image; and performing boundary fitting processing on the filtered and / or edge smoothed original grayscale image.
[0071] Optionally, performing polar coordinate conversion processing 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, performing image enhancement processing on 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 convolution kernel of a preset filter to complete filtering the frequency domain image.
[0074] Optionally, 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 difference processing on the image convolved with the first convolution kernel and the image convolved with the second convolution kernel; or performing difference 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, and determining the defect information of the lens based on the image after image enhancement processing includes: extracting the lens defect area from the spatial domain image using a local adaptive threshold method; performing inverse polar coordinate transformation on the extracted lens defect area to obtain a converted image; and determining the defect information of the lens based on the converted image.
[0076] Through the above-described embodiment, the electronic device can obtain a second characteristic image by performing polar coordinate conversion processing on the first characteristic image of the lens in the camera coordinate system, effectively avoiding interference from background noise in the second characteristic image. Furthermore, the second characteristic image is further processed using image enhancement processing technology to enhance the contrast of the lens defect area in the image, thereby enabling the subsequent effective extraction of lens defect information. The entire defect detection process can efficiently and accurately achieve automated detection of camera module / lens / lens defects without requiring excessive human intervention, thereby ensuring lens quality and improving the production efficiency of camera modules / lenses / lenses.
[0077] It should be noted that the specific contents of the method steps for operating the electronic device are combined with the above Figures 2 to 12 The specific implementation methods of the described related methods are the same or similar, so they will not be repeated here.
[0078] In addition, the present disclosure also provides a computer-readable storage medium in which program instructions are stored, and the program instructions are configured to be executed at runtime. Figure 2 and Figure 3 The method for detecting lens defects is shown.
[0079] Specifically, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0080] Although multiple embodiments of the present 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. Those skilled in the art can conceive of many changes, modifications, and alternatives without departing from the thought and spirit of the present application. It should be understood that in the process of practicing the present application, various alternatives to the embodiments of the present application described herein can be adopted. The accompanying claims are intended to define the scope of protection of the present 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: Obtaining a first characteristic image of the lens in a camera coordinate system; Performing polar coordinate conversion processing on the first feature image to obtain a second feature image; performing image enhancement processing on the second feature image; as well as Defect information of the lens is determined based on the image after image enhancement processing.
2. The method for detecting lens defects according to claim 1, wherein: Obtaining the first characteristic image of the lens in the camera coordinate system includes: Acquire 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 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, wherein: Performing boundary fitting processing on the original grayscale image includes: Performing filtering and / or edge smoothing on the original grayscale image; and Boundary fitting is performed on the filtered and / or edge-smoothed original grayscale image.
4. The method for detecting lens defects according to claim 1, wherein: Performing polar coordinate conversion processing 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 All pixel grayscale values in the polar coordinate system are mapped to coordinates in the rectangular coordinate system to obtain the second feature image.
5. The method for detecting lens defects according to any one of claims 1 to 4, characterized in that: Performing image enhancement processing on the second feature image includes: Performing Fourier transform processing on the second feature image to obtain a frequency domain image; performing filtering on the frequency domain image to obtain a filtered frequency domain image; and The filtered frequency domain image is subjected to inverse Fourier transform processing to obtain a spatial domain image.
6. The method for detecting lens defects according to claim 5, wherein: Performing filtering on the frequency domain image includes: The frequency domain image is convolved based on a convolution kernel of a preset filter to complete filtering processing on the frequency domain image.
7. The method for detecting lens defects according to claim 6, wherein: 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 difference processing on the image convolved by the first convolution kernel and the image convolved by the second convolution kernel; or Performing difference 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.
8. The method for detecting lens defects according to claim 5, wherein: The image after image enhancement processing includes the spatial domain image, and determining the defect information of the lens based on the image after image enhancement processing includes: extracting the lens defect area from the spatial domain image by adopting a local adaptive threshold method; Performing inverse polar coordinate transformation on the extracted lens defect area to obtain a transformed image; and Defect information of the lens is determined based on the converted image.
9. An electronic device, characterized in that: Also includes: processor; as well as A memory storing computer instructions for detecting lens defects, wherein when the computer instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that The invention comprises program instructions for detecting lens defects, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 8 is 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
Defect detection method and device and storage medium
CN117011250A
Appearance defect detection method for power battery busbar
CN117074424A
Pipeline defect detection method and device, electronic equipment and readable storage medium
CN117809018A