Optical communication filter appearance defect detection method and related equipment

Through the multi-spectral attention fusion network and the improved YOLOv5 backbone network, combined with multi-polarization information and special preprocessing, the problem of high leakage detection rate in optical communication filter detection is solved, and effective detection of small and low-contrast defects is achieved.

CN120177498BActive Publication Date: 2025-08-22ZHONGKE BOCHUANG (GUANGDONG) TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510673834.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-08-22
Estimated Expiration
2045-05-23

AI Technical Summary

Technical Problem

The prior art has high leakage detection rate in optical communication filter detection, making it difficult to effectively identify defect feature blurring and transparent substrates caused by optical interference effects caused by multi-layer coatings.

Method used

The multi-spectral attention fusion network is adopted, combined with multi-polarization information and specialized preprocessing methods, and the spectral separation convolution module and the cross-modal attention fusion module in the improved YOLOv5 backbone network are used to improve the detection ability of small and low-contrast defects through the frequency domain-space feature fusion and cross-modal attention mechanism.

Benefits of technology

The leakage detection rate is reduced and the accuracy of detection of defects on optical communication filters with small, low contrast and interference from film texture is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120177498B_ABST
    Figure CN120177498B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of visual inspection technology, and specifically discloses a method for detecting appearance defects in optical communication filters and related equipment. The method comprises the following steps: obtaining a set of polarization images of the optical communication filter to be inspected at different polarization angles; preprocessing the polarization image set to obtain a set of defect-enhanced images; and performing defect detection on the defect-enhanced image set based on a pre-trained multispectral attention fusion network. The method utilizes multi-polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of tiny, low-contrast defects on optical communication filters that are affected by film texture interference, thereby reducing the missed detection rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of visual inspection technology, and more specifically, to a method for detecting appearance defects of optical communication filters and related equipment. Background Art

[0002] In actual factory production, filter surface defect detection relies primarily on manual labor. Workers observe the filters using microscopes, determine the defect type based on their experience, and then address it. However, manual screening has significant drawbacks. Prolonged visual observation can easily lead to fatigue, resulting in low detection reliability and efficiency.

[0003] In recent years, advances in technologies such as visual image processing and deep learning have significantly driven the development of vision-based appearance defect detection, making it an effective detection solution that improves detection accuracy and speed. Traditional machine vision technology is divided into two categories. One is based on image processing, which uses features such as the shape, color, and edges of the target object to detect defects. This method is more effective for products with simple backgrounds, while complex backgrounds can be identified through frequency domain analysis. The other is based on statistical feature machine learning, which first extracts image statistical features and then inputs them into a learning model to achieve defect detection.

[0004] Deep learning, a branch of machine learning, has rapidly developed and is widely used in industrial visual inspection. It offers advantages such as strong feature extraction and integration capabilities, no need for complex preprocessing or manually designed feature extractors, and simple and efficient output design. However, filter inspection presents unique challenges: optical interference effects caused by multi-layer coatings blur defect features, and transparent substrates further reduce the contrast between defects and background. Furthermore, existing models are susceptible to interference from complex film textures during feature extraction, resulting in a high rate of missed detections.

[0005] There is currently no effective technical solution to the above problems. Summary of the Invention

[0006] The purpose of this application is to provide a method and related equipment for detecting appearance defects of optical communication filters to reduce the missed detection rate.

[0007] In a first aspect, the present application provides a method for detecting appearance defects of an optical communication filter, the method comprising the following steps:

[0008] S1. Acquire a set of polarization images of an optical communication filter to be tested at different polarization angles;

[0009] S2. Preprocessing the polarization image set to obtain a defect-enhanced image set;

[0010] S3. Defect detection is performed on the defect enhanced image set based on a pre-trained multispectral attention fusion network. The multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module and a multi-scale defect detection head arranged in sequence. The feature extraction module is a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module. The spectral separation convolution module includes a first convolution layer, a DCT transformation layer, an IDCT inverse transformation layer and a residual fusion layer arranged in sequence.

[0011] This method utilizes multiple polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain-spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of tiny, low-contrast defects on optical communication filters that are affected by film texture interference, and reduce the missed detection rate.

[0012] In the optical communication filter appearance defect detection method, the preprocessing in step S2 includes defect enhancement processing, dynamic range compression and local contrast enhancement processing, and small defect morphology enhancement processing performed sequentially on the polarized light image in the polarization image set.

[0013] Through the sequential processing of these three stages, the defect features in the image are effectively highlighted, and background interference such as the interference texture of the multilayer film is suppressed to a certain extent, thereby obtaining a high-quality defect enhanced image set, providing more favorable data input for subsequent defect detection.

[0014] The optical communication filter appearance defect detection method, wherein the defect enhancement processing includes:

[0015] S21, performing contrast-limited adaptive histogram equalization on the polarized light image in the polarized image set;

[0016] S22 , performing a differential operation on the polarized light image after the contrast-limited adaptive histogram equalization processing to highlight the defect edge.

[0017] In the optical communication filter appearance defect detection method, the dynamic range compression and local contrast enhancement processing includes:

[0018] S23, performing adaptive logarithmic mapping processing on the polarized light image after the defect enhancement processing to repair overexposure and underexposure defects;

[0019] S24, performing multi-scale Retinex enhancement processing on the polarized light image after the adaptive logarithmic mapping processing to separate the illumination component and the reflection component.

[0020] In the optical communication filter appearance defect detection method, the small defect morphology enhancement processing includes:

[0021] S25, performing a top-hat transformation on the polarized light image after dynamic range compression and local contrast enhancement processing to highlight tiny defects;

[0022] S26 , performing Sauvola adaptive binarization processing on the polarized light image after the top-hat transformation to segment tiny defects, so as to obtain the defect enhanced image set.

[0023] The optical communication filter appearance defect detection method, wherein the feature extraction module includes a first 3×3 convolution layer, a first separation convolution module, a second 3×3 convolution layer, a second separation convolution module and an SPP layer arranged in sequence, and the first separation convolution module and the second separation convolution module are both the spectral separation convolution modules.

[0024] The optical communication filter appearance defect detection method, wherein the multi-scale defect detection head includes a 20x20 detection head, a 40x40 detection head, an 80x80 detection head, and a 120x120 detection head constructed based on a 1.5× downsampling branch.

[0025] In a second aspect, the present application further provides a device for detecting appearance defects of optical communication filters, the device comprising:

[0026] An acquisition module, configured to acquire a set of polarization images of the optical communication filter to be detected at different polarization angles;

[0027] A preprocessing module, configured to preprocess the polarization image set to obtain a defect enhanced image set;

[0028] A detection module is used to perform defect detection on the defect-enhanced image set based on a pre-trained multispectral attention fusion network, wherein the multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module, and a multi-scale defect detection head arranged in sequence. The feature extraction module is a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module, and the spectral separation convolution module includes a first convolution layer, a DCT transformation layer, an IDCT inverse transformation layer, and a residual fusion layer arranged in sequence.

[0029] The device uses multi-polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain-spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of tiny, low-contrast defects on optical communication filters that are affected by film texture interference, thereby reducing the missed detection rate.

[0030] In a third aspect, the present application further provides an electronic device comprising a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps of the method provided in the first aspect are executed.

[0031] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, runs the steps of the method provided in the first aspect above.

[0032] As can be seen from the above, this application provides a method and related equipment for detecting appearance defects in optical communication filters. Specifically, this method utilizes the spectral separation convolution module in the improved YOLOv5 backbone network to fuse frequency and spatial domain information when extracting features, enhancing the perception of subtle textures and edges, helping to distinguish real defects from background textures. A cross-modal attention fusion module is then used to further process features from different polarization channels. The attention mechanism learns and enhances defect-related features, while suppressing periodic texture interference caused by multi-layer film interference, thereby improving the network's defect recognition accuracy. Thus, this method utilizes multi-polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain and spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of small, low-contrast defects on optical communication filters that are affected by film texture interference, while reducing the missed detection rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 This is a flow chart of a method for detecting appearance defects of optical communication filters provided in an embodiment of the present application.

[0034] Figure 2 Schematic diagram of the network structure of the multi-spectral attention fusion network.

[0035] Figure 3 Schematic diagram of the network structure of the spectral separation convolution module.

[0036] Figure 4 This is a schematic diagram of the structure of the optical communication filter appearance defect detection device provided in an embodiment of the present application.

[0037] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0038] Reference numerals: 201, acquisition module; 202, pre-processing module; 203, detection module; 301, processor; 302, memory; 303, communication bus. DETAILED DESCRIPTION

[0039] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.

[0040] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.

[0041] First, please refer to Figure 1-Figure 3 Some embodiments of the present application provide a method for detecting appearance defects of an optical communication filter, the method comprising the following steps:

[0042] S1. Acquire a set of polarization images of an optical communication filter to be tested at different polarization angles;

[0043] S2. Preprocessing the polarization image set to obtain a defect enhanced image set;

[0044] S3. Defect detection is performed on a defect-enhanced image set based on a pre-trained multispectral attention fusion network. The multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module, and a multi-scale defect detection head, which are arranged in sequence. The feature extraction module is a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module. The spectral separation convolution module includes a first convolution layer, a DCT transformation layer, an IDCT inverse transformation layer, and a residual fusion layer, which are arranged in sequence.

[0045] Specifically, in step S1, defects on the filter surface exhibit different contrast or visibility under different polarized light illumination. Acquiring a multi-angle polarized image set provides more comprehensive information, which helps to capture defects that are difficult to detect at a single angle. The polarized image set contains polarized light images at multiple angles. Multi-angle polarized light images provide richer surface information, which helps to reveal defects under different lighting and observation conditions.

[0046] More specifically, step S2 aims to improve the quality of the original image, enhancing defect features while suppressing background interference. The primary purpose of preprocessing is to enhance the contrast between the defect and the background, repair overexposed or underexposed areas caused by high reflectivity, and provide clearer input for subsequent deep learning detection.

[0047] More specifically, in step S3, the multispectral attention fusion network is the core detection tool, and its structure is designed according to the characteristics of filter defects. The multispectral preprocessing layer in this network is used to process image data of different polarization angles from the defect enhancement image set; the feature extraction module is improved based on the YOLOv5 backbone network. The improvement method is to replace part of the C3 module with the spectral separation convolution module. Among them, the C3 module belongs to the common spectral decoupling structure in the YOLOv5 backbone network and will not be described in detail here. The spectral separation convolution module realizes feature fusion in the frequency domain and spatial domain through the first convolution layer, DCT transformation layer, IDCT inverse transformation layer and residual fusion layer. This design can simultaneously analyze the frequency information and spatial information of the image, enhance the ability to extract subtle defect features, and help distinguish defects from periodic film textures; the cross-modal attention fusion module is used to remove the interference of multi-layer film interference texture. It fuses features from different polarization light images through the attention mechanism, learns which features are related to defects and which are related to film textures, enhances defect features, suppresses texture interference, and improves detection robustness; the multi-scale defect detection head can detect defects of different sizes. Taking into account the differences in filter defect sizes, especially the existence of sub-micron defects, the multi-scale detection head can make predictions on feature maps of different resolutions to ensure that both large and small defects can be effectively identified.

[0048] More specifically, the traditional YOLOv5 C3 module relies solely on spatial domain convolution. The improved module converts feature maps to the frequency domain via discrete cosine transform (DCT), truncating low-frequency components in the frequency domain (to suppress high-frequency noise). It then recovers spatial information via inverse transform (IDCT) and finally adds it to the original spatial features. This dual-domain processing enhances feature expression. The first convolutional layer is preferably a 3×3 convolution, which effectively reduces the number of parameters while filtering out redundant high-frequency information by truncating low-frequency components, reducing computational complexity and improving inference speed. The improved YOLOv5 backbone network works as follows: 3×3 convolution is performed on the input image to generate a basic spatial feature map. The feature map is then transformed using the DCT transform layer, mapping the spatial features to the frequency domain. The low-frequency components (usually concentrated in the upper left corner of the DCT matrix) are then truncated to remove high-frequency noise. The filtered low-frequency components are then inversely transformed back to the spatial domain using the inverse IDCT transform layer, preserving the main structural information. Finally, the reconstructed features are added to the original spatial features using the residual fusion layer to achieve the complementarity of frequency domain enhancement features and spatial details. This processing method explicitly separates the frequency domain components through DCT / IDCT, avoiding the implicit mixing of frequency domain information by traditional convolution, thus achieving decoupling of frequency domain features. Secondly, the low-frequency truncation threshold can be learned through training to dynamically adjust the frequency domain retention range to meet the needs of different tasks and achieve adaptive filtering.

[0049] The optical communication filter appearance defect detection method of the present application embodiment utilizes the spectral separation convolution module in the improved YOLOv5 backbone network to fuse frequency and spatial domain information when extracting features, enhancing the perception of subtle textures and edges, helping to distinguish real defects from background textures. Simultaneously, a cross-modal attention fusion module further processes features from different polarization channels, learning and enhancing defect-related features through the attention mechanism while suppressing periodic texture interference caused by multi-layer film interference, thereby improving the network's defect recognition accuracy. Thus, this method utilizes multi-polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain and spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of small, low-contrast defects on optical communication filters that are affected by film texture interference, while reducing the missed detection rate.

[0050] In some preferred embodiments, the preprocessing in step S2 includes sequentially performing defect enhancement processing, dynamic range compression and local contrast enhancement processing, and small defect morphology enhancement processing on the polarized light image in the polarization image set.

[0051] Specifically, defect enhancement processing aims to initially highlight potential defects in an image. Dynamic range compression and local contrast enhancement are used to address overexposure and underexposure in images while improving contrast in local areas. Small defect morphology enhancement specifically targets submicron defects, utilizing morphological methods to enhance the features of these tiny targets.

[0052] More specifically, the above processing approach addresses the complex characteristics of optical communication filter images by decomposing the preprocessing process into three sequentially executed stages.

[0053] First, defect enhancement processing is performed to perform preliminary processing on the original polarized light image to enhance the signal of possible defect areas. Next, dynamic range compression and local contrast enhancement processing are performed. This stage processes the brightness distribution of the image, compresses the excessive dynamic range, and enhances the contrast of local areas to improve the overexposure, underexposure and insufficient contrast problems caused by highly reflective materials and transparent substrates. Finally, small defect morphological enhancement processing is performed, using morphological operations to specifically enhance the tiny structures in the image, making small submicron defects more prominent in the image. Through the sequential processing of these three stages, the defect features in the image are effectively highlighted, and background interference such as multilayer film interference texture is suppressed to a certain extent, thereby obtaining a high-quality defect enhanced image set, providing more favorable data input for subsequent defect detection.

[0054] In some preferred embodiments, the defect enhancement process includes:

[0055] S21, performing contrast-limited adaptive histogram equalization on the polarized light image in the polarization image set;

[0056] S22 , performing a differential operation on the polarized light image after the contrast-limited adaptive histogram equalization processing to highlight the defect edge.

[0057] Specifically, step S21 uses limited contrast adaptive histogram equalization to divide the image into multiple blocks of preset size, and then independently performs histogram equalization in each block, and avoids excessive noise amplification by limiting the contrast gain, which can effectively improve the contrast of local areas of the image. In the embodiment of the present application, the block size is preferably set to 32×32, which can balance local adaptability and noise suppression. Step S22 performs a differential operation on the contrast-enhanced image, and enhances the areas in the image with drastic grayscale changes by subtracting the blurred version of the image, that is, highlighting the edge information.

[0058] More specifically, to address the potential issues of insufficient contrast and unclear defect edges in the original polarized light image, step S21 segments the image into multiple small regions and performs adaptive contrast adjustment within each region. This improves the contrast between the defect region and the background, which originally had minimal grayscale differences. The differential operation in step S22 effectively highlights edges and details in the image by calculating the difference between the image and its smoothed version, further sharpening the edge contours of the defect for greater clarity. The synergistic effect of steps S21 and S22 enhances the defect features in the original polarized light image, providing a more favorable input image for subsequent defect detection.

[0059] In some preferred embodiments, in step S22, the difference operation satisfies:

[0060] (1)

[0061] Among them, I en is the polarized light image after differential operation, I is the polarized light image after contrast-limited adaptive histogram equalization processing, is a Gaussian blur kernel with a kernel size of 1.5.

[0062] Specifically, Gaussian blur is an image smoothing technique, and its kernel size determines the degree of smoothing. A Gaussian kernel with a kernel size of 1.5 provides a moderate smoothing effect, which can suppress high-frequency noise and subtle textures in the image to a certain extent while preserving the main edge information of the image.

[0063] More specifically, the above processing method subtracts the image processed by Gaussian blur from the original image processed by limited contrast adaptive histogram equalization to achieve a difference operation, which can highlight the areas in the image with faster intensity changes, which usually correspond to the edges and details of the image.

[0064] More specifically, in the optical communication filter appearance defect detection scenario, the image to be inspected may contain submicron defects and interference textures caused by multilayer films. Simple differential operations may not be able to effectively distinguish the defect edge from these background textures and noise. In the above processing method, the image processed by limited contrast adaptive histogram equalization provides the basis for local contrast enhancement. After applying Gaussian blur with a kernel size of 1.5, the resulting image G (σ=1.5) *I retains the low-frequency components and main structure of the image, while the amplitude of the high-frequency components (including subtle textures and noise) is reduced. The original image I is subtracted from the smoothed image G. (σ=1.5) *I, obtained I enIt primarily contains the high-frequency components of the image. Since the edges of submicron defects typically appear as areas of rapidly changing local intensity, and while the interference texture of multilayer films is also high-frequency, its pattern may differ from that of the defect edge, and can be suppressed to a certain extent through Gaussian blurring with specific parameters, this differential operation can enhance the contrast of the defect edge, making it more prominent in the image, while relatively reducing the interference of background texture and noise. This results in an enhanced image that highlights the defect edge, providing a more favorable input image for subsequent defect detection steps.

[0065] In some preferred embodiments, the dynamic range compression and local contrast enhancement processing includes:

[0066] S23, performing adaptive logarithmic mapping processing on the polarized light image after the defect enhancement processing to repair overexposure and underexposure defects;

[0067] S24, performing multi-scale Retinex enhancement processing on the polarized light image after the adaptive logarithmic mapping processing to separate the illumination component and the reflection component.

[0068] Specifically, adaptive logarithmic mapping compresses the image's brightness range using a logarithmic function and adjusts parameters (such as the dynamic adjustment coefficients mentioned below) based on the brightness characteristics of the image region to improve detail in overly bright and dark areas. Multi-scale Retinex enhancement, based on Retinex theory, decomposes the image into illumination and reflection components, enhancing local contrast by removing the illumination component and applying multiple scales to address illumination variations at different spatial frequencies.

[0069] More specifically, polarized light images may suffer from excessive dynamic range and insufficient local contrast due to material properties, impacting subsequent defect detection. By performing adaptive logarithmic mapping, the image's brightness range is compressed, particularly improving the visibility of details in overexposed and underexposed areas, thereby resolving the dynamic range issue. Multi-scale Retinex enhancement decomposes the image into illumination and reflection components, enhancing the image's local contrast by removing the illumination component. Multi-scale processing also adapts to illumination variations at different scales, making defect features more prominent and improving the accuracy of subsequent defect detection.

[0070] In some preferred embodiments, in step S23, the adaptive logarithmic mapping process satisfies:

[0071] (2)

[0072] Among them, I en is the polarized light image after differential operation, I logis the polarized light image after adaptive logarithmic mapping processing, α is the dynamic adjustment coefficient, for the highlight area, α=0.1, for the dark area, α=0.01.

[0073] Specifically, formula (2) uses a logarithmic mapping formula to compress the dynamic range and implements adaptive processing by introducing a dynamic adjustment coefficient α. Specifically, the α coefficient is dynamically adjusted according to the brightness of the image area. For the highlight area in the image, α is set to 0.1; for the dark area in the image, α is set to 0.01. It can be set separately by presetting the judgment threshold of the highlight area and the judgment threshold of the dark area. This method of adjusting α according to the regional brightness enables the logarithmic mapping process to adjust different brightness ranges in a targeted manner. When the input value is low, the slope of the logarithmic curve is large, which can effectively stretch the contrast of the dark area. When the input value is high, the slope of the logarithmic curve is small, which can effectively compress the dynamic range of the highlight area. Therefore, this process can better repair overexposure and underexposure defects in the image.

[0074] More specifically, the adaptive logarithmic mapping processing aims to repair overexposed and underexposed areas in the image. By applying the logarithmic mapping function, the dynamic range of the image is compressed, and the dynamic range of the highlight area is effectively compressed, reducing the impact of overexposure, and improving the contrast of the dark area, so that the details of the underexposed area can be revealed, so that the overall brightness and contrast distribution of the corresponding output image are optimized, providing a basis for subsequent multi-scale Retinex enhancement processing and defect detection.

[0075] In some preferred embodiments, in step S24, the multi-scale Retinex enhancement process satisfies:

[0076] (3)

[0077] Where I(x,y) is the pixel value of the polarized light image at the coordinate (x,y) after adaptive logarithmic mapping processing, R(x,y) is the pixel value of the polarized light image at the coordinate (x,y) after multi-scale Retinex enhancement processing, and w k is the weight of the k-th scale, is the Gaussian kernel of the kth scale, where w k and σ k (kernel size) can be set according to usage requirements. Preferably, w k =[0.3,0.5,0.2],σ=[15,80,200].

[0078] Specifically, the above processing method uses three Gaussian kernels of different scales to convolve each pixel in the polarized light image after adaptive logarithmic mapping, and obtains , used to estimate illumination components at different scales. Calculate the logarithm logI(x,y) of each pixel and the logarithm of the estimated illumination component at each scale The difference between the two values ​​is used to separate the reflection component estimation value in the logarithmic domain. The reflection component estimation values ​​obtained at the three scales are multiplied by the corresponding weight w k , and then sum them up to get the pixel value of the final enhanced image R(x,y), thereby realizing the separation of the image illumination component and the reflection component.

[0079] More specifically, the process receives as input a polarized image I(x,y) processed by adaptive logarithmic mapping. Subtraction in the logarithmic domain decomposes the multiplicative model to separate the reflection component. Simultaneously, three Gaussian kernels of different scales are used to estimate illumination components of different spatial frequencies for multi-scale processing. The reflection component estimates obtained at the three scales are weighted and summed according to specific weights to obtain the final multi-scale Retinex-enhanced image R(x,y). Multi-scale fusion can simultaneously process illumination unevenness and detail information of varying sizes in the image, resulting in more comprehensive illumination separation, enhanced detail, and improved robustness.

[0080] In some preferred embodiments, the small defect morphology enhancement process includes:

[0081] S25, performing a top-hat transformation on the polarized light image after dynamic range compression and local contrast enhancement processing to highlight tiny defects;

[0082] S26. Perform Sauvola adaptive binarization processing on the polarized light image after the top-hat transformation to segment tiny defects, so as to obtain a defect enhanced image set.

[0083] Specifically, the top-hat transform is implemented by subtracting the result of the opening operation between the image and the structural element from the image. This can remove background portions of the image that are larger than the structural element, thereby highlighting features in the image that are smaller than the structural element, helping to separate small defects from the background. The principle of Sauvola adaptive binarization processing is to calculate a local threshold based on the mean and standard deviation of the local area of ​​the image for binarization. It can adapt to changes in brightness and contrast in the local area of ​​the image, thereby achieving defect segmentation in different areas of the image. After the top-hat transform highlights small defects, Sauvola adaptive binarization processing can perform segmentation based on the local characteristics of these highlighted features.

[0084] More specifically, to address the problem of small defects being difficult to separate or segment from the background, this solution performs morphological enhancement of small defects. The top-hat transform removes larger background structures from the image, making small defects more prominent in the image. The Sauvola adaptive binarization process calculates a local threshold based on the statistical characteristics (mean and standard deviation) of the local area of ​​the image and binarizes the image based on the local threshold. Because the threshold can adapt to brightness differences and contrast changes in the local area of ​​the image, it can effectively segment small defects that stand out from the background after the top-hat transform. This results in a set of defect-enhanced images in which small defects are clearly segmented, providing input for subsequent defect detection.

[0085] In some preferred embodiments, in step S25, the top-hat transformation satisfies:

[0086] (4)

[0087] Among them, I R is the polarized light image after multi-scale Retinex enhancement, I tophat is the polarized light image after top-hat transformation, (I R oB) indicates I R The result of the open operation with the structure element B, where the structure element B is a preset structure;

[0088] In step S26, the adaptive threshold used by Sauvola adaptive binarization segmentation satisfies:

[0089] (5)

[0090] Where T(x,y) is the adaptive threshold at the coordinate (x,y), μ(x,y) is the grayscale mean of the pixels in the local window centered at the coordinate (x,y) in the polarized light image after the top-hat transformation, σ(x,y) is the grayscale standard deviation of the pixels in the local window centered at the coordinate (x,y) in the polarized light image after the top-hat transformation, and R is the grayscale dynamic range, which satisfies R=128. is the sensitivity parameter and is set to 0.2.

[0091] Specifically, the opening operation is to corrode first and then dilate, and its function is to eliminate bright structures in the image that are smaller than a specific structural element. As a result, the top-hat transformation can highlight bright features in the image that are smaller than the structural element, while suppressing the background and larger bright knots. This allows small bright features to be enhanced in the image. Sauvola adaptive binarization calculates the local threshold at each pixel in the image. The local threshold is based on the grayscale mean and standard deviation of the pixels in the window centered on the point. This threshold calculation method based on local statistical information enables the binarization process to adapt to changes in brightness and contrast in local areas of the image.

[0092] In some preferred embodiments, the polarization image set includes polarization images of the optical communication filter to be inspected in four directions;

[0093] Step S1 includes:

[0094] S11. Use a rotating polarizer and an annular LED light source to capture polarized light images of the optical communication filter to be inspected from four directions.

[0095] Specifically, the polarization image set preferably includes polarized light images taken at four specific directions: 0°, 45°, 90°, and 135°. The selection of these angles provides surface information under different polarization states. The use of a rotating polarizer in combination with an annular LED light source is a technical means to achieve the acquisition of polarized images in these four directions. The rotating polarizer is used to control the polarization direction of the incident or outgoing light, and the annular LED light source provides uniform illumination. By adjusting the angle of the rotating polarizer, images at polarization directions of 0°, 45°, 90°, and 135° can be acquired in sequence. Thus, four polarized light images corresponding to different polarization angles are obtained to form a polarization image set. By capturing images at these specific angles, the differences caused by the interaction between different polarized light and the filter surface can be utilized to enhance the contrast of certain types of defects while reducing the visibility of non-defective areas, providing effective data input for subsequent defect enhancement preprocessing and deep learning-based defect detection, thereby improving the robustness and accuracy of the detection method.

[0096] In some preferred embodiments, the multispectral preprocessing layer is used to extract and weightedly fuse the directional features of the polarized light images in the polarized image set through CNN, and the weighted fusion process satisfies:

[0097] (6)

[0098] in, is the polarized light image in the i-th direction in the defect enhanced image set; w i is the weighted weight of the i-th direction, F fusion is the fusion feature after weighted fusion processing, and the fused F fusionMulti-angle polarization information is integrated to enhance defect characteristics.

[0099] Specifically, the weighted weights are generated by learning parameters to achieve adaptive determination of the weights.

[0100] More specifically, polarized light imaging captures the polarization properties of an object's surface at different angles. Material defects or stress can cause differences in polarization response. The multispectral preprocessing layer leverages this property to extract features from images in various directions using a convolutional neural network (CNN). These features are then weighted and fused to enhance the saliency of defect areas and the robustness of defect detection.

[0101] More specifically, the above processing method integrates information by learning weights and combining information from different angles, thereby concentrating defect signals and reducing the impact of background texture.

[0102] In some preferred embodiments, the feature extraction module includes a first 3×3 convolution layer, a first separation convolution module, a second 3×3 convolution layer, a second separation convolution module and an SPP layer arranged in sequence, and the first separation convolution module and the second separation convolution module are both spectral separation convolution modules.

[0103] Specifically, the feature extraction module first performs preliminary feature processing through a 3×3 convolution layer, and then uses the spectral separation convolution module to realize the frequency-space dual-domain feature fusion. By simultaneously processing and fusing features in the spatial and frequency domains, the module can better distinguish defect features from background textures and interference textures. The use of two spectral separation convolution modules allows the network to perform deeper feature learning while maintaining dual-domain processing capabilities. The SPP layer pools features at different spatial scales, providing multi-scale feature representation, which helps capture contextual information around the defect and enhances the robustness of feature extraction to changes in defect size and position. By integrating frequency domain analysis and multi-scale pooling, the feature extraction module enhances the network's ability to extract distinguishing features in defect detection tasks, overcoming the limitations of standard convolutional feature extraction methods.

[0104] More specifically, the first spectral separation convolution module performs frequency domain-space dual-domain fusion processing on the input features to distinguish the interference texture with frequency characteristics. The second spectral separation convolution module again performs frequency domain-space dual-domain fusion to deepen the feature distinction ability, so that the feature extraction module can effectively extract features that distinguish defects from background and interference textures, solving the problem of difficulty in defect feature extraction.

[0105] In some other embodiments, the feature extraction module includes a first 3×3 convolutional layer, a spectral separation convolution module, a second 3×3 convolutional layer, a C3 module and an SPP layer arranged in sequence, or includes a first 3×3 convolutional layer, a C3 module, a second 3×3 convolutional layer, a spectral separation convolution module and an SPP layer arranged in sequence.

[0106] In some preferred embodiments, the cross-modal attention fusion module is used to use defect features as queries and background texture features as keys and values, satisfying:

[0107] (7)

[0108] Among them, QK T is the similarity between Query and Key, is the scaling factor, d is the feature dimension, and V is the feature texture. Q comes from the feature map of the small target detection branch, K and V come from the feature map of the deep semantic branch, and are the Attention fusion results.

[0109] Specifically, in this cross-modal attention fusion module, features representing defect information are used as queries, and features representing background texture information are used as keys and values. The query comes from the feature maps of the small target detection branch in the network. These feature maps usually have high resolution and contain detailed information about tiny defects. The keys and values ​​come from the feature maps of the deep semantic branch in the network. These feature maps have a large receptive field and can capture a wider range of background texture information. The attention weight is obtained by calculating the similarity between the query and the key, scaling it, and processing it with the Softmax function. That is, the attention weight is These weights reflect the degree of correlation between defect features and background texture features. The final fusion result, Attention, is obtained by applying these weights to Value. This allows the module to adjust the contribution of background texture features based on the importance of defect features, reducing the interference of background texture unrelated to the defect. The core idea is to use attention weights to weight V (deep features) and suppress background texture unrelated to Q (defect).

[0110] More specifically, this attention weight indicates the correspondence between high-resolution defect features and low-resolution background texture features. This attention weight is applied to the Value feature map, resulting in a weighted fusion feature map. In this process, background texture regions with low similarity to the defect features receive lower weights in the Value, suppressing their contribution; whereas regions associated with the defect features receive higher weights, preserving their information. Through this cross-modal attention fusion, the module can effectively distinguish and suppress the interference of multilayer film interference textures, enhancing the salience of defect features and thus improving the accuracy of defect detection.

[0111] In some preferred embodiments, the loss function used in multispectral attention fusion network training is:

[0112] ;

[0113] Among them, L yolo is the balance loss of the multi-spectral attention fusion network, pred is the prediction result, gt is the true label, DCT is discrete cosine transform, L total is the total loss, λ is a hyperparameter, ||DCT(pred)−DCT(gt)|| 2 is the mean square error between the predicted result and the true label in the frequency domain.

[0114] Specifically, the loss function consists of two parts: one is the balance loss L yolo , which is used to evaluate the accuracy of the prediction results in the spatial domain and covers the core indicators in the target detection task, which can include positioning loss, confidence loss, and classification loss; the other part is the frequency domain loss term based on discrete cosine transform (DCT), which is used to measure the difference between the prediction results and the true labels in the frequency domain. By applying DCT transform to the prediction results and the true labels, their similarity can be compared in the frequency domain. The introduction of the frequency domain loss term prompts the network to focus not only on matching in the spatial domain during training, but also to learn to generate prediction results that are closer to the true labels in frequency domain characteristics. The hyperparameter λ is used to adjust the weights of the spatial domain loss and the frequency domain loss in the total loss. It can be set according to usage requirements, and its value is preferably 0.3.

[0115] More specifically, by incorporating the mean squared error (MSE) between the predicted and true labels in the frequency domain into the loss function, the network is trained to distinguish interference texture from defect features, suppressing the interference of interference texture and better capturing the high-frequency details of tiny defects. The setting of λ balances the optimization objectives in the spatial and frequency domains, improving the network's ability to detect tiny defects in complex backgrounds.

[0116] In some preferred embodiments, the multi-scale defect detection head includes a 20x20 detection head, a 40x40 detection head, an 80x80 detection head, and a 120x120 detection head constructed based on a 1.5× downsampling branch.

[0117] Specifically, the 20x20, 40x40, and 80x80 detection heads process feature maps of different scales to detect defects of varying sizes, respectively for detecting large, medium, and small defects. To detect defects smaller than 1 μm, the optical communication filter appearance defect detection method of the present embodiment adds a 120x120 detection head constructed using a 1.5x downsampling branch. 1.5x downsampling preserves image detail and resolution. Detection on the 120x120 feature map is equivalent to having a smaller receptive field on the original image, enabling the perception and location of extremely small defects.

[0118] In some preferred embodiments, the multi-scale defect detection head is further configured to dynamically adjust the anchor frame ratio according to the statistical distribution of filter defects and / or the aspect ratio of the defect size.

[0119] Specifically, the multi-scale defect detection head can adjust the proportions of its anchor frames based on the statistical distribution of filter defects and / or the aspect ratio of the defect size. By better matching the anchor frame proportions to the actual defect shape, the detection head improves its ability to locate and identify defects of varying shapes. Adjusting the anchor frame proportions based on the statistical characteristics of the defects allows the network to converge better when predicting defect bounding boxes, thereby improving defect detection accuracy.

[0120] Second, please refer to Figure 4 Some embodiments of the present application further provide a device for detecting appearance defects of optical communication filters, the device comprising:

[0121] An acquisition module 201 is configured to acquire a set of polarization images of an optical communication filter to be tested at different polarization angles;

[0122] A preprocessing module 202 is used to preprocess the polarization image set to obtain a defect enhanced image set;

[0123] The detection module 203 is used to perform defect detection on the defect enhanced image set based on a pre-trained multispectral attention fusion network. The multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module and a multi-scale defect detection head arranged in sequence. The feature extraction module is a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module. The spectral separation convolution module includes a first convolution layer, a DCT transformation layer, an IDCT inverse transformation layer and a residual fusion layer arranged in sequence.

[0124] The optical communication filter appearance defect detection device of the present application embodiment utilizes the spectral separation convolution module in the improved YOLOv5 backbone network to fuse frequency and spatial domain information when extracting features, enhancing the perception of subtle textures and edges, helping to distinguish real defects from background textures. Simultaneously, a cross-modal attention fusion module further processes features from different polarization channels, learning and enhancing defect-related features through an attention mechanism while suppressing periodic texture interference caused by multi-layer film interference, thereby improving the network's defect recognition accuracy. Thus, the device utilizes multi-polarization information, specialized preprocessing, and a deep learning network that combines frequency-domain and spatial feature fusion with a cross-modal attention mechanism to improve the detection capability of small, low-contrast defects on optical communication filters that are affected by film texture interference, while reducing the missed detection rate.

[0125] In some preferred embodiments, the optical communication filter appearance defect detection device of the embodiment of the present application is used to execute the optical communication filter appearance defect detection method provided in the first aspect above.

[0126] Thirdly, please refer to Figure 5 Some embodiments of the present application also provide a structural diagram of an electronic device. The present application provides an electronic device, including: a processor 301 and a memory 302. The processor 301 and the memory 302 are interconnected and communicate with each other through a communication bus 303 and / or other forms of connection mechanisms (not marked). The memory 302 stores computer-readable instructions executable by the processor 301. When the electronic device is running, the processor 301 executes the computer-readable instructions to execute the method in any optional implementation of the above embodiments.

[0127] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method of any optional implementation of the above embodiment is executed. The computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0128] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0129] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0130] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0131] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.

[0132] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A method for detecting appearance defects of optical communication filters, characterized in that: The method comprises the following steps: S1. Acquire a set of polarization images of an optical communication filter to be tested at different polarization angles; S2. Preprocessing the polarization image set to obtain a defect-enhanced image set; S3. Perform defect detection on the defect-enhanced image set based on a pre-trained multispectral attention fusion network, wherein the multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module, and a multi-scale defect detection head, wherein the feature extraction module is a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module, and the spectral separation convolution module includes a first convolution layer, a DCT transformation layer, an IDCT inverse transformation layer, and a residual fusion layer, which are arranged in sequence; The cross-modal attention fusion module is used to use defect features as queries and background texture features as keys and values, satisfying: ; Among them, QK T is the similarity between Query and Key, is the scaling factor, d is the feature dimension, and V is the feature texture. Q comes from the feature map of the small target detection branch, K and V come from the feature map of the deep semantic branch, and Attention is the fusion result. The preprocessing in step S2 includes defect enhancement processing, dynamic range compression and local contrast enhancement processing, and small defect morphology enhancement processing, which are sequentially performed on the polarized light image in the polarization image set.

2. The optical communication filter appearance defect detection method according to claim 1, characterized in that: The defect enhancement process includes: S21, performing contrast-limited adaptive histogram equalization on the polarized light image in the polarized image set; S22 , performing a differential operation on the polarized light image after the contrast-limited adaptive histogram equalization processing to highlight the defect edge.

3. The optical communication filter appearance defect detection method according to claim 1, characterized in that: The dynamic range compression and local contrast enhancement processing includes: S23, performing adaptive logarithmic mapping processing on the polarized light image after the defect enhancement processing to repair overexposure and underexposure defects; S24, performing multi-scale Retinex enhancement processing on the polarized light image after the adaptive logarithmic mapping processing to separate the illumination component and the reflection component.

4. The optical communication filter appearance defect detection method according to claim 1, characterized in that: The small defect morphology enhancement process includes: S25, performing a top-hat transformation on the polarized light image after dynamic range compression and local contrast enhancement processing to highlight tiny defects; S26 , performing Sauvola adaptive binarization processing on the polarized light image after the top-hat transformation to segment tiny defects, so as to obtain the defect enhanced image set.

5. The optical communication filter appearance defect detection method according to claim 1, characterized in that: The feature extraction module includes a first 3×3 convolution layer, a first separation convolution module, a second 3×3 convolution layer, a second separation convolution module and an SPP layer arranged in sequence, and the first separation convolution module and the second separation convolution module are both the spectral separation convolution modules.

6. The optical communication filter appearance defect detection method according to claim 1, characterized in that: The multi-scale defect detection head includes a 20x20 detection head, a 40x40 detection head, an 80x80 detection head, and a 120x120 detection head constructed based on a 1.5× downsampling branch.

7. An optical communication filter appearance defect detection device, characterized in that: The device comprises: An acquisition module, configured to acquire a set of polarization images of the optical communication filter to be detected at different polarization angles; A preprocessing module, configured to preprocess the polarization image set to obtain a defect enhanced image set; A detection module, configured to perform defect detection on the defect-enhanced image set based on a pre-trained multispectral attention fusion network, wherein the multispectral attention fusion network includes a multispectral preprocessing layer, a feature extraction module, a cross-modal attention fusion module, and a multi-scale defect detection head, the feature extraction module being a YOLOv5 backbone network after replacing at least one C3 module with a spectral separation convolution module, and the spectral separation convolution module including a first convolution layer, a DCT transformation layer, an inverse IDCT transformation layer, and a residual fusion layer, which are arranged in sequence; The cross-modal attention fusion module is used to use defect features as queries and background texture features as keys and values, satisfying: ; Among them, QK T is the similarity between Query and Key, is the scaling factor, d is the feature dimension, and V is the feature texture. Q comes from the feature map of the small target detection branch, K and V come from the feature map of the deep semantic branch, and Attention is the fusion result. The preprocessing includes defect enhancement processing, dynamic range compression and local contrast enhancement processing, and small defect morphology enhancement processing, which are sequentially performed on the polarized light image in the polarization image set.

8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 6 are executed.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • An image enhancement method and system based on Lab color space and Retinex

    CN109886885A

  • Aspherical fused quartz component surface micro-defect rapid positioning method

    CN110411346A

  • Optical element surface defect detection method based on YOLOX algorithm

    CN116612106A

  • GIS internal foreign matter defect monitoring method based on improved YOLOv3

    CN119205632A

  • Super-resolution image reconstruction method, system and device based on dynamic frequency domain adaptive coding and contrast constraint optimization, and medium

    CN119863364A