Optical module packaging material defect detection method

By using grayscale histograms to determine the segmentation threshold and optimizing the segmentation boundary in optical module detection, the problem of low accuracy in corrosion area recognition in complex backgrounds in traditional methods is solved, and higher detection accuracy is achieved.

CN120355706AActive Publication Date: 2025-07-22SHAANXI ALLWAVE LASER TECH INC
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510837375.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-07-22
Estimated Expiration
2045-06-23

AI Technical Summary

Technical Problem

When traditional optical module detection methods process images with noise or complex backgrounds, the defect area recognition accuracy is low, making it difficult to effectively identify the corrosion area on the surface of the optical module.

Method used

The image is segmented by determining two segmentation thresholds based on the grayscale histogram to form multiple segmentation areas. By analyzing the grayscale characteristics of each segmentation area, the segmentation threshold is optimized to obtain the optimal segmentation boundary, and the accuracy of image segmentation is improved.

Benefits of technology

It improves the identification and extraction accuracy of the surface corrosion areas of optical module packaging materials, can better deal with images with complex backgrounds and noise interference, and improves the accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120355706A_ABST
    Figure CN120355706A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to an optical module packaging material defect detection method. Segmenting the image based on the segmentation threshold to form a plurality of segmentation regions; for each segmented region, based on the gray features of the pixel points in each segmented region, calculating the regional rationality of the current segmented region, and taking the product of the regional rationality as the segmented interval rationality; in response to the condition that the reasonability of the segmentation interval is greater than a preset reasonable threshold value, taking the segmented image as a segmented image for defect detection; and in response to the condition that the reasonable degree of the segmentation interval is smaller than or equal to a preset reasonable threshold value, optimizing the segmentation threshold value, obtaining an optimal segmentation boundary, taking an image segmented based on the optimal segmentation boundary as a segmented image, and performing defect detection based on the segmented image. The method has the effect of improving the recognition and extraction accuracy of the corrosion area on the surface of the optical module packaging material.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and particularly to a method for detecting defects in optical module packaging materials. Background Art

[0002] An optical module is an optoelectronic conversion device integrating an optical transmitter and a receiver, usually existing in a standardized package form, and can be hot-pluggable in some communication devices. Its housing is usually made of alloy material. Such alloy materials may undergo electrochemical corrosion in humid heat, salt spray (coastal area environment), or acidic atmosphere. When rust occurs on the surface of the optical module, it may lead to problems such as shortened service life and degraded performance of the optical module. Therefore, in some scenarios, it is necessary to monitor the optical module, such as the factory inspection of the optical module or the real-time monitoring during the use of the optical module in a harsh environment. The traditional detection method mainly relies on manual visual inspection and judgment based on experience; this method is inefficient and inaccurate. With the development of electronic information technology, currently, the surface of the optical module is mainly monitored based on image processing technology. Its main steps are: collecting an image of the surface of the optical module through a high-resolution camera, performing segmentation processing on the image through an image segmentation algorithm, obtaining the rust area in the image, and realizing the detection of surface defects of the optical module.

[0003] The threshold segmentation method is one of the simplest and most commonly used methods in image segmentation. It mainly divides the pixels in the image into two or more regions based on the gray value information or color information of the pixels, so as to screen the rust area. For example, in the bimodal threshold method, it first counts the number of pixels corresponding to the pixel values in the image, performs a gray histogram analysis on the image, finds the peaks of the number of pixels in the histogram, and determines the segmentation threshold based on the peaks to realize the segmentation of the image. Although the bimodal threshold method has low computational complexity and high computational efficiency, it depends on an image with an obvious bimodal distribution in the gray histogram. During the process of processing an image with a complex background or more noise interference, the accuracy of defect recognition is relatively low. Summary of the Invention

[0004] In order to improve the problem of low accuracy in defect area recognition in the process of the traditional optical module detection method for processing images with noise or complex background, this application provides a method for detecting defects in optical module packaging materials.

[0005] This application provides a method for detecting defects in optical module packaging materials, adopting the following technical solutions: A method for detecting defects in optical module packaging materials, comprising the steps of: obtaining a grayscale histogram of the surface image of the optical module packaging materials, and determining the positions of two peak points in the grayscale histogram; determining two segmentation thresholds based on the positions of the two peak points, and segmenting the image based on the segmentation thresholds to form a plurality of segmented regions; for each segmented region, calculating the regional rationality of the current segmented region based on the grayscale features of the pixel points in the segmented region, and taking the product of the regional rationalities as the segmentation interval rationality; in response to the segmentation interval rationality being greater than a preset rationality threshold, using the segmented image as the segmented image for defect detection; in response to the segmentation interval rationality being less than or equal to the preset rationality threshold, optimizing the segmentation thresholds, obtaining the optimal segmentation boundary, using the image segmented based on the optimal segmentation boundary as the segmented image, and performing defect detection based on the segmented image.

[0006] Based on the surface grayscale histogram of the optical module packaging materials, two segmentation thresholds are determined. Under the action of the two segmentation thresholds, the value range of the image can be divided into three parts, where the region between the two peak points is one part, and there is one part on each side of the interval formed by the two peak points. Furthermore, a more detailed division of the image is achieved, facilitating the identification of various types of regions in the image. It breaks through the defect that only two regions can be divided in the traditional bimodal threshold method, making it easier to handle images with a more complex background (for example, there are some shadow regions in the image). At the same time, after the image segmentation, for each segmented region, the grayscale features in the segmented region are analyzed to determine whether the pixel points in the segmented region should be divided into this region. Based on the finally calculated segmentation interval rationality, it is determined whether the two segmentation thresholds need to be adjusted. The segmentation interval rationality represents the accuracy of the image segmentation. When the image segmentation is inaccurate, the segmentation thresholds are optimized, thereby improving the accuracy of the image segmentation, and further improving the accuracy of the corrosion region recognition and extraction.

[0007] Optionally, the step of determining two segmentation thresholds based on the positions of the two peak points includes: the two segmentation thresholds are respectively the left segmentation threshold and the right segmentation threshold; the two peak points include the first peak point and the second peak point, and the grayscale value corresponding to the first peak point is less than the grayscale value corresponding to the second peak point; taking the grayscale value of the lowest valley point between the first peak point and the second peak point as the left segmentation threshold; obtaining the first derivative of the grayscale histogram, and taking the grayscale value at the position corresponding to the minimum value of the first derivative in the region of the grayscale histogram where the grayscale value is greater than the second peak point as the right segmentation threshold.

[0008] In the image, there is a large gray-scale difference between the corroded area and the background area, and the gray-scale value change between the corroded area and the background area is not continuous. Assume that the gray-scale value of the corroded area is 1 - 50, and most of the pixel points in the corroded area are concentrated around the gray-scale value of 25, while the gray-scale value of the background area is concentrated around 150. Therefore, the lowest valley point between the two peak points is selected as the left segmentation threshold, and this method can accurately extract the obvious corroded area in the image. The gray-scale value corresponding to the position where the gray-scale value changes slowly on the right side of the second peak point is used as the right segmentation threshold, and the right segmentation threshold is mainly used to distinguish the background area and the shadow area.

[0009] Optionally, the steps of calculating the regional rationality of the current segmentation area based on the gray-scale characteristics of the pixel points in each segmentation area include: performing region growing based on the pixel points in the segmentation area to obtain multiple suspected areas, calculating the local rationality of the suspected areas, and taking the average value of the multiple local rationalities as the regional rationality corresponding to the segmentation area; among them, the segmentation area includes: the corroded area, the shadow area, and the background area.

[0010] Perform secondary segmentation on each segmentation area to form multiple suspected areas, and then reflect the overall regional rationality of the segmentation area by analyzing the gray-scale characteristics of the pixel points in the suspected areas, improving the efficiency of calculating the regional rationality and reducing the calculation amount.

[0011] Optionally, the corroded area is the area in the image where the gray-scale value is less than the left segmentation threshold, the shadow area is the area in the image where the gray-scale value is between the left segmentation threshold and the right segmentation threshold; the background area is the area in the image where the gray-scale value is greater than the right segmentation threshold.

[0012] In the actual production process, after the material surface is corroded, the gray-scale value of the corresponding position in the image will become smaller. Therefore, the segmentation area with a smaller gray-scale value corresponds to the corroded area. Similarly, based on the gray-scale characteristics of the shadow part and the background part in the image, they are determined as the background area or the shadow area.

[0013] Optionally, the steps of calculating the local rationality of the suspected area corresponding to the pixel points in the corroded area include: for any suspected area, obtaining the gray-scale fluctuation degree and the gray-scale level of the suspected area based on the gray-scale values of the pixel points in the suspected area; obtaining the gradient level of the suspected area based on the gradients of the pixel points in the suspected area; calculating the local rationality of the suspected area based on the gray-scale fluctuation degree, the gray-scale level, and the gradient level. The gray-scale fluctuation degree and the gradient level are positively correlated with the local rationality, and the gray-scale level is negatively correlated with the local rationality.

[0014] The pixel points in the corrosion area in the image should have the following characteristics: small gray values, uneven gray levels of each pixel point in the suspected area, and obvious boundaries. Based on the above characteristics, analyzing the gray level, gradient level of the pixel points in the suspected area, and the gray fluctuation degree of the pixel points in the suspected area can reflect the local rationality of dividing the suspected area into the corrosion area, which can also be understood as the possibility of corrosion occurring in the suspected area.

[0015] Optionally, the standard deviation of the gray levels of the pixel points in the suspected area is used as the gray fluctuation degree of the suspected area.

[0016] Optionally, the calculation steps of the local rationality of the suspected area corresponding to the pixel points in the shadow area include: obtaining the change continuity of the gray level change in the suspected area; calculating the gray level of the image and the gray level in the shadow area, obtaining the gray middle value of the image and the gray difference of the gray level in the influence area; calculating the local rationality of the shadow area based on the gray difference and the change continuity, where the gray difference and the change continuity are negatively correlated with the local rationality of the shadow area.

[0017] In the image, the pixel points in the shadow area should show continuous gray level changes of adjacent pixel points, and the gray level is between the left segmentation threshold and the right segmentation threshold. Therefore, in this method, the local rationality is reflected based on the change continuity of the gray level change of the pixel points in the suspected area and the gray difference between the gray level in the suspected area and the gray middle value in the whole image.

[0018] Optionally, the calculation steps of the local rationality of the suspected area corresponding to the pixel points in the background area include: obtaining the gray level of the suspected area and the gray fluctuation degree of the pixel points in the suspected area; calculating the local rationality of the suspected area corresponding to the background area based on the gray level and the gray fluctuation degree, where the gray level is directly proportional to the local rationality, and the gray fluctuation degree is inversely proportional to the local rationality.

[0019] Optionally, the steps of optimizing the segmentation threshold and obtaining the optimal segmentation boundary include: a shadow gray interval is formed between the two segmentation thresholds; the boundaries of the shadow gray interval are slid within a preset range to construct an adjustment interval, and the interval weight corresponding to the adjustment interval is calculated; the regional rationality of the segmentation area corresponding to the adjustment interval is obtained, and the product of the regional rationality and the corresponding interval weight is used as the recognition degree of the adjustment interval; the shadow gray interval with the largest recognition degree is used as the optimal interval, and the boundary values of the optimal interval are used as the optimal segmentation boundary.

[0020] In the process of optimizing the segmentation threshold, mainly by changing the segmentation threshold within a certain range, constructing an adjustment interval, and then selecting the optimal interval based on the segmentation interval rationality corresponding to the adjustment interval and the corresponding interval weight, and re-segmenting the image.

[0021] Optionally, the step of calculating the interval weight corresponding to the adjustment interval includes: obtaining the area ratio of the shadow area in the image; using the absolute difference between the normalized result of the interval length of the adjustment area and the area ratio as the interval weight.

[0022] The present application has the following technical effects: In this method, two segmentation thresholds are determined based on the grayscale histogram, enabling more detailed segmentation of the image. Then, by calculating the local rationality of the suspected areas corresponding to the pixel points in each segmented area, the accuracy of the current image segmentation is judged. When the image segmentation is inaccurate, the segmentation thresholds are adjusted to obtain a more accurate segmented area, improving the accuracy of the final recognition and extraction of the corrosion area. Description of the Drawings

[0023] Figure 1 It is a flowchart of a method for detecting defects in an optical module packaging material according to an embodiment of the present application. Detailed Embodiments

[0024] The embodiment of the present application discloses a method for detecting defects in an optical module packaging material. Based on the grayscale histogram of the surface image of the packaging material, the positions of two peak points in the grayscale histogram are determined, and two segmentation thresholds are determined based on the positions of the two peak points. Based on the two segmentation thresholds, the image can be divided into multiple segmented areas. Different segmented areas correspond to pixels with different grayscales. Then, the regional rationality of each segmented area is analyzed. If the regional rationality is too small, it indicates that the regional division is unreasonable, and the segmentation thresholds should be optimized to obtain the optimal segmentation boundary, and the image is segmented based on the optimal segmentation boundary. The area corresponding to the corrosion position in the segmented image is extracted to complete the recognition and extraction of the corrosion area. Compared with the traditional bimodal threshold method, on the one hand, more areas can be divided, thus enabling more detailed segmentation of the pixels in the image. On the other hand, based on the regional rationality of the regional division, it is judged whether the current image segmentation is reasonable and whether the corrosion area can be effectively distinguished. When the regional rationality is less than the preset rational threshold, the segmentation thresholds are optimized and dynamically adjusted to better cope with different types of background areas and improve the accuracy of recognizing the corrosion area.

[0025] Referring to Figure 1 , a method for detecting defects in an optical module packaging material includes steps S1 - S5.

[0026] S1: Obtain the grayscale histogram of the surface image of the optical module packaging material, and determine the positions of two peak points in the grayscale histogram; determine two segmentation thresholds based on the positions of the two peak points, and segment the image based on the segmentation thresholds to form multiple segmented areas.

[0027] Collect the surface image of the optical module packaging material through an industrial camera, perform grayscale processing on the surface image to obtain the surface grayscale image. Obtain the grayscale histogram of the surface grayscale image.

[0028] Three typical regions will be formed on the surface after metal corrosion: the corrosion region, the shadow region (referring to the transition region with a relatively smooth grayscale change between the corrosion region and the background region), and the background region. The corrosion region has a rough surface and strong light scattering due to material loss or thickening of the oxide layer. It appears as the lowest grayscale interval (close to black) in X-ray or visible light imaging, and has large grayscale fluctuations due to uneven structure. The shadow region forms a gradual shadow due to partial scattering or absorption of light, and its grayscale value is between the corrosion region and the background region, and shows a gradual change feature. The normal background region has a flat surface and high reflectivity, with a high and relatively uniform grayscale after imaging.

[0029] The steps to obtain the grayscale histogram are conventional technical means in this field and will not be elaborated here. The abscissa in the grayscale histogram represents the grayscale value, while the ordinate represents the number of pixel points corresponding to the grayscale value in the image.

[0030] S2: Determine two segmentation thresholds based on the positions of the two peak points, and segment the image based on the segmentation thresholds to form multiple segmented regions.

[0031] Identify the positions of the two peak points in the grayscale histogram, and determine two segmentation thresholds based on the positions of the two peak points. For the convenience of description, the two segmentation thresholds are respectively defined as the left segmentation threshold and the right segmentation threshold, where the grayscale value corresponding to the left segmentation threshold is less than the grayscale value corresponding to the right segmentation threshold.

[0032] Find the lowest valley point in the region between the two peak points in the grayscale histogram, and use the grayscale value corresponding to the lowest valley point as the left segmentation threshold. Based on the grayscale histogram, obtain the first derivative of the grayscale histogram. For the data on the right side of the second peak point (which can also be understood as the region in the grayscale histogram where the grayscale value is greater than the second peak point), obtain the position of the minimum value of the first derivative in this part of the data, and use the grayscale value corresponding to this position as the right segmentation threshold.

[0033] The first derivative of the grayscale histogram represents the degree of change in the number of corresponding pixel points with the change of grayscale in the image, and the position of the minimum value of the first derivative represents the position where the change in the number of pixel points is the smallest. It conforms to the grayscale value characteristics of the corrosion region, the shadow region, and the background region in step S1, and completes the initial segmentation of the image.

[0034] S3: For each segmented region, calculate the regional rationality of the current segmented region based on the grayscale characteristics of the pixel points in the segmented region, and take the product of the regional rationalities of each region as the segmentation interval rationality.

[0035] Region growing is performed based on the pixel points in the segmented region to obtain multiple suspected regions. The local rationality of the suspected regions is calculated, and the average value of the multiple local rationalities is used as the regional rationality corresponding to the segmented region. Analyze the local rationality of the pixel points in the suspected regions, and then analyze the local regional rationality of the entire segmented region.

[0036] For each segmented region, extract the pixel points in the segmented region. Using the pixel points in the segmented region as seed points, perform region growing on the seed points using the region growing method to form multiple suspected regions, realizing the re-segmentation of the segmented region. After segmentation, the local rationality of the suspected regions can be calculated based on the gray levels of the pixel points within the suspected regions, and the overall regional rationality of the segmented region is reflected through the results of multiple local rationalities.

[0037] After image segmentation, three segmented regions are formed, and the gray level features in each segmented region are different. Based on the gray level features of the pixel points in each segmented region, the three segmented regions can be named respectively: the corrosion region, the shadow region, and the background region, where the corrosion region is the region in the image where the gray level value is less than the left segmentation threshold, the shadow region is the region in the image where the gray level value is between the left segmentation threshold and the right segmentation threshold; the background region is the region in the image where the gray level value is greater than the right segmentation threshold.

[0038] Since the gray level features of the pixel points in different regions are different, the possibility of whether the pixel points in the segmented region belong to the region should be verified separately.

[0039] Among them, for the suspected regions corresponding to the pixel points in the corrosion region, obtain the gray level fluctuation degree and the gray level of the suspected region based on the gray level values of the pixel points within the suspected region; obtain the gradient level of the suspected region based on the gradients of the pixel points within the suspected region; calculate the local rationality of the suspected region based on the gray level fluctuation degree, the gray level, and the gradient level. The gray level fluctuation degree and the gradient level are positively correlated with the local rationality, and the gray level is negatively correlated with the local rationality.

[0040] In this embodiment, the average value of the gray levels of all pixel points in the suspected region is used as the gray level, and the average value of the gradients of all pixel points in the suspected region is used as the gradient level; the standard deviation of the gray levels of all pixel points in the suspected region is used as the gray level fluctuation degree.

[0041] Specifically, the calculation formula for the local rationality of the suspected regions corresponding to the pixel points in the corrosion region can be expressed as: ; In the formula, represents the local rationality of the pixel points in the suspected region; represents the gray level fluctuation degree of the pixel points in the suspected region; represents the gradient level of the pixel points in the suspected region; represents the gray level of the pixel points in the suspected region.

[0042] For the gray-scale features of the pixel points in the corrosion area, they are mainly manifested as low gray-scale values, uneven gray-scale, and relatively obvious boundaries. Therefore, for a suspected area, the greater the gray-scale fluctuation degree, the greater the possibility that the pixel points in the suspected area are in the corrosion area. If the gradient of the pixel points in a suspected area is greater, it indicates that the boundaries of the pixel points are more obvious. Furthermore, the local rationality of the suspected area is greater, and thus the segmentation of the segmented area is more accurate and the area rationality is greater.

[0043] Similarly, if the gray-scale level in the suspected area corresponding to a pixel point is relatively large, it indicates that the overall gray-scale in the suspected area is relatively large; at the same time, if the gradient level and the gray-scale fluctuation degree are relatively small, then it indicates that the suspected area may not be a real corrosion area, and further indicates that the segmentation of the image by the two thresholds is not accurate, so the area rationality is smaller.

[0044] For the suspected area corresponding to the pixel points in the shadow area, obtain the change continuity of the gray-scale change in the suspected area; calculate the gray-scale level of the image and the gray-scale level in the shadow area, and obtain the gray-scale difference between the gray-scale level of the image and the gray-scale level in the affected area; calculate the local rationality of the shadow area based on the gray-scale difference and the change continuity, where the gray-scale difference and the change continuity are negatively correlated with the local rationality of the shadow area.

[0045] For the shadow area, its overall gray-scale is between the corrosion area and the background area, which can also be understood as that the overall gray-scale of the shadow area should be close to the average level of all pixel points in the image. At the same time, the pixel points in the shadow area also show a gradual change feature, that is, the change continuity of the gray-scale of adjacent pixel points is relatively strong. Based on the above characteristics, the local rationality of the suspected area can be calculated.

[0046] For the change continuity of the gray-scale change of the pixels in the suspected area, in this embodiment, first obtain the circumscribed circle of the suspected area, and quantify the change continuity of the gray-scale of the pixel points in the suspected area by fitting a gradual change linear model to the change of the gray-scale in the direction from the center of the circumscribed circle to the edge.

[0047] The gradual change linear model can be expressed as: ; where represents the gray-scale value of the pixel point, represents the slope of the gray-scale value change in the vertical direction from the center of the circle; represents the slope of the gray-scale value change in the vertical direction from the center of the circle; represents the reference gray-scale value, that is, the constant term in the fitting process of the gradual change linear model. Obtain the corresponding fitting error based on the gradual change linear model, and take the reciprocal of the fitting error as the change continuity of the suspected area. The extraction of the fitting error is a conventional technical means in the art and will not be elaborated here.

[0048] Specifically, the calculation formula for the local rationality of the suspected area corresponding to the pixel points in the shadow area can be expressed as: ; In the formula, represents the local rationality of the suspected area corresponding to the pixel points in the shadow area; represents the fitting error of the gradient linear model, represents the average gray value in the suspected area, represents the median gray value of all pixel points in the image.

[0049] In the formula represents the change continuity. The greater the change continuity, the worse the continuity of the gray value change in the suspected area, and further indicates that the suspected area may not belong to the shadow area.

[0050] represents the gray difference between the overall gray value of the pixel segment in the suspected area and the median gray value of the entire image. Based on the gray feature of the pixel points in the shadow area, the overall gray value in the suspected area should be close to the median gray value of the entire image. Therefore, the greater the gray difference, the more likely the suspected area belongs to the shadow area, and further the greater the local rationality corresponding to the suspected area. is mainly used to prevent the denominator in the formula from being 0.

[0051] For the local rationality of the suspected area corresponding to the pixel points in the background area, obtain the gray level of the suspected area and the gray fluctuation degree of the pixel points in the suspected area; calculate the local rationality of the suspected area corresponding to the background area based on the gray level and the gray fluctuation degree. The gray level is directly proportional to the local rationality, and the gray fluctuation degree is inversely proportional to the local rationality.

[0052] For the gray feature of the pixel points in the background area, it is mainly characterized by a large gray value and a uniform gray distribution. Therefore, this method judges the local rationality corresponding to the suspected area through the gray fluctuation degree and the gray level in the suspected area.

[0053] Specifically, the calculation formula for the local rationality of the suspected area corresponding to the pixel points in the background area can be expressed as: ; In the formula, represents the local rationality of the suspected area corresponding to the pixel points in the background area; represents the gray fluctuation degree of the suspected area corresponding to the pixel points in the background area; represents the gray level of the suspected area corresponding to the pixel points in the background area.

[0054] Multiply the regional rationalities corresponding to multiple segmented areas to obtain the final segmentation interval rationality for the entire image segmentation.

[0055] S4: In response to the rationality of the segmentation interval being greater than a preset rationality threshold, use the segmented image as the segmented image for defect detection.

[0056] In this embodiment, the rationality threshold is set to 0.8. When the rationality of the segmentation intervals of the multiple segmented regions obtained by the first segmentation is greater than 0.8, it indicates that the image segmentation is relatively accurate, and the corrosion regions in the image can be accurately identified. Furthermore, the corrosion regions in the image can be directly extracted to complete the anomaly detection.

[0057] S5: In response to the rationality of the segmentation interval being less than or equal to the preset rationality threshold, optimize the segmentation threshold, obtain the optimal segmentation boundary, use the image segmented based on the optimal segmentation boundary as the segmented image, and perform defect detection based on the segmented image.

[0058] If the finally calculated rationality of the segmentation interval is small, it indicates that the division of the segmented regions is inaccurate, and there may be abnormal situations such as corrosion regions being misclassified into shadow regions or shadow regions being misclassified into corrosion regions. Therefore, it is necessary to optimize and adjust the segmentation threshold.

[0059] Specifically, a shadow gray level interval is formed between two segmentation thresholds; slide the boundaries of the shadow gray level interval within a preset range to construct an adjustment interval, and calculate the interval weight corresponding to the adjustment interval; obtain the regional rationality of the segmented region corresponding to the adjustment interval, and use the product of the regional rationality and the corresponding interval weight as the recognition degree of this adjustment interval; use the shadow gray level interval with the maximum recognition degree as the optimal interval, and use the boundary values of the optimal interval as the optimal segmentation boundary.

[0060] Set a sliding range near the left segmentation threshold and the right segmentation threshold. During the process of sliding and adjusting the values of the left segmentation threshold and the right segmentation threshold, a new adjustment interval is formed. For example, in this embodiment, the sliding range is set to 10 values near the segmentation threshold. Assuming the left segmentation threshold is 50, then the sliding range corresponding to the left segmentation threshold is 40 - 60. Obtain all possible regions of the left segmentation threshold and all possible values of the right segmentation threshold, and arbitrarily combine them to form multiple adjustment intervals.

[0061] Obtain the interval weight corresponding to the adjustment interval.

[0062] Extract the gray level data of all pixel points in the entire image, and use the K-means clustering method to cluster the pixel points based on the magnitude of the gray level values. The number of clustering clusters is set to 3, and finally three clustering clusters are obtained. The overall gray levels of the pixel points in the three clustering clusters are different. Therefore, the three clustering clusters can be divided into: a low gray level clustering cluster, a medium gray level clustering cluster, and a high gray level clustering cluster, where the medium gray level clustering cluster corresponds to the pixel points in the shadow region of the image. Obtain the ratio of the number of pixel points in the medium gray level clustering cluster to the number of all pixel points in the image as the area ratio of the shadow region in the image.

[0063] Since the pixel points in the medium gray clustering cluster correspond to the area of the shadow region, and the region between the two segmentation thresholds corresponds to the shadow area, in actual situations, the length of the adjustment interval formed between the two segmentation thresholds should be close to the area ratio. Furthermore, if the difference between the normalized result of the adjustment interval length and the area ratio is smaller, it indicates that the segmentation of the image is more accurate. Therefore, the reciprocal of the absolute difference between the normalized result of the interval length and the area ratio is used as the interval weight.

[0064] The product of the interval weight and the rationality of the segmentation interval corresponding to the adjustment interval is used as the recognition degree of this adjustment interval.

[0065] Specifically, the calculation formula for the recognition degree of the adjustment region can be expressed as: ; In the formula, represents the recognition degree of the adjustment interval ; represents the rationality of the segmentation interval corresponding to the adjustment interval ; represents the number of pixel points in the medium gray clustering cluster; represents the number of all pixel points in the image; is a linear normalization function.

[0066] The adjustment interval with the highest recognition degree among all adjustment intervals is used as the optimal interval, and the two boundary values corresponding to the optimal interval are used as the optimal segmentation boundaries.

[0067] The image segmented based on the optimal segmentation boundaries is used as the segmented image, and defect detection is performed based on the segmented image.

[0068] In the image segmented based on the optimal segmentation boundaries, the eroded area represents the part of the material surface that has corroded. At the same time, in the shadow region, since the gray value is less than that of the background region, there may be some slightly corroded parts mixed in the background region. Therefore, here Blob detection is used to extract the slightly corroded parts in the shadow region and divide them into the eroded area, and then the eroded area is extracted to realize the recognition and extraction of the eroded area in the image, and the anomaly detection is completed.

[0069] Here, the slightly corroded parts in the shadow region are extracted again to further improve the accuracy of the finally obtained eroded area.

[0070] The embodiment of the present application also discloses an optical module packaging material defect detection system, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, an optical module packaging material defect detection method according to the present application is implemented.

[0071] The above system further includes other components well-known to those skilled in the art, such as a communication bus and a communication interface. Their settings and functions are known in the art, so they will not be elaborated here.

[0072] The above are all preferred embodiments of the present application. It is not intended to limit the protection scope of the present application hereby. Therefore, all equivalent changes made according to the structure, shape, and principle of the present application shall be covered within the protection scope of the present application.

Claims

1. A method for detecting defects in optical module packaging materials, characterized in that, It includes the steps of: obtaining the gray histogram of the surface image of the optical module packaging material, and determining the positions of two peak points in the gray histogram; determining two segmentation thresholds based on the positions of the two peak points, and segmenting the image based on the segmentation thresholds to form multiple segmented regions; for each segmented region, calculating the regional rationality of the current segmented region based on the gray features of the pixel points in the segmented region, and taking the product of the regional rationalities as the rationality of the segmentation interval; in response to the rationality of the segmentation interval being greater than a preset rationality threshold, using the segmented image as the segmented image for defect detection; in response to the rationality of the segmentation interval being less than or equal to the preset rationality threshold, optimizing the segmentation threshold, obtaining the optimal segmentation boundary, using the image segmented based on the optimal segmentation boundary as the segmented image, and performing defect detection based on the segmented image.

2. The method for detecting defects of an optical module packaging material according to claim 1, characterized in that The step of determining two segmentation thresholds based on the positions of the two peak points includes: the two segmentation thresholds are respectively the left segmentation threshold and the right segmentation threshold; the two peak points include the first peak point and the second peak point, and the gray value corresponding to the first peak point is less than the gray value corresponding to the second peak point; taking the gray value of the lowest valley point between the first peak point and the second peak point as the left segmentation threshold; obtaining the first derivative of the gray histogram, and taking the gray value at the position corresponding to the minimum value of the first derivative in the region where the gray value in the histogram is greater than the second peak point as the right segmentation threshold.

3. A method for detecting defects in an optical module encapsulation material according to claim 1, characterized in that, The step of calculating the regional rationality of the current segmented region based on the gray features of the pixel points in each segmented region includes: performing region growing based on the pixel points in the segmented region to obtain multiple suspected regions, calculating the local rationality of the suspected regions, and taking the average value of the multiple local rationalities as the regional rationality corresponding to the segmented region; wherein, the segmented region includes: the corrosion region, the shadow region, and the background region.

4. The method for detecting defects of an optical module packaging material according to claim 3, characterized in that, The corrosion region is the region in the image where the gray value is less than the left segmentation threshold, and the shadow region is the region in the image where the gray value is between the left segmentation threshold and the right segmentation threshold; the background region is the region in the image where the gray value is greater than the right segmentation threshold.

5. The method for detecting defects of an optical module packaging material according to claim 3, wherein, The calculation step of the local rationality of the suspected region corresponding to the pixel points in the corrosion region includes: for any suspected region, obtaining the gray fluctuation degree and the gray level of the suspected region based on the gray values of the pixel points in the suspected region; obtaining the gradient level of the suspected region based on the gradients of the pixel points in the suspected region; calculating the local rationality of the suspected region based on the gray fluctuation degree, the gray level, and the gradient level, where the gray fluctuation degree and the gradient level are positively correlated with the local rationality, and the gray level is negatively correlated with the local rationality.

6. The method for detecting defects of an optical module packaging material according to claim 5, wherein Taking the standard deviation of the gray values of the pixel points in the suspected region as the gray fluctuation degree of the suspected region.

7. The method for detecting defects of an optical module packaging material according to claim 3, wherein, The calculation step of the local rationality of the suspected region corresponding to the pixel points in the shadow region includes: obtaining the change continuity of the gray change in the suspected region; calculating the gray level of the image and the gray level in the shadow region, and obtaining the gray difference between the gray level of the image and the gray level in the affected region; calculating the local rationality of the shadow region based on the gray difference and the change continuity, where the gray difference and the change continuity are negatively correlated with the local rationality of the shadow region.

8. The method for detecting defects of an optical module packaging material according to claim 3, wherein, The calculation steps for the local rationality of the suspected region corresponding to the pixel points in the background region include: obtaining the gray level of the suspected region and the gray level fluctuation degree of the pixel points in the suspected region; calculating the local rationality of the suspected region corresponding to the background region based on the gray level and the gray level fluctuation degree, where the gray level is directly proportional to the local rationality and the gray level fluctuation degree is inversely proportional to the local rationality.

9. The method for detecting defects of an optical module packaging material according to claim 1, wherein, The steps for optimizing the segmentation threshold and obtaining the optimal segmentation boundary include: a shadow gray level interval is formed between two segmentation thresholds; the boundaries of the shadow gray level interval are slid within a preset range to construct an adjustment interval and calculate the interval weight corresponding to the adjustment interval; obtaining the regional rationality of the segmentation region corresponding to the adjustment interval, and taking the product of the regional rationality and the corresponding interval weight as the recognition degree of this adjustment interval; taking the shadow gray level interval with the largest recognition degree as the optimal interval and taking the boundary value of the optimal interval as the optimal segmentation boundary.

10. The method for detecting defects in an optical module packaging material according to claim 9, characterized in that, The steps for calculating the interval weight corresponding to the adjustment interval include: obtaining the area ratio of the shadow region in the image; taking the absolute difference between the normalized result of the interval length of the adjustment region and the area ratio as the interval weight.

Citation Information

Patent Citations

  • Defect detection method for electronic component

    CN115018828A

  • LED semiconductor packaging dispensing defect detection method based on optical information

    CN116977340A

  • Cover film surface defect detection method based on machine vision

    CN119273684A

  • Method and system for image segmentation

    EP2645329A1

  • Image segmentation method

    KR1020160140232A