Image processing-based optical communication filter quality detection method and system
By using an iteratively optimized thin-plate spline interpolation algorithm, combined with gradient significance and residual clustering, a high-precision background image is constructed, which solves the problem of indistinguishable background and defects in the quality inspection of optical communication filters, and achieves high-precision defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DONGGUAN WEIKE OPTOELECTRONICS TECH CO LTD
- Filing Date
- 2025-10-14
- Publication Date
- 2026-04-28
AI Technical Summary
The quality inspection results of optical communication filters in the existing technology are inaccurate, mainly because noise points in the polarization image cause a complex background, making it impossible to accurately distinguish between the background and defects.
An iteratively optimized thin-plate spline interpolation algorithm is used to dynamically adjust the control point set by calculating the gradient significance and residual clustering of pixel points, constructing a high-precision target background image, and performing threshold segmentation and connected component analysis to extract defect regions.
This improves the accuracy and robustness of optical communication filter quality inspection, reduces the rate of missed defects, and enhances inspection precision.
Smart Images

Figure CN121353202B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method and system for detecting the quality of optical communication filters based on image processing. Background Technology
[0002] Optical communication filters are optical components used in optical communication systems to selectively transmit or block light of specific wavelengths. Optical communication filters have strict requirements for surface quality. When there are defects on the surface of the filter, the location of the defect will affect the optical path, which will cause the optical communication filter to be unable to accurately transmit or block light of specific wavelengths. Therefore, the quality of the filter needs to be tested during the production process of optical communication filters.
[0003] Currently, patent application CN120177498A discloses a method and related equipment for detecting appearance defects in optical communication filters. The method includes the following steps: acquiring a set of polarization images of the optical communication filter to be tested at different polarization angles; preprocessing the polarization image set to obtain a defect-enhanced image set, wherein the preprocessing includes sequentially performing defect enhancement processing, dynamic range compression and local contrast enhancement processing, and small defect morphological enhancement processing on the polarized light images in the polarization image set; and performing defect detection on the defect-enhanced image set based on a pre-trained multispectral attention fusion network.
[0004] The above method takes the same optical communication filter under different polarization angles and preprocesses the polarization image set to enhance defects before inputting it into a multispectral attention fusion network for defect detection. However, due to the influence of the filter on the refraction and projection of light, there will be a large number of noise points in the polarization image, which makes the background in the polarization image complex and makes it impossible to accurately distinguish between the background and defects in the polarization image, resulting in inaccurate quality detection results of the filter. Summary of the Invention
[0005] To address the technical problem of inaccurate quality inspection results for optical filters, this application provides a method and system for quality inspection of optical communication filters based on image processing. This method can construct an accurate background image of the filter, accurately distinguish between the background and defects in the filter image, and obtain accurate quality inspection results.
[0006] In a first aspect, this application provides a method for quality inspection of optical communication filters based on image processing. The method includes: acquiring a grayscale image of the filter to be inspected; constructing a target background of the grayscale image using a thin-plate spline interpolation algorithm; calculating a residual image between the grayscale image and the target background; and performing threshold segmentation on the residual image to obtain defect areas of the filter to be inspected. Constructing the target background of the grayscale image includes: calculating the gradient saliency of each pixel in the grayscale image; in one iteration, acquiring a residual image between the grayscale image and the initial background from the previous iteration to calculate the residual clustering degree of each pixel; and calculating the background of each pixel in the current iteration based on the residual clustering degree and the gradient saliency. Background confidence; comparing background confidence with a confidence threshold, the control point set of the previous iteration is divided into valid control points and invalid control points. Invalid control points are deleted, and new control points with the same number of invalid control points are selected in the grayscale image in descending order of selection coefficient to obtain the control point set of the current iteration. The selection coefficient is positively correlated with the background confidence of the pixel and the minimum Euclidean distance to the valid control point. The initial background is constructed in the control point set of the current iteration using a thin plate spline interpolation algorithm. Multiple iterations are performed until the change in the initial background between two adjacent iterations is less than a preset value or the number of iterations reaches the maximum number, at which point the target background is obtained.
[0007] By iteratively optimizing the control point set and calculating the background confidence based on gradient significance and residual clustering, invalid control points falling into the defect area are dynamically removed, and newly added control points with uniform distribution are selected, thereby constructing a more accurate target background model. This avoids the thin plate spline interpolation algorithm from learning defect features into the initial background, reducing the false negative rate of subsequent defect detection and improving detection accuracy.
[0008] Preferably, the calculation of the gradient saliency of each pixel includes: in the grayscale image, calculating the variance of the gradient direction of each pixel within the neighborhood window of any pixel; the gradient saliency of any pixel is the absolute value of the difference between the variance of the pixel and the average variance of all pixels.
[0009] By calculating the variance of the gradient direction in the neighborhood of a pixel and defining gradient saliency based on the absolute value of the difference from the mean variance, the complexity of local texture can be effectively quantified, thereby distinguishing defective regions from smooth backgrounds.
[0010] Preferably, the calculation of the residual clustering degree of each pixel includes: in the residual map between the grayscale image and the initial background in the previous iteration, performing a Gaussian weighted summation on the residual values of all pixels within the neighborhood window centered on any pixel to obtain the residual clustering degree of the pixel.
[0011] Real defects often form continuous clusters in the residual map. By performing Gaussian weighted summation on the residual values of pixels within the neighborhood window in the residual map, the residual clustering degree can be obtained, which can highlight spatially clustered defect signals and suppress isolated noise.
[0012] Preferably, the background confidence is negatively correlated with both the residual clustering degree and the gradient significance.
[0013] Preferably, before comparing the background confidence score and the confidence score threshold, the detection method further includes: weighted summing of the background confidence score of any pixel in the current iteration with the background confidence score of the pixel in the previous iteration.
[0014] By weighted summing the background confidence scores of the current iteration and the previous iteration, historical information is introduced, enhancing the stability and continuity of background point selection. Only pixels that consistently exhibit high confidence scores across multiple iterations are retained, reducing random errors and improving the robustness of background modeling.
[0015] Preferably, this iteration medium pixel Selection coefficient for:
[0016] ;in, For this iteration medium pixel Background confidence, For this iteration medium pixel The minimum Euclidean distance to each effective control point. This is the minimum distance threshold.
[0017] The higher the background confidence, the larger the selection coefficient, ensuring that pixels belonging to the pure background have a larger selection coefficient. The larger the minimum Euclidean distance, the larger the selection coefficient, ensuring the uniformity of the spatial distribution of the newly added control points, thereby improving the global fitting ability of thin plate spline interpolation and enhancing the accuracy of the background model.
[0018] Preferably, the target background for constructing the grayscale image further includes: during the initial iteration, dividing the grayscale image into a preset number of grid units, with the center point of each grid unit constituting the control point set for the initial iteration.
[0019] By dividing the grayscale image into grid cells in the initial iteration and initializing the control point set with the center point, the initial distribution of control points is guaranteed to cover the entire image area. The uniformly distributed control points can better capture global background features, providing a solid foundation for subsequent iterative optimization and avoiding modeling deviations caused by the initial point concentration.
[0020] Preferably, the change in the initial background between two adjacent iterations is the average of the absolute values of the differences in grayscale values of corresponding pixels in the initial background.
[0021] Preferably, thresholding the residual map to obtain the defect region of the filter to be detected includes: performing connected component analysis on the binarized result after thresholding to extract the area and location information of the defect.
[0022] In a second aspect, this application also provides an image processing-based optical communication filter quality inspection system, including a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the image processing-based optical communication filter quality inspection method according to the first aspect of this application is implemented.
[0023] The technical solution of this application has the following beneficial technical effects:
[0024] By acquiring the grayscale image of the filter to be inspected, an iteratively optimized thin-plate spline interpolation algorithm is used to construct the target background. In each iteration, the gradient significance and residual clustering of pixels are calculated to determine the background confidence level, and the control point set is dynamically adjusted to generate a high-precision background image. Subsequently, the residual image between the grayscale image and the target background is calculated, and threshold segmentation and connected component analysis are performed on the residual image to accurately extract the location and area information of defect regions. This scheme, through adaptive background modeling and defect enhancement, effectively overcomes the defect omission problem caused by control point contamination in the thin-plate spline interpolation algorithm, improving the accuracy and robustness of optical communication filter quality inspection. Attached Figure Description
[0025] Figure 1 This is a flowchart of an image processing-based optical communication filter quality detection method according to an embodiment of this application.
[0026] Figure 2 This is a schematic diagram of the change curve during the iteration process according to the embodiments of this application.
[0027] Figure 3 This is a structural block diagram of an image processing-based optical communication filter quality inspection system according to an embodiment of this application. Detailed Implementation
[0028] According to a first aspect of this application, this application provides a method for quality inspection of optical communication filters based on image processing, used to detect surface defects in manufactured optical communication filters. Figure 1 This is a flowchart of an image processing-based optical communication filter quality detection method according to an embodiment of this application. Figure 1As shown, the image processing-based optical communication filter quality detection method includes steps S101 to S103, which are described in detail below.
[0029] S101, Obtain the grayscale image of the filter to be detected, and construct the target background of the grayscale image using the thin plate spline interpolation algorithm.
[0030] In one embodiment, a high-resolution image of the optical communication filter under test is acquired using an image acquisition device such as an industrial camera under uniform illumination, and the acquired high-resolution image is converted into a grayscale image. Uniform illumination can be achieved using a ring light source.
[0031] Since optical filters have a significant refractive effect on light, and defects in the filters are located at a few pixels, a target background that accurately reflects the brightness distribution of an ideal, defect-free filter under current lighting conditions can be constructed for quality inspection. Defects in the optical communication filter under inspection can be determined by comparing the grayscale image with the target background image. Thin Plate Spline (TPS) interpolation modeling achieves background modeling by controlling the movement of multiple control points. The selection of control points directly affects the background modeling effect. If the control points are not selected properly, such as falling into the actual defect area, the TPS algorithm will learn the defect features into the target background, leading to subsequent missed defects. Therefore, to ensure the accuracy of optical communication filter quality inspection, this application adopts an iterative optimization method to construct the target background.
[0032] Specifically, constructing the target background of the grayscale image includes: calculating the gradient saliency of each pixel in the grayscale image; in one iteration, obtaining the residual image of the grayscale image and the initial background in the previous iteration to calculate the residual clustering degree of each pixel, and calculating the background confidence degree of each pixel in the current iteration based on the residual clustering degree and gradient saliency; comparing the background confidence degree and the confidence degree threshold, dividing the control point set of the previous iteration into valid control points and invalid control points, deleting invalid control points, and selecting new control points in the grayscale image in descending order of selection coefficients, with the same number of invalid control points, to obtain the control point set of the current iteration, wherein the selection coefficients are positively correlated with the background confidence degree of the pixel and the minimum Euclidean distance to the valid control points; constructing the initial background in the control point set of the current iteration using a thin plate spline interpolation algorithm; performing multiple iterations until the change in the initial background between two adjacent iterations is less than a preset value or the number of iterations reaches the maximum number, thus obtaining the target background.
[0033] Gradient saliency characterizes the texture complexity of a local region of any pixel relative to the global filter. Since defective pixels are rare in a filter, a higher gradient saliency indicates a greater deviation between that pixel and the background features of the filter. Therefore, gradient saliency can serve as an indicator to distinguish defects from the background. Specifically, calculating the gradient saliency of each pixel involves: in the grayscale image, calculating the variance of the gradient directions of each pixel within its neighborhood window; the gradient saliency of any pixel is the absolute value of the difference between its variance and the average variance of all pixels. Regions with higher gradient saliency have higher texture complexity and are more likely to be defective or noisy areas, rather than smooth background areas.
[0034] The residual clustering degree is used to quantify the initial judgment of abnormal regions in this iteration. Even if a real defect is partially absorbed by the initial background in a certain iteration, its residual signal, although not having a high peak value, will form a cluster in space, which can still be used to distinguish the defect from the background. Specifically, calculating the residual clustering degree of each pixel includes: in the residual map between the grayscale image and the initial background from the previous iteration, performing a Gaussian weighted summation on the residual values of all pixels within a neighborhood window centered on any pixel to obtain the residual clustering degree of that pixel.
[0035] In this embodiment, this iteration medium pixel residual aggregation Satisfying the relation:
[0036] ;
[0037] in, In pixels The center is a neighborhood window, and the size of the neighborhood window can be set to 7×7 or 5×5; For neighborhood windows One pixel within, For this iteration medium pixel The residual value, The standard deviation of the Gaussian function is set to 1.5. Represents pixels and pixels The Euclidean distance between them.
[0038] Background confidence assesses how reliably each pixel can serve as a clean background. An ideal background pixel should have low residual clustering, meaning it does not belong to an unmodeled anomalous region, and low gradient significance, meaning it does not possess defective texture features. Therefore, background confidence is negatively correlated with both residual clustering and gradient significance.
[0039] In this embodiment, this iteration medium pixel Background confidence Satisfying the relation:
[0040] ;
[0041] in, For this iteration medium pixel The residual aggregation degree, For pixels The significance of the gradient. It should be noted that, to ensure dimensional consistency, the residual clustering degree must be considered before calculating the background confidence level. With gradient significance Standardize the process.
[0042] In another embodiment, to overcome potential fluctuations in background confidence during iteration, historical information about background confidence during iteration is introduced to obtain a more stable and accurate background confidence. Specifically, before comparing the background confidence with the confidence threshold, the detection method further includes: weighted summing of the background confidence of any pixel in the current iteration with the background confidence of the pixel in the previous iteration. This endows each pixel with a memory capability, ensuring that only pixels that consistently and stably exhibit good background features across multiple iterations can maintain a high background confidence, thus enhancing the stability and robustness of subsequent control point selection.
[0043] In this embodiment, the background confidence of the pixels from the previous iteration is used to evaluate the current iteration. medium pixel The background confidence is updated, and the weighted summation is calculated using the following formula:
[0044] ;
[0045] in, For this iteration medium pixel Weighted summation of background confidence For this iteration medium pixel Background confidence level before weighted summation For the previous iteration medium pixel Background confidence after weighted summation; The smoothing coefficient is used in this embodiment. The value is 0.4.
[0046] After obtaining the background confidence score of each pixel in this iteration, the control point set can be continuously optimized through a survival-of-the-fittest mechanism. Each control point in the control point set is a pixel in the grayscale image. In the control point set of the previous iteration, control points with a background confidence score higher than or equal to a confidence threshold are considered valid and retained, while those below the threshold are considered invalid and deleted. The confidence threshold is set to 0.8. Subsequently, new control points are selected in the grayscale image in descending order of selection coefficient, matching the number of invalid control points, to maintain a stable total number of control points. The selection coefficient is positively correlated with both the background confidence score of the pixel and the minimum Euclidean distance to a valid control point. New control points should not only have a high probability of belonging to a clean background but should also be as far away as possible from existing valid control points to ensure the uniform distribution of the control point set across the entire image space, thereby constructing a more accurate global background model.
[0047] In this embodiment, this iteration medium pixel Selection coefficient for:
[0048] ;in, For this iteration medium pixel Background confidence, For this iteration medium pixel The minimum Euclidean distance to each effective control point. This is the minimum distance threshold. The larger the value, the more pixels there are. The greater the likelihood of it having a clean background, The larger the value, the more pixels there are. Away from all valid control points, at this point, the pixel The selection coefficient is relatively large to ensure the uniform distribution of the control point set in the entire image space during this iteration. The minimum distance threshold can be set to 1, which is used during this iteration. medium pixel The minimum Euclidean distance to each effective control point is less than the minimum distance threshold. At that time, this iteration medium pixel The selection coefficient is set to 0.
[0049] The valid control points retained in this iteration are merged with the newly added control points selected based on the selection coefficients to obtain the control point set for this iteration. Then, a smooth surface is fitted onto the control point set of this iteration using the thin plate spline interpolation algorithm, which serves as the initial background for this iteration.
[0050] Thus, each iteration yields an initial background. The change in the initial background between two adjacent iterations is calculated, where the change is the average of the absolute values of the differences in grayscale values of corresponding pixels in the initial background. The target background is obtained when the change in the initial background is less than a preset value or the maximum number of iterations is reached. The preset value is 0.5; the maximum number of iterations is 50. Please refer to [link / reference]. Figure 2 This is a schematic diagram of the change curve during the iteration process according to the embodiments of this application.
[0051] Understandably, since the control point set of the previous iteration cannot be obtained in the first iteration, in order to ensure that the initial distribution of control points has good spatial coverage, the grayscale image is divided into a preset number of grid units in the first iteration. The center point of each grid unit constitutes the control point set of the first iteration, and the preset number can be 15×15.
[0052] Thus, by iteratively optimizing the algorithm, the problem of control point contamination in the thin plate spline interpolation algorithm is effectively overcome, and a high-precision filter target background that can adapt to individual differences is constructed, laying the foundation for subsequent defect extraction.
[0053] S102, calculate the residual image between the grayscale image and the target background.
[0054] In one embodiment, the grayscale image is subtracted pixel by pixel from the target background, and the absolute value is taken to obtain a residual image. In this residual image, grayscale changes caused by light refraction due to the filter are eliminated because they are accurately fitted to the target background, while the defective areas, whose grayscale values deviate from the ideal background, have their difference signals highlighted and appear as areas with higher grayscale values.
[0055] S103, perform threshold segmentation on the residual map to obtain the defect area of the filter to be inspected.
[0056] In one embodiment, a fixed threshold or an adaptive thresholding algorithm such as the Otsu thresholding method is used to determine the segmentation threshold, and the residual image is binarized. Pixels with residual values higher than the threshold are identified as defective parts, and their pixel values are set to 255 (white); pixels with residual values lower than the threshold are identified as background parts, and their pixel values are set to 0 (black). Specifically, thresholding the residual image to obtain the defective region of the filter to be detected includes: performing connected component analysis on the binarized result after thresholding to extract the area and location information of the defects.
[0057] Thus, by performing threshold segmentation and connected component analysis on the residual map, defective regions can be accurately located, enabling automated and high-precision detection of the quality of optical communication filters.
[0058] According to a second aspect of this application, this application also provides an image processing-based optical communication filter quality inspection system. Figure 3 This is a structural block diagram of an image processing-based optical communication filter quality inspection system according to an embodiment of this application. Figure 3 As shown, the system 50 includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the image processing-based optical communication filter quality detection method according to the first aspect of this application. The system also includes other components well-known to those skilled in the art, such as a communication bus and a communication interface. Their configuration and functions are known in the art and will not be described further here.
[0059] It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of this application, and these all fall within the scope of protection of this application.
Claims
1. A method for detecting the quality of optical communication filters based on image processing, characterized in that, The detection method includes: acquiring a grayscale image of the filter to be detected; constructing a target background of the grayscale image using a thin plate spline interpolation algorithm; calculating a residual image between the grayscale image and the target background; and performing threshold segmentation on the residual image to obtain the defect area of the filter to be detected. The target background for constructing the grayscale image includes: Calculating the gradient significance of each pixel in a grayscale image includes: calculating the variance of the gradient direction of each pixel within the neighborhood window of any pixel in the grayscale image; the gradient significance of any pixel is the absolute value of the difference between the variance of the pixel and the average variance of all pixels. In one iteration, a residual map of the grayscale image and the initial background from the previous iteration is obtained to calculate the residual clustering degree of each pixel. This includes: in the residual map of the grayscale image and the initial background from the previous iteration, performing a Gaussian weighted summation on the residual values of all pixels within a neighborhood window centered on any pixel to obtain the residual clustering degree of the pixel; and calculating the background confidence degree of each pixel in the current iteration based on the residual clustering degree and gradient significance. By comparing the background confidence level and the confidence threshold, the control point set from the previous iteration is divided into valid and invalid control points. Invalid control points are deleted, and new control points, equal in number to the number of invalid control points, are selected from the grayscale image in descending order of their selection coefficients. This yields the control point set for the current iteration. medium pixel Selection coefficient for: In the formula, For this iteration medium pixel Background confidence, For this iteration medium pixel The minimum Euclidean distance to each effective control point. Minimum distance threshold; The initial background is constructed in the control point set of the current iteration using the thin plate spline interpolation algorithm; multiple iterations are performed until the change in the initial background between two adjacent iterations is less than the preset value or the number of iterations reaches the maximum number, at which point the target background is obtained.
2. The method for detecting the quality of optical communication filters based on image processing according to claim 1, characterized in that, The background confidence level is negatively correlated with both the residual clustering degree and the gradient significance.
3. The method for detecting the quality of optical communication filters based on image processing according to claim 1, characterized in that, Before comparing the background confidence score and the confidence threshold, the detection method further includes: weighted summing of the background confidence score of any pixel in the current iteration with the background confidence score of the pixel in the previous iteration.
4. The method for detecting the quality of optical communication filters based on image processing according to claim 1, characterized in that, The target background for constructing the grayscale image also includes: during the initial iteration, the grayscale image is divided into a preset number of grid units, and the center point of each grid unit constitutes the control point set for the initial iteration.
5. The method for detecting the quality of optical communication filters based on image processing according to claim 1, characterized in that, The change in the initial background between two adjacent iterations is the average of the absolute values of the differences in grayscale values of corresponding pixels in the initial background.
6. The method for detecting the quality of optical communication filters based on image processing according to claim 1, characterized in that, Thresholding the residual map to obtain the defect region of the filter to be inspected includes: performing connected component analysis on the binarized result after thresholding to extract the area and location information of the defects.
7. An image processing-based optical communication filter quality inspection system, characterized in that, It includes a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the image processing-based optical communication filter quality detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Optical communication filter appearance defect detection method and related equipment
CN120177498A
Picture matting method based on sample pair screening and local optimization
CN114445384A
Unified image transformation method based on coupling thin plate spline interpolation
CN117830076A