Metal workpiece defect detection method and system based on image difference

By employing a lightweight convolutional neural network detection method based on image difference, the problems of missed and false detections in metal workpiece defect detection under complex lighting and strong reflective environments are solved, achieving efficient and real-time detection of minute defects, which is suitable for high-precision detection of metal workpieces.

CN120992658AActive Publication Date: 2025-11-21JILIN UNIVERSITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511516425.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2025-11-21
Estimated Expiration
2045-10-23

AI Technical Summary

Technical Problem

Existing methods for detecting defects in metal workpieces are prone to missed or false detections under complex lighting and strong reflective environments, making it difficult to capture minute defects such as microcracks. Furthermore, traditional algorithm parameters require frequent optimization, lack versatility, and involve large computational loads, making it difficult to achieve real-time operation and online adaptation on resource-constrained devices such as embedded GPUs or FPGAs.

Method used

A lightweight convolutional neural network based on image difference is adopted. The image to be inspected and the normal reference image are preprocessed and pixel-level absolute difference operation is performed to generate a difference image. This difference image is then concatenated with the original image along the channel direction to form a multi-channel input tensor. Combined with the defect probability heat map output by the lightweight convolutional neural network, coarse localization and fine segmentation are performed, noise is filtered, and an accurate defect mask is obtained.

Benefits of technology

It improves the accuracy and robustness of defect detection in metal workpieces, enabling accurate location and segmentation of minute defects in complex environments. It is suitable for efficient, real-time detection of industrial products such as metal sheets and parts, while reducing equipment costs and computing resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120992658A_ABST
    Figure CN120992658A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of machine vision and industrial detection, and provides a metal workpiece defect detection method and system based on image difference, and the method comprises the following steps: collecting a to-be-detected image and a normal reference image, carrying out the preprocessing of the to-be-detected image and the normal reference image, and then carrying out the pixel-level absolute difference operation, and generating a difference image; splicing the to-be-detected image, the normal reference image and the differential image to form a multi-channel input tensor, then inputting the multi-channel input tensor into a lightweight convolutional neural network, outputting a defect probability thermodynamic diagram, and determining a coarse positioning mask; performing connected domain analysis on the coarse positioning mask, and filtering noise to obtain a candidate defect region; performing fine segmentation on the candidate defect area to obtain an accurate defect mask; and overlapping and displaying the candidate defect area and the accurate defect mask on the original to-be-detected image to obtain a detection result. According to the method, the difference information of the normal reference image and the to-be-detected image is combined, and the fine segmentation network is introduced, so that the detection precision and robustness are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of machine vision and industrial inspection technology, and particularly relates to a method and system for detecting defects in metal workpieces based on image difference. Background Technology

[0002] In the metal processing and manufacturing industry, accurate detection of metal surface defects plays a crucial role in ensuring product quality and production safety. Current metal surface defect detection technologies primarily rely on manual visual inspection, non-destructive testing, traditional machine vision algorithms, or end-to-end deep learning segmentation networks. However, with the development of manufacturing automation and precision, traditional manual inspection methods can no longer meet the demands of high-speed, high-precision, and high-consistency modern industrial inspection, making automated visual inspection technology increasingly mainstream. Especially in the continuous production of metal sheets and parts, the presence of minute defects such as scratches, pores, indentations, peeling, and pits on the surface often directly determines the product's usability and grade. However, in real-world industrial scenarios, factors such as material reflection, complex textures, lighting variations, and oil occlusion often present challenges to metal surface inspection, including complex backgrounds, inconspicuous defects, and blurred boundaries. Ordinary image processing methods or traditional single-frame image-based defect detection techniques often struggle to provide stable responses under high-resolution or high-speed inspection requirements. Detection accuracy drops significantly, especially when dealing with small-scale, irregularly shaped, or low-contrast defects.

[0003] In summary, existing methods for detecting defects in metal workpieces are not only inefficient, highly dependent on operator experience, and costly, but also prone to missed or false detections in complex lighting and strong reflective environments, making it difficult to capture minute defects such as microcracks. Traditional algorithm parameters require frequent optimization and lack versatility. Large-scale deep learning models require a large amount of computation, making it difficult to achieve real-time operation and online adaptation on resource-constrained industrial edge devices such as embedded GPUs or FPGAs.

[0004] Therefore, developing a defect detection method based on reference image difference analysis is key to solving the above problems. Summary of the Invention

[0005] The purpose of this invention is to provide a method for detecting defects in metal workpieces based on image difference, thereby solving the aforementioned technical problems.

[0006] This invention is implemented as follows: a method for detecting defects in metal workpieces based on image difference, comprising the following steps: Acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and preprocess both images. Pixel-level absolute difference operations are performed on the preprocessed image to be inspected and the normal reference image to generate a difference image; The image to be inspected, the normal reference image, and the difference image are stitched together along the channel direction to form a multi-channel input tensor; The multi-channel input tensor is fed into a lightweight convolutional neural network, which outputs a defect probability heatmap and obtains a coarse localization mask based on the defect probability heatmap. Connectivity analysis is performed on the coarse positioning mask, and noise is filtered based on the area threshold method to obtain candidate defect regions; Based on multi-scale contextual information, the candidate defect region is finely segmented to obtain an accurate defect mask; The candidate defect region and the precise defect mask are superimposed on the original image to be inspected to obtain the detection result.

[0007] Furthermore, the preprocessing methods include uniform size scaling and pixel normalization.

[0008] Furthermore, the formula for pixel-level absolute difference calculation is as follows: ; In the formula, (x,y) represents pixels; The image to be inspected; This is a normal reference image; This is a difference image.

[0009] Furthermore, before the step of stitching the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor, the method further includes: performing Gaussian blur processing on the difference image.

[0010] Furthermore, the formula for Gaussian blur processing is: ; ; In the formula, (x,y) represents pixels; The difference image after Gaussian blurring; This is the original difference image; For Gaussian kernel; To control the degree of ambiguity, The larger the size, the stronger the blurriness.

[0011] Furthermore, the steps of inputting the multi-channel input tensor into a lightweight convolutional neural network, outputting a defect probability heatmap, and obtaining a coarse localization mask based on the defect probability heatmap specifically include: Based on a lightweight convolutional neural network, a defect probability heatmap is output by taking a multi-channel input tensor as input; the brightness intensity in the defect probability heatmap represents the probability that a pixel is a defect. After upsampling the defect probability heatmap, a coarse location mask is generated by binarizing it using the first threshold.

[0012] Furthermore, the formula for generating the coarse positioning mask is: ; In the formula, (x,y) represents pixels; This represents the probability value of the corresponding pixel in the defect probability heatmap. The first threshold; For coarse positioning mask; when This indicates an area where defects may exist; when , indicating the background area or a normal, defect-free area.

[0013] Furthermore, the steps for performing connected component analysis on the coarse localization mask and filtering noise based on the area threshold method to obtain candidate defect regions are as follows: Connectivity analysis is performed on the coarse location mask to extract all connected regions and enclose them with the minimum bounding rectangle. If the area is less than the second threshold, it is considered noise and is removed. The remaining part is output as a set of candidate defect regions in the form of the minimum bounding rectangle.

[0014] Furthermore, based on multi-scale contextual information, the candidate defect region is finely segmented to obtain an accurate defect mask. This process specifically includes: Adaptive average pooling of different sizes and upsampling are performed on candidate defect regions to obtain multi-scale features; Multi-scale features are concatenated with the original features and then fused through convolution to obtain a pixel-level defect probability map; After normalizing the pixel-level defect probability map, binarization is performed to obtain the accurate defect mask.

[0015] Another object of the present invention is to provide a metal workpiece defect detection system based on image difference, for implementing the above-mentioned metal workpiece defect detection method, comprising: The image acquisition and preprocessing module is used to acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and to preprocess both of them. The differential image generation module is used to perform pixel-level absolute difference operations on the preprocessed image to be inspected and the normal reference image to generate a differential image. The image stitching module is used to stitch the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor; The coarse defect localization module is used to input multi-channel input tensors into a lightweight convolutional neural network, output a defect probability heatmap, and obtain a coarse localization mask based on the defect probability heatmap. The candidate region extraction module is used to perform connected component analysis on the coarse positioning mask, filter noise based on the area threshold method, and obtain candidate defect regions. The fine segmentation module is used to perform fine segmentation of candidate defect regions based on multi-scale context information to obtain accurate defect masks; The results visualization module is used to overlay candidate defect regions and precise defect masks onto the original image to be inspected, thereby obtaining the detection results.

[0016] The present invention provides a method for detecting defects in metal workpieces based on image difference. This method combines the difference information between a normal reference image and the image to be inspected, and introduces a fine segmentation network, effectively improving detection accuracy and robustness. This method can be widely applied to the surface quality inspection of industrial products such as metal sheets, parts, and precision devices, and is particularly suitable for detecting complex surfaces and small defects. Attached Figure Description

[0017] Figure 1 This is a schematic flowchart of the image difference-based defect detection method for metal workpieces provided in an embodiment of the present invention.

[0018] Figure 2 This is a schematic diagram of the structure of a metal workpiece defect detection system based on image difference provided in an embodiment of the present invention.

[0019] Figure 3 This is a schematic diagram illustrating the detection of defective images in practical applications.

[0020] Figure 4 This is an exemplary diagram of the metal workpiece defect detection system provided in this embodiment of the invention in actual metal workpiece defect detection.

[0021] Figure 5 This is another exemplary figure illustrating the metal workpiece defect detection system provided in this embodiment of the invention in actual metal workpiece defect detection. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0023] In modern mechanical manufacturing production lines, the problem of locating, segmenting, and real-time detecting surface defects on metal workpieces under complex backgrounds and lighting interference conditions is addressed. This invention proposes a lightweight, multi-stage detection method driven by differential features between normal and defective images. This method combines differential feature contrast learning, pixel-level fine segmentation using an integrated pyramid pooling (PSP) module, channel and spatial attention mechanisms to suppress reflective interference, and a lightweight online fine-tuning strategy. This approach can both magnify and accurately locate minute defects, and adapt to different workpieces and surface processes while maintaining a high frame rate. Therefore, it meets the demands of modern industrial production lines for automated, high-precision, and low-latency detection of metal surface defects.

[0024] Specifically, such as Figure 1 As shown, in one embodiment of the present invention, a method for detecting defects in metal workpieces based on image difference is provided, comprising the following steps: S100: Acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and preprocess both. S200: Perform pixel-level absolute difference operation on the preprocessed image to be inspected and the normal reference image to generate a difference image; S300: The image to be inspected, the normal reference image, and the difference image are stitched together along the channel direction to form a multi-channel input tensor; S400. Input the multi-channel input tensor into a lightweight convolutional neural network, output a defect probability heatmap, and obtain a coarse localization mask based on the defect probability heatmap. S500. Perform connected component analysis on the coarse positioning mask, filter noise based on the area threshold method, and obtain candidate defect regions. S600: Based on multi-scale contextual information, the candidate defect region is finely segmented to obtain an accurate defect mask; S700: The candidate defect region and the precise defect mask are superimposed and displayed on the original image to be inspected to obtain the detection result.

[0025] In this embodiment of the invention, a normal image under the same product manufacturing conditions is used as a reference image, and the image to be inspected is subjected to pixel-level differential processing to highlight potential defect areas. This differential mechanism essentially constructs a "contrast enhancement mechanism," which effectively improves the accuracy and robustness of defect detection without relying on a large number of samples for training. Simultaneously, in conjunction with subsequent image segmentation algorithms and target tracking techniques, automatic identification and tracking of defective targets are achieved.

[0026] Furthermore, the method provided in this invention is not only widely applicable to metal surface defect detection, but also suitable for other industrial vision fields that detect minute anomalies on the surfaces of stable structures, such as the manufacturing and inspection processes for ceramics, circuit boards, and plastic products. Its technical mechanism possesses high scalability and system integration capabilities, providing a feasible path and crucial support for achieving efficient, accurate, and real-time industrial defect detection.

[0027] In a preferred embodiment of the present invention, the preprocessing method includes, but is not limited to, uniform size scaling and pixel normalization.

[0028] Specifically, in step S100, when the metal workpiece enters the inspection area, an industrial camera (or a high-resolution camera) can acquire in real time an image of the metal workpiece surface (i.e., the image to be inspected) and a corresponding defect-free normal reference image (which can be a similar reference image or a model reconstruction image). Under the premise of ensuring consistent acquisition resolution and lighting conditions, both images can be preprocessed uniformly, including size scaling (e.g., 256×256 pixels) and pixel normalization, thereby removing interference caused by brightness fluctuations and equipment differences, improving image quality, and providing standardized input for subsequent algorithms.

[0029] In a preferred embodiment of the present invention, the formula for pixel-level absolute difference calculation is as follows: ; In the formula, (x,y) represents pixels; The image to be inspected; This is a normal reference image; This is a difference image.

[0030] By performing pixel-level absolute difference processing on the preprocessed image, defect features can be highlighted, enabling the network to simultaneously perceive the original texture and minute changes, thereby improving its sensitivity to minute cracks and pits. The difference image obtained in this embodiment of the invention can effectively highlight the minute differences between the two in terms of surface texture, brightness, and detail, and it has a particularly good response to surface pits, scratches, and other detail anomalies.

[0031] In a preferred embodiment of the present invention, before the step of stitching the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor, the method further includes: performing Gaussian blur processing on the difference image.

[0032] Specifically, the formula for Gaussian blur processing is: ; ; In the formula, The difference image after Gaussian blurring; For Gaussian kernel; To control the degree of ambiguity, The larger the size, the stronger the blurriness.

[0033] In step 300, the normal reference image, the image to be inspected, and their differential images are stitched together along the R, B, and G channels, respectively, to form a three-channel input tensor that is then fed into the subsequent model. This method ensures that the model can simultaneously receive information about the overall appearance of the workpiece and details of defect changes, thereby improving recognition accuracy.

[0034] It is worth noting that in metal surface defect detection tasks, the original differential images often contain small-scale noise fluctuations (such as dust, texture, and light reflection) and pixel-level errors caused by image precision. These subtle interferences can easily be confused with real defects. Therefore, directly binarizing the original differential image often leads to misjudgment or missed detection. This invention, by first introducing Gaussian blur to process the differential image and then stitching it with a normal reference image and the image to be inspected, can suppress noise and pixel-level alignment errors.

[0035] In a preferred embodiment of the present invention, the steps of inputting a multi-channel input tensor into a lightweight convolutional neural network, outputting a defect probability heatmap, and obtaining a coarse localization mask based on the defect probability heatmap specifically include: Based on a lightweight convolutional neural network, a defect probability heatmap is output by taking a multi-channel input tensor as input; the brightness intensity in the defect probability heatmap represents the probability that a pixel is a defect. After upsampling the defect probability heatmap, a coarse location mask is generated by binarizing it using the first threshold.

[0036] It should be noted that after the multi-channel input tensor is fed into the lightweight convolutional neural network, the network outputs a low-resolution defect probability heatmap. This heatmap can be enlarged to its original resolution using bilinear interpolation and binarized according to a threshold to obtain a coarse localization mask covering all potential defect regions.

[0037] Specifically, the formula for generating the coarse positioning mask is: ; In the formula, This represents the probability value of the corresponding pixel in the defect probability heatmap. The first threshold is an adjustable parameter used to control the sensitivity of coarse positioning. For coarse positioning mask; when This indicates an area where defects may exist; when , indicating the background area or a normal, defect-free area.

[0038] In a preferred embodiment of the present invention, the step of performing connected component analysis on the coarse positioning mask and filtering noise based on the area threshold method to obtain candidate defect regions specifically includes: Connectivity analysis is performed on the coarse location mask to extract all connected regions and enclose them with the minimum bounding rectangle. If the area is less than the second threshold, it is considered noise and is removed. The remaining part is output as a set of candidate defect regions in the form of the minimum bounding rectangle.

[0039] In this embodiment of the invention, by performing connected component analysis on the coarse positioning mask, areas smaller than a preset minimum value (i.e., the second threshold A) are eliminated. min , which is an adjustable parameter used to adjust the stringency of candidate region selection based on the noise level in the actual scene, is used to filter noise specks. The remaining connected components are output as a set of candidate defect boxes in the form of minimum bounding rectangles. This step effectively filters background impurities and minor artifacts, locking in key areas for subsequent fine segmentation.

[0040] In a preferred embodiment of the present invention, the step of finely segmenting the candidate defect region based on multi-scale context information to obtain an accurate defect mask specifically includes: Adaptive average pooling of different sizes and upsampling are performed on candidate defect regions to obtain multi-scale features; Multi-scale features are concatenated with the original features and then fused through convolution to obtain a pixel-level defect probability map; After normalizing the pixel-level defect probability map, binarization is performed to obtain the accurate defect mask.

[0041] In this embodiment of the invention, after the candidate defect region is cropped, it is fed into a fine-grained segmentation network. This fine-grained segmentation network employs a multi-scale context fusion strategy: it performs different convolutions or pooling operations such as 1×1, 3×3, and 5×5, concatenates features at each scale, and then fuses them through convolution to extract rich edge and texture information. The output pixel-level defect probability map can be normalized using the Sigmoid function before being processed using the aforementioned first threshold. By performing binarization, a precise defect mask at the pixel level can be obtained, which can then effectively outline the edge and shape of the defect.

[0042] In step S700, the candidate defect region (candidate box) and the precise defect mask are superimposed onto the original image to be inspected, enabling real-time interface display. The method provided by this embodiment supports exporting detection results in the form of images, coordinate lists, or alarm events, and can be interfaced with industrial control systems to meet the needs of online monitoring, immediate response, and subsequent quality tracking.

[0043] In another embodiment of the present invention, an image difference-based metal workpiece defect detection system is also provided for implementing the above-described metal workpiece defect detection method, comprising: The image acquisition and preprocessing module 10 is used to acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and to preprocess both of them. The differential image generation module 20 is used to perform pixel-level absolute difference operations on the preprocessed image to be inspected and the normal reference image to generate a differential image. The image stitching module 30 is used to stitch the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor; The coarse defect localization module 40 is used to input multi-channel input tensors into a lightweight convolutional neural network, output a defect probability heatmap, and obtain a coarse localization mask based on the defect probability heatmap. The candidate region extraction module 50 is used to perform connected component analysis on the coarse positioning mask, filter noise based on the area threshold method, and obtain candidate defect regions. The fine segmentation module 60 is used to perform fine segmentation of candidate defect regions based on multi-scale context information to obtain accurate defect masks; The result visualization module 70 is used to overlay the candidate defect region and the precise defect mask on the original image to be inspected to obtain the detection result.

[0044] In practical applications, the final detection results output by the method and system provided in this invention are superimposed on the original image to be inspected in the form of a red box (rectangle) and a red defect mask. The system can display the detection results in real time and supports exporting defect maps, mask maps, coordinate data, etc., for use in production line alarms, statistics, or automatic rejection equipment linkage control. For example, when using the above-mentioned metal workpiece defect detection method to detect an image to be inspected with defects, the output precise defect mask and detection results with candidate defect areas are as follows: Figure 3 As shown in the figure. Additionally, an exemplary figure of the detection results of the above-mentioned metal workpiece defect detection system in actual metal workpiece defect detection is shown in the figure below. Figure 4 and Figure 5 As shown in the figure, the left image is the normal reference image, and the right image is the output detection result.

[0045] In summary, the embodiments of this invention, by introducing a differential image comparison mechanism (pixel differences between a normal reference image and the image to be inspected), significantly enhance the sensitivity to minute defects, effectively highlight defect areas, and reduce background interference and false detection rates. For scenarios with complex textures and changing backgrounds, differential enhancement enables the model to focus on the actual defect areas, improving defect detection accuracy and interpretability.

[0046] The embodiments of this invention perform coarse detection in the first stage, which can quickly locate candidate defect areas, significantly reducing the computational resources and time required for subsequent fine processing. This makes it suitable for deployment in edge or production line real-time inspection systems. It is applicable to surface defect identification of various metal types (such as aluminum plates, stainless steel, die castings, etc.) and possesses good versatility and scalability.

[0047] Furthermore, the embodiments of this invention use fixed camera capture combined with normal image references, eliminating the need for large-scale sample training and complex modeling, resulting in flexible deployment and low training costs. It can be seamlessly integrated with industrial image acquisition systems, inspection terminals, and other modules, adapting to the high-efficiency requirements of production lines, online inspection, and other scenarios.

[0048] It should be noted that each of the above modules can be implemented as a computer program, which can run on a computer device. The computer device's memory can store the computer program that makes up each module, enabling the processor to execute each step of the above method.

[0049] It should be understood that although the steps in the flowcharts of the various embodiments of the present invention are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the various embodiments may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.

[0050] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Furthermore, any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory.

[0051] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. A method for detecting defects in metal workpieces based on image difference, characterized in that, Includes the following steps: Acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and preprocess both images. Pixel-level absolute difference operations are performed on the preprocessed image to be inspected and the normal reference image to generate a difference image; The image to be inspected, the normal reference image, and the difference image are stitched together along the channel direction to form a multi-channel input tensor; The multi-channel input tensor is fed into a lightweight convolutional neural network, which outputs a defect probability heatmap and obtains a coarse localization mask based on the defect probability heatmap. Connectivity analysis is performed on the coarse positioning mask, and noise is filtered based on the area threshold method to obtain candidate defect regions; Based on multi-scale contextual information, the candidate defect region is finely segmented to obtain an accurate defect mask; The candidate defect region and the precise defect mask are superimposed on the original image to be inspected to obtain the detection result.

2. The method for detecting defects in metal workpieces based on image difference according to claim 1, characterized in that, Preprocessing methods include uniform size scaling and pixel normalization.

3. The method for detecting defects in metal workpieces based on image difference according to claim 1, characterized in that, The formula for pixel-level absolute difference calculation is as follows: ; In the formula, (x,y) represents pixels; The image to be inspected; This is a normal reference image; This is a difference image.

4. The method for detecting defects in metal workpieces based on image difference according to claim 1 or 3, characterized in that, Before the step of stitching the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor, the method further includes: performing Gaussian blur processing on the difference image.

5. The method for detecting defects in metal workpieces based on image difference according to claim 4, characterized in that, The formula for Gaussian blur processing is: ; ; In the formula, (x,y) represents pixels; The difference image after Gaussian blurring; This is the original difference image; For Gaussian kernel; To control the degree of ambiguity, The larger the size, the stronger the blurriness.

6. The method for detecting defects in metal workpieces based on image difference according to claim 1, characterized in that, The steps of feeding a multi-channel input tensor into a lightweight convolutional neural network, outputting a defect probability heatmap, and obtaining a coarse localization mask based on the defect probability heatmap specifically include: Based on a lightweight convolutional neural network, a defect probability heatmap is output by taking a multi-channel input tensor as input; the brightness intensity in the defect probability heatmap represents the probability that a pixel is a defect. After upsampling the defect probability heatmap, a coarse location mask is generated by binarizing it using the first threshold.

7. The method for detecting defects in metal workpieces based on image difference according to claim 6, characterized in that, The formula for generating the coarse positioning mask is: ; In the formula, (x,y) represents pixels; This represents the probability value of the corresponding pixel in the defect probability heatmap. The first threshold; For coarse positioning mask; when This indicates an area where defects may exist; when , indicating the background area or a normal, defect-free area.

8. The method for detecting defects in metal workpieces based on image difference according to claim 1, characterized in that, The steps for performing connected component analysis on the coarse localization mask and filtering noise based on the area threshold method to obtain candidate defect regions are as follows: Connectivity analysis is performed on the coarse localization mask to extract all connected regions and enclose them with the minimum bounding rectangle. If the area is less than the second threshold, it is considered noise and is removed. The remaining part is output as a set of candidate defect regions in the form of the minimum bounding rectangle.

9. The method for detecting defects in metal workpieces based on image difference according to claim 1, characterized in that, The steps for finely segmenting candidate defect regions based on multi-scale contextual information to obtain accurate defect masks specifically include: Adaptive average pooling of different sizes and upsampling are performed on candidate defect regions to obtain multi-scale features; Multi-scale features are concatenated with the original features and then fused through convolution to obtain a pixel-level defect probability map; After normalizing the pixel-level defect probability map, binarization is performed to obtain the accurate defect mask.

10. A metal workpiece defect detection system based on image difference, used to implement the metal workpiece defect detection method according to any one of claims 1-9, characterized in that, include: The image acquisition and preprocessing module is used to acquire the image of the metal workpiece to be inspected and the corresponding normal reference image without defects, and to preprocess both of them. The differential image generation module is used to perform pixel-level absolute difference operations on the preprocessed image to be inspected and the normal reference image to generate a differential image. The image stitching module is used to stitch the image to be inspected, the normal reference image, and the difference image along the channel direction to form a multi-channel input tensor; The coarse defect localization module is used to input multi-channel input tensors into a lightweight convolutional neural network, output a defect probability heatmap, and obtain a coarse localization mask based on the defect probability heatmap. The candidate region extraction module is used to perform connected component analysis on the coarse positioning mask, filter noise based on the area threshold method, and obtain candidate defect regions. The fine segmentation module is used to perform fine segmentation of candidate defect regions based on multi-scale context information to obtain accurate defect masks; The results visualization module is used to overlay candidate defect regions and precise defect masks onto the original image to be inspected, thereby obtaining the detection results.

Citation Information

Patent Citations

  • Intelligent detection method for machining process of automobile decorative plate

    CN119919400A

  • Display screen defect image synthesis method of hybrid network model

    CN120612292A

  • Container bottom plate surface defect intelligent detection method based on deep learning

    CN120635066A

  • Artificial intelligence image segmentation processing method and device, equipment and medium

    CN120782796A

  • Method for analyzing minor defect based on progressive segmentation network

    US20230298152A1