A method for detecting defects in optical module packaging materials

By determining the segmentation threshold based on the grayscale histogram in optical module detection and optimizing the segmentation boundary, the problem of low accuracy in defect area identification under complex background and noise interference in traditional methods is solved, and higher accuracy in corrosion area identification and extraction is achieved.

CN120355706BActive Publication Date: 2025-08-15SHAANXI ALLWAVE LASER TECH INC
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When traditional optical module detection methods process images with noisy or complex backgrounds, the defect area recognition accuracy is low.

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 accuracy of identification and extraction 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 CN120355706B_ABST
    Figure CN120355706B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and in particular to a method for detecting defects in optical module packaging materials. The method includes segmenting an image based on a segmentation threshold to form multiple segmented regions. For each segmented region, the rationality of the region divided by the current segmented region is calculated based on the grayscale characteristics of the pixels in each segmented region, and the product of the rationality of each region is used as the rationality of the segmented interval. In response to the rationality of the segmented interval being greater than a preset rational threshold, the segmented image is used as a segmented image for defect detection. In response to the rationality of the segmented interval being less than or equal to the preset rational threshold, the segmentation threshold is optimized to obtain an optimal segmentation boundary, and the image segmented based on the optimal segmentation boundary is used as a segmented image, and defect detection is performed based on the segmented image. The present application has the effect of improving the accuracy of identifying and extracting corrosion areas on the surface of optical module packaging materials.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method for detecting defects in packaging materials of optical modules. Background Art

[0002] An optical module is a photoelectric conversion device that integrates a light transmitter and receiver. It typically comes in a standardized package and is hot-swappable in certain communications equipment. Its housing is typically made of an alloy. These alloys can be susceptible to electrochemical corrosion in environments with humidity, heat, salt spray (in coastal areas), or acidic atmospheres. Rust on the optical module surface can shorten its lifespan and degrade its performance. Therefore, monitoring optical modules is necessary in some scenarios, such as factory inspection or real-time monitoring during use in harsh environments. Traditional inspection methods rely primarily on visual observation and empirical judgment, which is inefficient and inaccurate. With the advancement of electronic information technology, optical module surface monitoring currently relies primarily on image processing technology. The main steps are: capturing images of the optical module surface with a high-resolution camera, segmenting the images using image segmentation algorithms, identifying corroded areas in the images, and detecting surface defects.

[0003] Threshold segmentation is one of the simplest and most commonly used methods for image segmentation. It primarily divides pixels in an image into two or more regions based on their grayscale value or color information, thereby screening for rusted areas. For example, in the bimodal threshold method, the number of pixels corresponding to the pixel value in the image is first counted, a grayscale histogram analysis is performed on the image, and the peak value of the number of pixels in the histogram is found. The segmentation threshold is then determined based on the peak value to achieve image segmentation. Although the bimodal threshold method has low computational complexity and high computational efficiency, it relies on images with a clear bimodal distribution in the grayscale histogram. When processing images with complex backgrounds or high noise interference, the accuracy of defect recognition is low. Summary of the Invention

[0004] In order to improve the problem of low defect area recognition accuracy of traditional optical module detection methods when processing images with noise or complex backgrounds, the present application provides an optical module packaging material defect detection method.

[0005] This application provides a method for detecting defects in optical module packaging materials, which adopts the following technical solutions:

[0006] A method for detecting defects in optical module packaging materials comprises the following steps: obtaining a grayscale histogram of an image of a surface of an optical module packaging material, 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 region rationality of the current segmented region based on the grayscale features of the pixels in each segmented region, and taking the product of the rationalities of the regions as the segmentation interval rationality; in response to the segmentation interval rationality being greater than a preset rational threshold, using the segmented image as a segmented image for defect detection; in response to the segmentation interval rationality being less than or equal to the preset rational threshold, optimizing the segmentation threshold, obtaining an optimal segmentation boundary, using the image segmented based on the optimal segmentation boundary as a segmented image, and performing defect detection based on the segmented image.

[0007] Based on the surface grayscale histogram of the optical module packaging material, two segmentation thresholds are determined. These two thresholds divide the image's value range into three parts: the area between the two peaks, and two parts on either side of the interval formed by the two peaks. This achieves more detailed image segmentation, facilitating the identification of diverse image regions. This overcomes the limitation of traditional bimodal thresholding methods, which only allow for two-region segmentation, making it more suitable for images with complex backgrounds (e.g., those with shadows). After image segmentation, the grayscale features of each segmented region are analyzed to determine whether the pixels within the segmented region should be included in that region. Based on the calculated segmentation interval rationality, the two segmentation thresholds are used to determine whether adjustments are necessary. The segmentation interval rationality indicates the accuracy of image segmentation. If the image segmentation is inaccurate, the segmentation thresholds can be optimized to improve segmentation accuracy, thereby enhancing the accuracy of corrosion area identification and extraction.

[0008] Optionally, the step of determining two segmentation thresholds based on the positions of two peak points includes: the two segmentation thresholds are respectively a left segmentation threshold and a right segmentation threshold; the two peak points include a first peak point and a second peak point, and the grayscale value corresponding to the first peak point is smaller than the grayscale value corresponding to the second peak point; the grayscale value of the lowest valley point between the first peak point and the second peak point is used as the left segmentation threshold; the first-order derivative of the grayscale histogram is obtained, and the grayscale value of the position corresponding to the minimum value of the first-order derivative in the area of the histogram where the grayscale value is greater than the second peak point is used as the right segmentation threshold.

[0009] In the image, the grayscale difference between the eroded area and the background area is large, and the grayscale value changes in the eroded area and the background area are discontinuous. Assuming that the grayscale value of the eroded area is 1-50, most pixels in the eroded area are concentrated around grayscale value 25, while the grayscale value of the background area is concentrated around grayscale value 150. Therefore, the lowest valley point between the two peak points is selected as the left segmentation threshold. This method can accurately extract the more obvious eroded areas in the image. The grayscale value corresponding to the position with slow grayscale value change to the right of the second peak point is used as the right segmentation threshold. The right segmentation threshold is mainly used to distinguish between the background area and the shadow area.

[0010] Optionally, based on the grayscale features of the pixels in each segmented area, the step of calculating the regional rationality of the current segmented area includes: performing region growth based on the pixels in the segmented area to obtain multiple suspected areas, calculating the local rationality of the suspected areas, and taking the average of the multiple local rationalities as the regional rationality corresponding to the segmented area; wherein the segmented area includes: corrosion area, shadow area and background area.

[0011] Each segmented area is segmented again to form multiple suspected areas. Then, the grayscale characteristics of the pixels in the suspected areas are analyzed to reflect the overall regional rationality of the segmented area, thereby improving the efficiency of regional rationality calculation and reducing the amount of calculation.

[0012] Optionally, the eroded area is an area in the image whose grayscale value is less than the left segmentation threshold, the shadow area is an area in the image whose grayscale value is between the left segmentation threshold and the right segmentation threshold; and the background area is an area in the image whose grayscale value is greater than the right segmentation threshold.

[0013] In actual production, when a material surface corrodes, the grayscale value of the corresponding location in the image decreases. Therefore, the segmented area with a smaller grayscale value corresponds to the corroded area. Similarly, the shadow area and background area in the image are determined as background area or shadow area based on their grayscale characteristics.

[0014] Optionally, the steps for calculating the local rationality of the suspected area corresponding to the pixel points of the corrosion area include: for any suspected area, obtaining the grayscale fluctuation and grayscale level of the suspected area based on the grayscale values of the pixel points in the suspected area; obtaining the gradient level of the suspected area based on the gradient of the pixel points in the suspected area; calculating the local rationality of the suspected area based on the grayscale fluctuation, grayscale level and gradient level, the grayscale fluctuation and gradient level are positively correlated with the local rationality, and the grayscale level is negatively correlated with the local rationality.

[0015] Pixels in the corroded region of an image should exhibit the following characteristics: low grayscale values, uneven grayscale across pixels in the suspected region, and distinct boundaries. Based on these characteristics, the grayscale level, gradient level, and grayscale fluctuation of pixels in the suspected region are analyzed to determine the local plausibility of classifying the suspected region as a corroded region, which can also be understood as the likelihood of corrosion occurring in the suspected region.

[0016] Optionally, the standard deviation of the grayscale of the pixels in the suspected area is used as the grayscale fluctuation of the suspected area.

[0017] Optionally, the steps for calculating the local rationality of the suspected area corresponding to the center pixel point of the shadow area include: obtaining the change continuity of the grayscale change in the suspected area; calculating the grayscale level of the image and the grayscale level in the shadow area, obtaining the grayscale median value of the image and the grayscale difference of the grayscale level in the affected area; calculating the local rationality of the shadow area based on the grayscale difference and change continuity, wherein the grayscale difference and change continuity are negatively correlated with the local rationality of the shadow area.

[0018] In an image, pixels in the shadow area should show continuous grayscale changes between adjacent pixels, and their grayscale should be between the left and right segmentation thresholds. Therefore, this method reflects local rationality based on the continuity of grayscale changes in the suspected area and the grayscale difference between the suspected area and the grayscale median of the entire image.

[0019] Optionally, the step of calculating the local rationality of the suspected area corresponding to the pixel point in the background area includes: obtaining the grayscale level of the suspected area and the grayscale fluctuation of the pixel point in the suspected area; calculating the local rationality of the suspected area corresponding to the background area based on the grayscale level and the grayscale fluctuation, the grayscale level is directly proportional to the local rationality, and the grayscale fluctuation is inversely proportional to the local rationality.

[0020] Optionally, the steps of optimizing the segmentation threshold and obtaining the optimal segmentation boundary include: forming a shadow grayscale interval between two segmentation thresholds; sliding the boundary of the shadow grayscale interval within a preset range to construct an adjustment interval, and calculating the interval weight corresponding to the adjustment interval; obtaining the regional rationality of the segmentation area corresponding to the adjustment interval, and taking the product of the regional rationality and the corresponding interval weight as the recognition of the adjustment interval; taking the shadow grayscale interval with the maximum recognition as the optimal interval, and taking the boundary value of the optimal interval as the optimal segmentation boundary.

[0021] In the process of optimizing the segmentation threshold, the segmentation threshold is mainly changed within a certain range to construct an adjustment interval, and then the optimal interval is selected based on the rationality of the segmentation interval corresponding to the adjustment interval and the corresponding interval weight, and the image is re-segmented.

[0022] 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; and taking the absolute difference between the normalized result of the interval length of the adjustment area and the area ratio as the interval weight.

[0023] This application has the following technical effects:

[0024] In this method, two segmentation thresholds are determined based on the grayscale histogram, which can achieve more detailed image segmentation. The accuracy of the current image segmentation is then judged by calculating the local plausibility of the suspected area corresponding to the pixel points in each segmented area. If the image segmentation is inaccurate, the segmentation threshold is adjusted to obtain a more accurate segmentation area, thereby improving the accuracy of the final identification and extraction of the corroded area. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a method flow chart of a method for detecting defects in optical module packaging materials according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The present invention discloses a method for detecting defects in optical module packaging materials. Based on a grayscale histogram of an image of the packaging material surface, the method determines the locations of two peak points in the grayscale histogram and then determines two segmentation thresholds based on the locations of the two peak points. The two segmentation thresholds can be used to divide the image into multiple segmented regions. Different segmented regions correspond to pixels of different grayscales. The method then analyzes the regional rationality of each segmented region. If the regional rationality is too low, indicating that the regional division is irrational, the segmentation threshold should be optimized to obtain the optimal segmentation boundary. The image is then segmented based on the optimal segmentation boundary. Regions corresponding to corrosion locations in the segmented image are extracted to identify and extract the corrosion regions. Compared to traditional bimodal thresholding methods, this method can, on the one hand, divide more regions, thereby achieving more detailed segmentation of pixels in the image. On the other hand, based on the regional rationality of the regional divisions, it determines whether the current image segmentation is reasonable and whether it can effectively distinguish corrosion regions. When the regional rationality is less than a preset rationality threshold, the segmentation threshold is optimized and dynamically adjusted to better cope with different background regions and improve the accuracy of corrosion region identification.

[0027] Reference Figure 1 A method for detecting defects in optical module packaging materials includes steps S1 to S5.

[0028] S1: Obtain a grayscale histogram of the surface image of the optical module packaging material, 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 segmentation areas.

[0029] The surface image of the optical module packaging material is captured by an industrial camera, and the surface image is grayscale processed to obtain a surface grayscale image. The grayscale histogram of the surface grayscale image is obtained.

[0030] After metal corrosion, three typical areas will form on the surface: the corrosion area, the shadow area (referring to the transition area with a relatively smooth grayscale change between the corrosion area and the background area), and the background area. The corrosion area has a rough surface and strong light scattering due to missing material or thickening of the oxide layer. In X-ray or visible light imaging, it appears as the lowest grayscale range (close to black) and has large grayscale fluctuations due to uneven structure. The shadow area forms a gradient shadow due to partial scattering or absorption of light. Its grayscale value is between the corrosion area and the background area and has a gradient characteristic. The normal background area has a flat surface and high reflectivity, and the grayscale after imaging is high and relatively uniform.

[0031] The steps of obtaining the grayscale histogram are conventional techniques in the art and will not be described in detail here. In the grayscale histogram, the horizontal axis represents the grayscale value, while the vertical axis represents the number of pixels corresponding to the grayscale value in the image.

[0032] 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 segmentation regions.

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

[0034] Find the lowest valley point in the area 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-order derivative of the grayscale histogram. For the data to the right of the second peak point (which can also be understood as the area in the grayscale histogram where the grayscale value is greater than the second peak point), obtain the position of the minimum first-order derivative in this part of the data, and use the grayscale value corresponding to this position as the right segmentation threshold.

[0035] The first-order derivative of the grayscale histogram represents the degree of change in the number of pixels in the image as the grayscale changes, and the location of the minimum first-order derivative represents the location where the number of pixels changes the least. The grayscale value characteristics of the eroded area, shadow area, and background area in step S1 are consistent, completing the initial segmentation of the image.

[0036] S3: For each segmented area, based on the grayscale features of the pixels in each segmented area, calculate the regional rationality of the current segmented area, and take the product of the rationality of each area as the rationality of the segmented interval.

[0037] Based on the pixels in the segmented region, region growing is performed to obtain multiple suspected regions. The local rationality of the suspected regions is calculated, and the average of the multiple local rationality values is used as the regional rationality of the segmented region. The local rationality of the pixels in the suspected region is analyzed, and then the local regional rationality of the entire segmented region is analyzed.

[0038] For each segmented region, pixels within the segmented region are extracted and used as seed points. Region growing is then performed on the seed points to form multiple suspected regions, allowing for further segmentation of the segmented region. After segmentation, the local rationality of the suspected region is calculated based on the grayscale of the pixels within the suspected region. The results of these multiple local rationality measures reflect the overall regional rationality of the segmented region.

[0039] After image segmentation, the three segments are formed, and the grayscale characteristics of each segment are different. Based on the grayscale characteristics of the pixels in each segmentation area, the three segmentation areas can be named as: erosion area, shadow area, and background area. The erosion area is the area in the image with a grayscale value less than the left segmentation threshold, the shadow area is the area in the image with a grayscale value between the left and right segmentation thresholds, and the background area is the area in the image with a grayscale value greater than the right segmentation threshold.

[0040] Since the grayscale characteristics of pixels in different regions are different, the possibility of whether a pixel in a segmented region belongs to the region should be verified separately.

[0041] Among them, for the suspected area corresponding to the pixel point in the corrosion area, the grayscale fluctuation and grayscale level of the suspected area are obtained based on the grayscale value of the pixel point in the suspected area; the gradient level of the suspected area is obtained based on the gradient of the pixel point in the suspected area; the local rationality of the suspected area is calculated based on the grayscale fluctuation, grayscale level and gradient level. The grayscale fluctuation and gradient level are positively correlated with the local rationality, and the grayscale level is negatively correlated with the local rationality.

[0042] In this embodiment, the mean grayscale of all pixels in the suspected area is used as the grayscale level, the mean gradient of all pixels in the suspected area is used as the gradient level; and the standard deviation of the grayscale of all pixels in the suspected area is used as the grayscale fluctuation.

[0043] Specifically, the calculation formula for the local rationality of the suspected area corresponding to the pixel point in the corrosion area can be expressed as: Where, Indicates the local rationality of the pixel points in the suspected area; Indicates the grayscale fluctuation of pixels in the suspected area; Indicates the gradient level of the pixel in the suspected area; Indicates the gray level of the pixel in the suspected area.

[0044] The grayscale characteristics of pixels within the corrosion region are characterized by low grayscale values, uneven grayscale, and distinct boundaries. Therefore, the greater the grayscale fluctuation of a suspected region, the more likely it is that the pixels are in the corrosion region. A larger gradient indicates a more distinct pixel boundary within the suspected region. Consequently, the greater the local rationality of the suspected region, the more accurate the segmentation, and the greater the regional rationality.

[0045] Similarly, if the grayscale level in the suspected area corresponding to a pixel point is larger, it means that the overall grayscale in the suspected area is larger; at the same time, the gradient level and grayscale fluctuation are small, then it means that the suspected area may not be a real corrosion area, which further indicates that the two thresholds are not accurate in segmenting the image, so the smaller the regional rationality.

[0046] For the suspected area corresponding to the pixel point in the shadow area, the change continuity of the grayscale change in the suspected area is obtained; the grayscale level of the image and the grayscale level in the shadow area are calculated to obtain the grayscale difference of the image grayscale level and the grayscale level in the affected area; the local rationality of the shadow area is calculated based on the grayscale difference and change continuity, wherein the grayscale difference and change continuity are negatively correlated with the local rationality of the shadow area.

[0047] The overall grayscale of the shadow region lies between the eroded region and the background region. This means the overall grayscale of the shadow region should be close to the average level of all pixels in the image. Furthermore, the pixels in the shadow region exhibit a gradient, meaning the grayscale changes between adjacent pixels are highly continuous. Based on these characteristics, the local plausibility of the suspected region can be calculated.

[0048] Regarding the continuity of the grayscale changes of pixels in the suspected area, in this embodiment, the circumscribed circle of the suspected area is first obtained, and the continuity of the grayscale changes of pixels in the suspected area is quantified by fitting a gradient linear model based on the grayscale changes from the center of the circumscribed circle to the edge.

[0049] The gradient linear model can be expressed as: Where, Represents the grayscale value of the pixel, Indicates the slope of the grayscale value change from the center of the circle in the vertical direction; Indicates the slope of the grayscale value change from the center of the circle in the vertical direction; represents the baseline grayscale value, which is also the constant term in the gradient linear model fitting process. Based on the gradient linear model, the corresponding fitting error is obtained, and the inverse of the fitting error is used as the continuity of the change in the suspected region. Extracting the fitting error is a conventional technique in the art and will not be elaborated here.

[0050] Specifically, the calculation formula for the local rationality of the suspected area corresponding to the pixel point in the shadow area can be expressed as:

[0051] Where, Indicates the local rationality of the suspected area corresponding to the pixel in the shadow area; represents the fitting error of the gradient linear model, Represents the mean gray value in the suspected area, Represents the median grayscale value of all pixels in the image.

[0052] in the formula It indicates the continuity of change. The greater the continuity of change, the worse the continuity of gray value change in the suspected area, which further indicates that the suspected area may not belong to the shadow area.

[0053] This represents the grayscale difference between the overall grayscale of the pixel segments in the suspected region and the median grayscale value of the entire image. Based on the grayscale characteristics of the pixels in the shadow region, the overall grayscale of the suspected region should be close to the median grayscale value of the entire image. Therefore, the greater the grayscale difference, the more likely the suspected region is a shadow region, and thus the greater the local plausibility of the suspected region. Mainly used to prevent the denominator in the formula from being 0.

[0054] For the local rationality of the suspected area corresponding to the pixel points in the background area, the grayscale level of the suspected area and the grayscale fluctuation of the pixel points in the suspected area are obtained; based on the grayscale level and grayscale fluctuation, the local rationality of the suspected area corresponding to the background area is calculated, and the grayscale level is directly proportional to the local rationality, and the grayscale fluctuation is inversely proportional to the local rationality.

[0055] The grayscale characteristics of the pixels in the background area are mainly characterized by large grayscale values and uniform grayscale distribution. Therefore, this method judges the local rationality of the suspected area based on the grayscale fluctuation and grayscale level in the suspected area.

[0056] Specifically, the calculation formula for the local rationality of the suspected area corresponding to the pixel point in the background area can be expressed as: Where, Indicates the local rationality of the suspected area corresponding to the pixel point in the background area; Indicates the grayscale fluctuation of the suspected area corresponding to the pixel point in the background area; Indicates the grayscale level of the suspected area corresponding to the pixel in the background area.

[0057] The regional rationality corresponding to multiple segmentation regions is multiplied to obtain the final segmentation interval rationality of the entire image segmentation.

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

[0059] In this embodiment, the reasonable threshold is set to 0.8. When the segmentation interval rationality of the multiple segmented areas obtained by the first segmentation is greater than 0.8, it means that the image segmentation is relatively accurate and can accurately identify the corroded area in the image. Then, the corroded area in the image can be directly extracted to complete the anomaly detection.

[0060] S5: In response to the rationality of the segmentation interval being less than or equal to a preset rationality threshold, optimizing the segmentation threshold, obtaining an optimal segmentation boundary, using the image segmented based on the optimal segmentation boundary as a segmented image, and performing defect detection based on the segmented image.

[0061] If the final calculated segmentation interval rationality is small, it means that the segmentation area is not accurate. There may be abnormal situations such as the corrosion area being mistakenly divided into the shadow area, or the shadow area being mistakenly divided into the corrosion area. Therefore, it is necessary to optimize and adjust the segmentation threshold.

[0062] Specifically, the shadow grayscale interval is formed between the two segmentation thresholds; the boundary of the shadow grayscale interval is slid within the 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 of the adjustment interval; the shadow grayscale interval with the maximum recognition is used as the optimal interval, and the boundary value of the optimal interval is used as the optimal segmentation boundary.

[0063] A sliding range is set near the left and right segmentation thresholds. During the sliding adjustment of the left and right segmentation thresholds, a new adjustment interval is formed. For example, in this embodiment, the sliding range is set to 10 values near the segmentation thresholds. Assuming the left segmentation threshold is 50, the corresponding sliding range for the left segmentation threshold is 40-60. All possible regions for the left segmentation threshold are obtained, and all possible values for the right segmentation threshold are combined to form multiple adjustment intervals.

[0064] Get the interval weight corresponding to the adjustment interval.

[0065] The grayscale data of all pixels in the entire image was extracted. The pixels were clustered using the K-means clustering method based on their grayscale values. The number of clusters was set to three, resulting in three clusters. The pixels in each cluster had different overall grayscales, so the three clusters can be divided into: low-grayscale cluster, medium-grayscale cluster, and high-grayscale cluster. The medium-grayscale cluster corresponds to pixels in the shadow area of the image. The ratio of the number of pixels in the medium-grayscale cluster to the total number of pixels in the image was used as the area ratio of the shadow area in the image.

[0066] Since the pixels in the mid-grayscale clusters correspond to the shadow area, and the area between the two segmentation thresholds also corresponds to the shadow area, in practice, the length of the adjustment interval between the two segmentation thresholds should be close to the area ratio. Furthermore, the smaller the difference between the normalized adjustment interval length and the area ratio, the more accurate the image segmentation. Therefore, the reciprocal of the absolute difference between the normalized interval length and the area ratio is used as the interval weight.

[0067] The product of the interval weight and the rationality of the segmented interval corresponding to the adjustment interval is taken as the acceptance degree of the adjustment interval.

[0068] Specifically, the calculation formula of the recognition degree of the adjustment area can be expressed as:

[0069] Where, Indicates the adjustment range recognition; Indicates the adjustment range The rationality of the corresponding segmentation interval; Indicates the number of pixels in the grayscale cluster; Represents the number of all pixels in the image; is a linear normalization function.

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

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

[0072] In the segmented image based on the optimal segmentation boundary, the corroded area represents the corroded portion of the material surface. Meanwhile, because the grayscale value in the shadow area is lower than that in the background area, some shallowly corroded areas may be mixed in with the background area. Therefore, blob detection is used here to extract the shallowly corroded areas in the shadow area and classify them as corroded areas. Then, corroded areas are extracted to identify and extract corroded areas in the image, completing anomaly detection.

[0073] Here, the shallowly corroded part in the shadow area is extracted again to further improve the accuracy of the finally obtained corroded area.

[0074] An embodiment of the present application also discloses a system for detecting defects in packaging materials for optical modules, including a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, a method for detecting defects in packaging materials for optical modules according to the present application is implemented.

[0075] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface. The configuration and functions of these components are known in the art and will not be described in detail here.

[0076] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.

Claims

1. A method for detecting defects in optical module packaging materials, characterized in that: The method includes the following steps: obtaining a grayscale histogram of a surface image of an optical module packaging material, and determining the positions of two peak points in the grayscale histogram; the two peak points include a first peak point and a 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; determining two segmentation thresholds based on the positions of the two peak points, the two segmentation thresholds being a left segmentation threshold and a right segmentation threshold respectively; using the grayscale value of the lowest valley point between the first peak point and the second peak point as the left segmentation threshold; obtaining a first-order derivative of the grayscale histogram, and using the grayscale value of the position corresponding to the minimum value of the first-order derivative in an area of the histogram where the grayscale value is greater than the second peak point as the right segmentation threshold; Segment the image based on the segmentation threshold to form multiple segmentation areas; For each segmented region, based on the grayscale features of the pixels in each segmented region, the regional rationality of the current segmented region is calculated, specifically including: performing region growing based on the pixels in the segmented region to obtain multiple suspected regions, calculating the local rationality of the suspected regions, and taking the average of the multiple local rationalities as the regional rationality corresponding to the segmented region; wherein the segmented region includes: an erosion region, a shadow region, and a background region; taking the product of the rationality of each region as the rationality of the segmented interval; in response to the rationality of the segmented interval being greater than a preset rational threshold, using the segmented image as the segmented image for defect detection; in response to the rationality of the segmented interval being less than or equal to the preset rational threshold, optimizing the segmentation threshold to obtain the optimal segmentation boundary, specifically including: forming a shadow grayscale interval between two segmentation thresholds; sliding the boundary of the shadow grayscale interval within a preset range to construct an adjustment interval, and calculating the interval weight corresponding to the adjustment interval; obtaining the regional rationality of the segmented region corresponding to the adjustment interval, taking the product of the regional rationality and the corresponding interval weight as the recognition of the adjustment interval; taking the shadow grayscale interval with the maximum recognition as the optimal interval, taking the boundary value of the optimal interval as the optimal segmentation boundary, taking the image segmented based on the optimal segmentation boundary as the segmented image, and performing defect detection based on the segmented image.

2. The optical module packaging material defect detection method according to claim 1, characterized in that: The eroded area is the area in the image whose grayscale value is less than the left segmentation threshold, the shadow area is the area in the image whose grayscale value is between the left segmentation threshold and the right segmentation threshold; the background area is the area in the image whose grayscale value is greater than the right segmentation threshold.

3. The optical module packaging material defect detection method according to claim 1, characterized in that: The steps for calculating the local rationality of the suspected area corresponding to the pixel points of the corrosion area include: for any suspected area, obtaining the grayscale fluctuation and grayscale level of the suspected area based on the grayscale values of the pixels in the suspected area; obtaining the gradient level of the suspected area based on the gradient of the pixels in the suspected area; calculating the local rationality of the suspected area based on the grayscale fluctuation, grayscale level and gradient level, the grayscale fluctuation and gradient level are positively correlated with the local rationality, and the grayscale level is negatively correlated with the local rationality.

4. The optical module packaging material defect detection method according to claim 3, characterized in that: The standard deviation of the grayscale of the pixels in the suspected area is taken as the grayscale fluctuation of the suspected area.

5. The optical module packaging material defect detection method according to claim 1, characterized in that: The steps for calculating the local rationality of the suspected area corresponding to the central pixel point in the shadow area include: obtaining the change continuity of the grayscale change in the suspected area; calculating the grayscale level of the image and the grayscale level in the shadow area, obtaining the grayscale level of the image and the grayscale difference of the grayscale level in the affected area; calculating the local rationality of the shadow area based on the grayscale difference and change continuity, wherein the grayscale difference and change continuity are negatively correlated with the local rationality of the shadow area.

6. The optical module packaging material defect detection method according to claim 1, characterized in that: The steps for calculating the local rationality of the suspected area corresponding to the pixel point in the background area include: obtaining the grayscale level of the suspected area and the grayscale fluctuation of the pixel point in the suspected area; calculating the local rationality of the suspected area corresponding to the background area based on the grayscale level and the grayscale fluctuation, the grayscale level is proportional to the local rationality, and the grayscale fluctuation is inversely proportional to the local rationality.

7. The optical module packaging material defect detection method according to claim 1, characterized in that: The step of calculating the interval weight corresponding to the adjustment interval includes: obtaining the area ratio of the shadow area in the image; and taking the absolute difference between the normalized result of the interval length of the adjustment area and the area ratio as the interval weight.

Citation Information

Patent Citations

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

    CN116977340A

  • Cover film surface defect detection method based on machine vision

    CN119273684A