Defect detection method for image protective net of air filter
Through the pix2pix style transfer model and Fourier amplitude filtering technology, combined with unsupervised methods, the problem of defect detection caused by the complex structure and reflection of air filters is solved, achieving more efficient defect detection results and better generalization capabilities. , reducing labor labeling costs.
Patent Information
- Application Number
- CN202410847236.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
AI Technical Summary
Existing image defect detection technology is difficult to effectively detect defects in the appearance of air filters, especially due to its complex three-dimensional structure, reflection and irregular texture. This causes existing algorithms to perform poorly on air filter data sets and requires a large amount of Manual annotation of defect features results in high cost and low robustness when updating the model.
Using the pix2pix style transfer model combined with Fourier amplitude filtering, the training model converts the air filter appearance image into a black and white style and performs image segmentation. Fourier filtering and generative adversarial networks are used for defect detection, and unsupervised methods are used to reduce manpower. Label the requirements, and combine the SSIM and L1 distance difference measurements to perform pixel-by-pixel difference measurement to locate defects.
It improves the segmentation effect and reconstructed detailed information of air filter appearance defect detection, reduces missed detections, improves AUROC value, has good generalization ability, saves manpower and time costs, and is suitable for emerging defects.
Smart Images

Figure CN118735884A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing, and in particular relates to a method for detecting defects of an air filter image protection net. Background Art
[0002] Appearance defect detection is an important part of quality control in air filter production. The appearance of an air filter is composed of an outer metal mesh and an inner filter material.
[0003] Most existing image defect detection technologies use supervised detection methods. Since all types of defect features need to be collected, a lot of manpower is needed to label the defect features. However, in the production process, defect features are diverse and new defect features often appear continuously. New data needs to be continuously added for training, resulting in problems such as untimely model updates, low robustness, and high costs.
[0004] The above technical problems can be avoided by using unsupervised methods. However, in the existing unsupervised method research, public unsupervised defect detection datasets are often used, which mostly contain images of aligned small objects (toothbrush heads, capsules, electronic commutators, PCB boards), or images of large objects (grids, fabrics) with relatively good imaging, or large object plane images (leather, metal, magnetic tiles). The appearance of the air filter is a three-dimensional structure with a large area, and because the materials of the outer protective net and the inner filter material are different, under sufficient light source imaging, the outer protective net is reflective and blocks the inner layer, casting shadows on the inner layer, and the imaging is mottled, and the gaps between the normal inner filter material are not uniform, forming an irregular texture, resulting in insignificant defect features. Therefore, the algorithm that performs well on the public defect detection dataset does not perform well on the air filter appearance dataset.
[0005] The appearance of air filters has a stack of inner and outer textures, which makes the overall texture more complex. Although there has been considerable research in the field of defect detection, the appearance of air filters presents unique difficulties compared to other research targets, such as objects in public defect detection datasets. Therefore, existing defect detection technologies are not suitable for air filters and cannot be directly applied.
[0006] A Chinese patent application with publication number "CN 116452578A" and invention name "Periodic Texture Image Defect Detection Method" discloses an image defect detection method, which performs defect detection on images based on Fourier amplitude filtering for defect detection on periodic texture surfaces. However, this prior art performs better only when the imaging quality is relatively good and the texture periodicity is relatively strong. It performs poorly for air filter protection nets that are reflective and have weak periodicity, and has low versatility. Summary of the invention
[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a method for detecting defects of an air filter image protection net.
[0008] The technical problem proposed by the present invention is solved in this way:
[0009] A method for detecting defects in an air filter image protection net comprises the following steps:
[0010] Step S1: training a first pix2pix style transfer model, which can assign different colors to different structures of the input air filter appearance image to present a black and white style;
[0011] Step S2: After completing the image segmentation of the outer protective net and the inner filter material of the air filter appearance image, Fourier amplitude filtering is performed to obtain a protective net filtered image; a second pix2pix style transfer model is trained to reconstruct the input protective net filtered image;
[0012] Step S3: obtaining an appearance image x of a defective air filter, and inputting it into a first pix2pix style transfer model to obtain a black-and-white style image y';
[0013] Step S4: Perform morphological opening and closing operations with a kernel of 3 on the black-and-white style image y', and then perform threshold segmentation to obtain a black-and-white label image y;
[0014] Step S5: Convert y into a 0-1 binary matrix Compare x with Multiply them to complete the image segmentation of the outer protective net and the inner filter material, and obtain the defective outer protective net image g;
[0015] Step S6: Filter the defective outer layer protection net image g using the Fourier amplitude filtering method to obtain a defective protection net filtering image h;
[0016] Step S7: input the defect protection network filter image h into the second pix2pix style transfer model to obtain a defect-free reconstruction image g' corresponding to the image g;
[0017] Step S8: Use the difference measurement method combining SSIM structural similarity and L1 distance to measure the pixel-by-pixel difference of image g and image g'. For each pixel, the two difference measurement values are weighted averaged to complete the threshold segmentation, and then the defect detection positioning map r is obtained to complete the air filter protective net defect detection.
[0018] Furthermore, the specific process of step S1 is as follows:
[0019] Step S1-1: Obtain a set of non-defective air filter appearance images X, where xi represents the appearance image of the i-th defect-free air filter, 1≤i≤N, N is the dimension of X, and the boundary of its outer protective net is marked with polygons;
[0020] Step S1-2: Generate a black and white label image set Y based on the polygon annotation results,
[0021] Step S1-3: Train a first pix2pix style transfer model using the image pair set {X, Y}.
[0022] Furthermore, the specific process of step S2 is as follows:
[0023] Step S2-1: Set y i Convert to 0-1 binary matrix y i ', x i With y i 'Multiply to complete the image segmentation of the outer protective net and the inner filter material, and obtain the normal outer protective net image g i ; Construct a normal protection network image set
[0024] Step S2-2: Use the Fourier amplitude filtering method to filter the normal protection net image set G to obtain the normal protection net filtered image set
[0025] Step S2-3: Use the image pair set {G, H} to train the second style transfer pix2pix model.
[0026] Furthermore, in step S2-2, the process of the Fourier amplitude filtering method is:
[0027] For the normal outer protective net image g i Perform a two-dimensional discrete Fourier transform to obtain a first complex matrix; compare the element amplitude of the first complex matrix with the set threshold, perform pixel operation on the first complex matrix, set the amplitude and phase of the elements in the first complex matrix whose element amplitude is less than the set threshold to zero, and obtain a second complex matrix; perform a two-dimensional discrete Fourier inverse transform on the second complex matrix to obtain the normal protection net filter image h i .
[0028] Furthermore, the threshold in step S4 adopts the pixel median.
[0029] The beneficial effects of the present invention are:
[0030] 1) The segmentation scheme combining pix2pix and image processing in the present invention is more in line with the semantic structure than the classic segmentation model U-Net, and can achieve better segmentation effects. The Pix2pix model adopts the training mechanism of the Generative Adversarial Network (GAN), and can be closer to the label effect image through adversarial training of the generator and the discriminator, while U-Net is a deterministic network based on the encoder-decoder structure and lacks the advantage of generative adversarial; Pix2pix uses adversarial loss and content loss at the same time, which can better guide the generator to generate label effect images, while U-Net only uses a single pixel-level loss function and lacks the advantage brought by adversarial loss; in this embodiment, the output of pix2pix is a grayscale image, which has higher robustness, and the noise has less effect on the output effect, and the noise can be eliminated by combining image processing later, while the output of U-Net is a binary image, and the noise has a greater impact on the output effect, and it is difficult to eliminate the noise through image processing later. Therefore, the segmentation scheme of the pix2pix model and image processing has better effect.
[0031] 2) The present invention adopts an unsupervised route, which does not require the definition and labeling of various defects, saving manpower and time costs, and is also applicable to newly emerging defects and has good generalization capabilities.
[0032] 3) Compared with the prior art, the defect-free reconstruction method combining pix2pix and Fourier amplitude filtering in the present invention has filtered out the defective components of the image by Fourier amplitude filtering before the image enters the pix2pix model. Therefore, pix2pix does not need to implement the defect removal function, while the prior art needs to remove defects while reconstructing, and some information will be lost in the process; and the pix2pix model adopts the training mechanism of generative adversarial network (GAN), which can produce more realistic images through adversarial training of the generator and the discriminator, while the prior art adopts a network with an encoder-decoder structure, which lacks the advantage of generative adversarial; therefore, the reconstruction effect of the method combining pix2pix and Fourier amplitude filtering has richer detail information, fewer missed detections, and a higher AUROC value. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic diagram of the process of the protective net defect detection method of the present invention;
[0034] Figure 2 A comparison diagram of the segmentation effect images of the method described in the prior art and the embodiment;
[0035] Figure 3 A comparison diagram of the defect original image, defect-free reconstructed image, positioning image, and defect positioning visualization image of the method described in the prior art and the embodiment;
[0036] Figure 4The appearance image of the air filter without defects and the black-and-white label image in the method described in the embodiment;
[0037] Figure 5 The normal outer layer protection net image and the normal outer layer protection net filtered image in the method described in the embodiment;
[0038] Figure 6 The defective air filter appearance image, black and white style image and black and white label image in the method described in the embodiment;
[0039] Figure 7 The defective outer layer protection net image, the defective protection net filter image and the defect-free reconstruction image in the method described in the embodiment;
[0040] Figure 8 It is a positioning map of defect detection in the method described in the embodiment. DETAILED DESCRIPTION
[0041] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0042] This embodiment provides a method for detecting defects in an air filter image protection net. Figure 1 As shown, according to the characteristics of the air filter appearance, in order to improve the prominence of defects, an algorithm is designed to split the appearance according to the deep structure, separate the outer protective net and then perform defect detection; an unsupervised solution is used, and there is no need to label the defect features.
[0043] The method described in this embodiment specifically includes the following steps:
[0044] Step S1: training the first pix2pix style transfer model P1, which can assign different colors to different structures of the air filter appearance image to present a black and white style.
[0045] Step S1-1: Obtain a set of non-defective air filter appearance images X, where x i Represents the appearance image of the i-th defect-free air filter, 1≤i≤N, N is the dimension of X, and the boundary of its outer protective net is marked with polygons.
[0046] Step S1-2: Generate a black and white label image set Y based on the polygon annotation results,
[0047] Step S1-3: Use the image pair set {X, Y} to train the first pix2pix model to obtain the model P1. The example of {X, Y} is shown in the attached figure. Figure 4 shown.
[0048] Step S2: training a second pix2pix style transfer model P2, which can generate a detailed and realistic defect-free protection net image from the protection net Fourier amplitude filter image.
[0049] Step S2-1: Set y i Convert to 0-1 binary matrix y i ', x i With y i 'Multiply to complete the image segmentation of the outer protective net and the inner filter material, and obtain the normal outer protective net image g i ; Construct a normal outer protective net image set
[0050]
[0051] Step S2-2: Use the Fourier amplitude filtering method to filter the normal outer layer protection net image set G to obtain the normal outer layer protection net filtered image set
[0052] In step S2-2, the process of the Fourier amplitude filtering method is:
[0053] For the normal outer protective net image g i Perform a two-dimensional discrete Fourier transform to obtain a first complex matrix; compare the element amplitude of the first complex matrix with the set threshold, perform pixel operation on the first complex matrix, set the amplitude and phase of the elements in the first complex matrix whose element amplitude is less than the set threshold to zero, and obtain a second complex matrix; perform a two-dimensional discrete Fourier inverse transform on the second complex matrix to obtain the normal outer layer protection net filtered image h i .
[0054] Step S2-3: Use the image pair set {G, H} to train the second pix2pix model to obtain model P2. The example of {G, H} is shown in the attached figure. Figure 5 shown.
[0055] Step S3: Obtain the appearance image x of the defective air filter, input it into the model P1, and obtain the black and white style image y'.
[0056] Step S4: Perform morphological opening and closing operations with a kernel of 3 on the black-and-white style image y', and then perform threshold segmentation (the threshold uses the pixel median) to obtain a black-and-white label image y.
[0057] Figure 6 The first image is x in this embodiment, the second image is y', and the third image is y.
[0058] Step S5: convert y into a 0-1 binary matrix y, multiply x by y, complete the image segmentation of the outer protective net and the inner filter material, and obtain the defective outer protective net image g;
[0059] Step S6: Filter the defective outer layer protection net image g using the Fourier amplitude filtering method to obtain a defective protection net filtering image h;
[0060] Step S7: input the defect protection network filter image h into the model P2 to obtain a defect-free reconstruction image g' corresponding to the image g;
[0061] Figure 7 The first image is g in this embodiment, the second image is h, and the third image is g'.
[0062] Step S8: Use the difference measurement method combining SSIM structural similarity and L1 distance to measure the pixel-by-pixel difference of image g and image g'. For each pixel, the two difference measurement values are weighted averaged to complete the threshold segmentation, and then the defect detection positioning map r is obtained, as shown in the attached figure. Figure 8 As shown, the air filter protective screen defect detection is completed.
[0063] Figure 2 From left to right are respectively an air filter appearance image, the result of image segmentation of the air filter appearance image by the prior art U-Net network, a black and white style image of the air filter appearance image input into the first pix2pix model, and a black and white label image after opening, closing and threshold segmentation of the black and white style image; by comparison, it can be seen that the method described in this embodiment can achieve better segmentation effect.
[0064] Figure 3 The first row, from left to right, respectively shows the defect original image, defect-free reconstructed image, positioning image and defect positioning visualization image in the prior art “Improving unsupervised defectsegmentation by applying structural similarity to autoencoders”; the second row, from left to right, respectively shows the defect original image, defect-free reconstructed image, positioning image and defect positioning visualization image in the method described in the present embodiment; by comparison, it can be seen that the reconstruction effect of the method described in the present embodiment has richer detail information, fewer missed detections, and a higher AUROC value.
Claims
1. A method for detecting defects in an air filter image protection net, characterized in that: The following steps are involved: Step S1: training a first pix2pix style transfer model, which can assign different colors to different structures of the input air filter appearance image to present a black and white style; Step S2: After completing the image segmentation of the outer protective net and the inner filter material of the air filter appearance image, Fourier amplitude filtering is performed to obtain a protective net filtered image; a second pix2pix style transfer model is trained to reconstruct the input protective net filtered image; Step S3: obtaining an appearance image x of a defective air filter, and inputting it into a first pix2pix style transfer model to obtain a black-and-white style image y'; Step S4: Perform morphological opening and closing operations with a kernel of 3 on the black-and-white style image y', and then perform threshold segmentation to obtain a black-and-white label image y; Step S5: Convert y into a 0-1 binary matrix Compare x with Multiply them to complete the image segmentation of the outer protective net and the inner filter material, and obtain the defective outer protective net image g; Step S6: Filter the defective outer layer protection net image g using the Fourier amplitude filtering method to obtain a defective protection net filtering image h; Step S7: input the defect protection network filter image h into the second pix2pix style transfer model to obtain a defect-free reconstruction image g' corresponding to the image g; Step S8: Use the difference measurement method combining SSIM structural similarity and L1 distance to measure the pixel-by-pixel difference of image g and image g'. For each pixel, the two difference measurement values are weighted averaged to complete the threshold segmentation, and then the defect detection positioning map r is obtained to complete the air filter protective net defect detection.
2. The method for detecting defects of an air filter image protection net according to claim 1, characterized in that: The specific process of step S1 is: Step S1-1: Obtain a set of non-defective air filter appearance images X, where x i represents the appearance image of the i-th defect-free air filter, 1≤i≤N, N is the dimension of X, and the boundary of its outer protective net is marked with polygons; Step S1-2: Generate a black and white label image set Y based on the polygon annotation results, Step S1-3: Train a first pix2pix style transfer model using the image pair set {X, Y}.
3. The method for detecting defects of an air filter image protection net according to claim 2, characterized in that: The specific process of step S2 is: Step S2-1: Set y i Convert to 0-1 binary matrix y i ', x i With y i 'Multiply to complete the image segmentation of the outer protective net and the inner filter material, and obtain the normal outer protective net image g i ; Construct a normal protection network image set Step S2-2: Use the Fourier amplitude filtering method to filter the normal protection net image set G to obtain the normal protection net filtered image set Step S2-3: Use the image pair set {G, H} to train the second style transfer pix2pix model.
4. The method for detecting defects of an air filter image protection net according to claim 3, characterized in that: In step S2-2, the process of the Fourier amplitude filtering method is: For the normal outer protective net image g i Perform a two-dimensional discrete Fourier transform to obtain a first complex matrix; compare the element amplitude of the first complex matrix with a set threshold, perform a pixel operation on the first complex matrix, set the amplitude and phase of the elements in the first complex matrix whose element amplitude is less than the set threshold to zero, and obtain a second complex matrix; Perform a two-dimensional discrete Fourier inverse transform on the second complex matrix to obtain the normal protection net filter image h i .
5. The method for detecting defects of an air filter image protection net according to claim 1, characterized in that: In step S4, the threshold value is the pixel median.
Citation Information
Cited By
Screen defect detection method and system in pharmaceutical process of pharmaceutical production line
CN121708021A
A method and system for detecting defects in screens during the pharmaceutical production process.
CN121708021B
