A metal workpiece defect detection method and system based on image difference
By using a lightweight convolutional neural network detection method based on image difference, the problems of low efficiency and real-time detection of existing metal workpiece detection methods and resource-constrained equipment are solved. This method achieves high-precision and low-latency metal workpiece defect detection and is suitable for detecting minute defects on complex surfaces such as metal sheets and parts.
Patent Information
- Application Number
- CN202511516425.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2045-10-23
AI Technical Summary
Existing methods for detecting defects in metal workpieces are inefficient, highly dependent on operator experience, and costly to use. They are 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. Furthermore, large-scale depth models are difficult to implement in real-time operation and online adaptation on resource-constrained industrial edge devices.
A lightweight convolutional neural network detection method based on image difference is adopted. The method involves acquiring the image to be inspected and a normal reference image, preprocessing them, performing pixel-level absolute difference operations to generate a difference image, and then concatenating it with the original image before inputting it into the lightweight convolutional neural network. Combined with multi-scale contextual information, fine segmentation is performed, and a defect probability heatmap and mask are output to remove noise and achieve high-precision defect detection.
It improves the accuracy and robustness of detection, effectively identifies minute defects in complex backgrounds, reduces the demand for computing resources, and is suitable for real-time detection on resource-constrained devices such as embedded GPUs or FPGAs, thus reducing the false detection rate and the missed detection rate.
Smart Images

Figure CN120992658B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of machine vision and industrial detection, and particularly relates to a metal workpiece defect detection method and system based on image difference. BACKGROUND
[0002] In the metal processing and manufacturing industry, accurate detection of metal surface defects is crucial for ensuring product quality and production safety. Existing metal surface defect detection techniques mainly rely on manual visual inspection, non-destructive testing, traditional machine vision algorithms, or end-to-end deep learning segmentation networks. With the development of manufacturing automation and precision, traditional manual detection methods have been unable to meet the needs of modern industrial detection with high speed, high precision, and high consistency. Automated visual inspection technology has gradually become the mainstream. In particular, in the continuous production process of metal plates and parts, the presence of small defects such as scratches, pores, indentations, peeling, and pits on the surface often directly determines the usability and factory grade of the product. However, in industrial practical scenarios, factors such as material reflection, complex texture, light variation, and oil obstruction often make the detection of metal surfaces challenging due to complex backgrounds, non-significant defects, and blurred boundaries. Ordinary image processing methods or traditional defect detection methods based on single-frame images often struggle to respond stably under high-resolution or high-speed detection requirements. Especially when facing small-scale, irregular-shaped, or low-contrast defects, the detection accuracy significantly decreases.
[0003] In summary, existing metal workpiece defect detection methods are not only inefficient, highly dependent on operator experience, and costly, but also prone to missed detection and false detection in complex lighting and strong reflection environments, making it difficult to capture subtle defects such as micro-cracks. Traditional algorithms require frequent parameter tuning and lack universality. Large deep models have high computational complexity, making it difficult to implement 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 crucial to solving the above problems. SUMMARY
[0005] The present application aims to provide a metal workpiece defect detection method based on image difference, which aims to solve the above technical problems.
[0006] The present application is implemented as follows: a metal workpiece defect detection method based on image difference, comprising the following steps:
[0007] Collecting the detection image of the metal workpiece to be detected and the corresponding normal reference image without defects, and pre-processing both images;
[0008] performing pixel-level absolute difference operation on the preprocessed image to be inspected and the normal reference image to generate a difference image;
[0009] 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;
[0010] inputting the multi-channel input tensor into the lightweight convolutional neural network to output a defect probability heat map, and obtaining a coarse positioning mask according to the defect probability heat map;
[0011] performing connected domain analysis on the coarse positioning mask, filtering noise based on an area threshold method to obtain a candidate defect region;
[0012] performing fine segmentation on the candidate defect region based on multi-scale context information to obtain an accurate defect mask;
[0013] superimposing the candidate defect region and the accurate defect mask on the original image to be inspected to obtain a detection result.
[0014] Further, the preprocessing method includes uniform size scaling and pixel normalization.
[0015] Further, the formula of the pixel-level absolute difference operation is as follows:
[0016] ;
[0017] wherein (x, y) is a pixel; is the image to be inspected; is the normal reference image; is the difference image.
[0018] Further, 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, it further includes: performing Gaussian blur processing on the difference image.
[0019] Further, the formula of the Gaussian blur processing is as follows:
[0020] ;
[0021] ;
[0022] wherein (x, y) is a pixel; is the difference image after Gaussian blur; is the original difference image; is the Gaussian kernel; is the control blur degree, the greater the blur is.
[0023] Further, the multi-channel input tensor is input to the lightweight convolutional neural network, and a defect probability heat map is output, and a coarse positioning mask is obtained according to the defect probability heat map, and the step specifically comprises:
[0024] Based on the lightweight convolutional neural network, a multi-channel input tensor is input, and a defect probability heat map is output; the brightness intensity in the defect probability heat map represents the probability that the pixel is a defect;
[0025] After the defect probability heat map is up-sampled, the first threshold is used for binaryzation processing, and a coarse positioning mask is generated.
[0026] Further, the generation formula of the coarse positioning mask is:
[0027] ;
[0028] In the formula, (x, y) is a pixel; is the probability value of the corresponding pixel point in the defect probability heat map; is the first threshold; is the coarse positioning mask; when , it represents a region where a defect may exist; when , it represents a background region or a normal defect-free region.
[0029] Further, the step of performing connected domain analysis on the coarse positioning mask and filtering noise based on an area threshold method to obtain a candidate defect region specifically comprises:
[0030] The connected domain analysis is performed on the coarse positioning mask, all connected regions are extracted and surrounded by the minimum bounding rectangle, if the area is less than the second threshold, it is considered as noise and removed, and the remaining part is output in the form of the minimum bounding rectangle as a candidate defect region set.
[0031] Further, the step of performing fine segmentation on the candidate defect region based on multi-scale context information to obtain an accurate defect mask specifically comprises:
[0032] The adaptive average pooling of different sizes is performed on the candidate defect region and up-sampling is performed, and multi-scale features are obtained;
[0033] The multi-scale features and the original features are spliced, and convolution fusion is performed to obtain a pixel-level defect probability map;
[0034] After the pixel-level defect probability map is normalized, binaryzation processing is performed to obtain an accurate defect mask.
[0035] Another object of the present application is to provide a metal workpiece defect detection system based on image difference, which is used to realize the metal workpiece defect detection method, and comprises:
[0036] An image acquisition and preprocessing module is configured to acquire a to-be-inspected image of a metal workpiece to be inspected and a normal reference image corresponding to no defects, and to preprocess the two images;
[0037] A difference image generation module is configured to perform pixel-level absolute difference operation on the preprocessed to-be-inspected image and the normal reference image to generate a difference image;
[0038] An image splicing module is configured to splice the to-be-inspected image, the normal reference image and the difference image along a channel direction to form a multi-channel input tensor;
[0039] A defect coarse positioning module is configured to input the multi-channel input tensor into a lightweight convolutional neural network to output a defect probability heat map, and to obtain a coarse positioning mask according to the defect probability heat map;
[0040] A candidate region extraction module is configured to perform connected domain analysis on the coarse positioning mask, filter noise based on an area threshold method, and obtain a candidate defect region;
[0041] A fine segmentation module is configured to perform fine segmentation on the candidate defect region based on multi-scale context information to obtain an accurate defect mask;
[0042] A result visualization module is configured to superimpose and display the candidate defect region and the accurate defect mask on the original to-be-inspected image to obtain a detection result.
[0043] The metal workpiece defect detection method based on image difference provided by the present application combines the difference information of the normal reference image and the to-be-inspected image, and introduces a fine segmentation network, which effectively improves the detection accuracy and robustness. The method can be widely applied to the surface quality inspection link of industrial products such as metal plates, parts and precision devices, and is especially suitable for detection tasks with complex surfaces and small defects. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 The flowchart of the metal workpiece defect detection method based on image difference provided by the present application is shown.
[0045] Figure 2 The structure diagram of the metal workpiece defect detection system based on image difference provided by the present application is shown.
[0046] Figure 3 The schematic diagram of detecting the to-be-inspected image with defects in actual application is shown.
[0047] Figure 4 The exemplary diagram of the metal workpiece defect detection system in actual metal workpiece defect detection provided by the present application is shown.
[0048] Figure 5Another exemplary diagram of the metal workpiece defect detection system provided by the embodiments of the present application in actual metal workpiece defect detection. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical scheme and advantages of the present application more clear, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0050] In modern mechanical manufacturing production lines, the positioning, segmentation and real-time detection of metal workpiece surface defects under complex background and light interference conditions are problems. The embodiments of the present application propose a lightweight multi-stage detection method based on normal and defect image difference feature driving, which combines difference feature contrast learning, pixel-level fine segmentation of integrated pyramid pooling (PSP) module, channel and spatial attention mechanism to suppress reflection interference, and lightweight online fine-tuning strategy, which can not only magnify and accurately locate small defects, but also adapt to different workpiece and surface process switching while maintaining high frame rate, thereby meeting the needs of modern industrial pipeline for metal surface defect automation, high precision and low delay detection.
[0051] Specifically, as shown in the drawings, in one embodiment of the present application, a metal workpiece defect detection method based on image difference is provided, comprising the following steps: Figure 1
[0052] S100, collecting the to-be-detected image of the metal workpiece to be detected and the corresponding normal reference image without defects, and pre-processing both;
[0053] S200, performing pixel-level absolute difference operation on the pre-processed to-be-detected image and the normal reference image to generate a difference image;
[0054] S300, splicing the to-be-detected image, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor;
[0055] S400, inputting the multi-channel input tensor into a lightweight convolutional neural network to output a defect probability heat map, and obtaining a coarse positioning mask according to the defect probability heat map;
[0056] S500, performing connected domain analysis on the coarse positioning mask, filtering noise based on the area threshold method, and obtaining a candidate defect region;
[0057] S600, performing fine segmentation on the candidate defect region based on multi-scale context information to obtain an accurate defect mask;
[0058] S700, superimposing and displaying the candidate defect region and the accurate defect mask on the original to-be-detected image to obtain a detection result.
[0059] In the embodiment of the present application, by using the normal image under the same product process condition as the reference image, the pixel-level difference processing is performed on the image to be detected, so as to highlight the potential defect area. The difference mechanism essentially constructs a "contrast enhancement mechanism", which effectively improves the accuracy and robustness of defect detection without relying on a large number of sample training. At the same time, combined with the subsequent image segmentation algorithm and target tracking technology, the automatic identification and tracking of the defect target are realized.
[0060] In addition, the method provided by the embodiment of the present application not only has wide applicability in metal surface defect detection, but is not limited thereto, and is also applicable to other industrial vision fields such as ceramic, circuit board, plastic product manufacturing detection links for detecting small abnormalities on the surface of stable structures. The technical mechanism has high scalability and system integration capability, and provides a feasible path and important support for realizing efficient, accurate and real-time industrial defect detection.
[0061] In a preferred embodiment of the present application, the pre-processing method includes but is not limited to uniform size scaling and pixel normalization.
[0062] Specifically, in step S100, when the metal workpiece enters the detection area, the metal workpiece surface image (i.e. the image to be detected) and the corresponding normal reference image (which can be a similar reference image or a model restored image) can be collected by an industrial camera (or a high-resolution camera) in real time. Under the premise of ensuring consistent acquisition resolution and lighting conditions, uniform size scaling (for example, 256x256 pixels) and pixel normalization and other pre-processing can be performed on the two images, thereby removing the interference caused by brightness fluctuations and device differences, improving the image quality, and providing standardized input for subsequent algorithms.
[0063] In a preferred embodiment of the present application, the formula of pixel-level absolute difference operation is as follows:
[0064] ;
[0065] In the formula, (x, y) is a pixel; is the image to be detected; is the normal reference image; is the difference image.
[0066] On the pre-processed image, the pixel-level absolute difference processing can highlight the defect features, so that the network can simultaneously perceive the original texture and small changes, thereby improving the sensitivity to fine cracks and pits. The difference image obtained by the embodiment of the present application can effectively highlight the small differences in surface texture, brightness and details between the two, especially for surface pits, scratches and other detail abnormalities.
[0067] In a preferred embodiment of the present application, before the step of splicing the to-be-detected image, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor, it further includes: performing Gaussian blur processing on the difference image.
[0068] Specifically, the formula of Gaussian blur processing is:
[0069] ;
[0070] ;
[0071] In the formula, is the difference image after Gaussian blur; is the Gaussian kernel; is the control of the blur degree, the greater, the stronger the blur.
[0072] In step 300, the normal reference image, the to-be-detected image and their difference image are spliced along the R, B and G channel directions respectively to form a three-channel input tensor for inputting into the subsequent model. This method ensures that the model can simultaneously receive the overall appearance information of the workpiece and the defect change details, thereby improving the recognition accuracy.
[0073] It is worth noting that in the task of metal surface defect detection, the original difference image often contains small-range noise fluctuations (such as dust, texture, light reflection) and pixel-level errors caused by image precision. These weak interferences are easy to be confused with real defects. Therefore, directly binarizing the original difference image often leads to misjudgment or omission. The embodiment of the present application can suppress noise and pixel-level alignment errors by first introducing Gaussian blur to process the difference image, and then splicing it with the normal reference image and the to-be-detected image.
[0074] In a preferred embodiment of the present application, the multi-channel input tensor is input into a lightweight convolutional neural network, and a defect probability heat map is output, and a rough positioning mask is obtained according to the defect probability heat map. The step specifically includes:
[0075] Based on the lightweight convolutional neural network, a multi-channel input tensor is input, and a defect probability heat map is output. The brightness intensity in the defect probability heat map represents the probability that the pixel is a defect.
[0076] After upsampling processing of the defect probability heat map, the first threshold is used for binarization processing to generate a rough positioning mask.
[0077] It should be noted that after the multi-channel input tensor is sent into the lightweight convolutional neural network, the network outputs a low-resolution defect probability heat map, which can be enlarged to the original resolution through bilinear interpolation and binarized according to a threshold to obtain a coarse positioning mask covering all potential defect regions.
[0078] Specifically, the generation formula of the coarse positioning mask is:
[0079] ;
[0080] In the formula, is the probability value of the corresponding pixel point in the defect probability heat map; is a first threshold, which is an adjustable parameter used to control the sensitivity of coarse positioning; is the coarse positioning mask; when , it represents a region where defects may exist; when , it represents a background region or a normal defect-free region.
[0081] In a preferred embodiment of the present application, the coarse positioning mask is subjected to connected component analysis, and noise is filtered based on the area threshold method to obtain a candidate defect region, specifically as follows:
[0082] The coarse positioning mask is subjected to connected component analysis, all connected regions are extracted and surrounded by minimum bounding rectangles, if the area is less than a second threshold, it is considered to be noise and removed, and the remaining part is output in the form of minimum bounding rectangle as a candidate defect region set.
[0083] In the embodiment of the present application, by performing connected component analysis on the coarse positioning mask, noise spots with an area less than a preset minimum value (i.e. a second threshold A min is an adjustable parameter used to adjust the strictness of candidate region screening according to the noise level in the actual scene) are removed, and the remaining connected blocks are output in the form of minimum bounding rectangle as a candidate defect frame set. This step effectively filters background impurities and small artifacts, and locks the key region for subsequent fine segmentation.
[0084] In a preferred embodiment of the present application, based on multi-scale context information, the candidate defect region is subjected to fine segmentation to obtain an accurate defect mask, specifically including:
[0085] Adaptive average pooling of different sizes is performed on the candidate defect region and up-sampling is performed to obtain multi-scale features;
[0086] The multi-scale features are spliced with the original features, and convolution fusion is performed to obtain a pixel-level defect probability map;
[0087] After the pixel-level defect probability map is normalized, it is subjected to binarization processing to obtain an accurate defect mask.
[0088] In the embodiment of the present application, after the candidate defect area is cropped, it is sent to the fine segmentation network. The fine segmentation network adopts a multi-scale context fusion strategy: different convolutions or poolings such as 1x1, 3x3, 5x5 are respectively performed, the features of each scale are spliced and fused through convolution, and rich edge and texture information is extracted. The pixel-level defect probability map output can be normalized by using the Sigmoid function, and then the first threshold value described above is used binaryzation processing, the accurate defect mask of accurate pixel level is obtained, and the defect edge and morphology are effectively outlined.
[0089] In step S700, the candidate defect area (candidate box) and the accurate defect mask are superimposed on the original image to be detected, and real-time interface display can be realized. The method provided in the embodiment of the present application supports exporting detection results in the form of images, coordinate lists or alarm events, and can be connected with an industrial control system to meet the needs of online monitoring, instant response and subsequent quality tracking.
[0090] In another embodiment of the present application, a metal workpiece defect detection system based on image difference is also provided, which is used to realize the metal workpiece defect detection method described above, and includes:
[0091] An image acquisition and preprocessing module 10 is configured to acquire the image to be detected of the metal workpiece to be detected and the normal reference image corresponding to no defect, and to pre-process the two images;
[0092] A difference image generation module 20 is configured to perform pixel-level absolute difference operation on the pre-processed image to be detected and the normal reference image, and to generate a difference image;
[0093] An image splicing module 30 is configured to splice the image to be detected, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor;
[0094] A defect coarse positioning module 40 is configured to input the multi-channel input tensor into a lightweight convolutional neural network, output a defect probability heat map, and obtain a coarse positioning mask according to the defect probability heat map;
[0095] A candidate area extraction module 50 is configured to perform connected domain analysis on the coarse positioning mask, filter noise based on an area threshold method, and obtain a candidate defect area;
[0096] A fine segmentation module 60 is configured to perform fine segmentation on the candidate defect area based on multi-scale context information, and obtain an accurate defect mask;
[0097] A result visualization module 70 is configured to superimpose the candidate defect area and the accurate defect mask on the original image to be detected, and obtain a detection result.
[0098] In practical applications, the method and system provided by the embodiment of the present application superimpose the final detection result in the form of a red box (rectangle) and a red defect mask on the original image to be detected. The system can display the detection result in real time and support export of a defect map, a mask map, coordinate data, etc. for production line alarm, statistics or automatic rejection device linkage control. For example, the metal workpiece defect detection method is used to detect the image to be detected with defects, and the output accurate defect mask and detection result with the candidate defect area are as shown in Figure 3 Figure 4 Figure 5
[0099] In summary, the embodiment of the present application greatly enhances the sensitivity to small defects by introducing a differential image contrast mechanism (pixel difference between the normal reference image and the image to be detected), effectively highlights the defect area, and reduces background interference and false detection rate. For complex texture and background change scenes, differential enhancement enables the model to focus on the actual defect area, improving defect detection accuracy and interpretability.
[0100] The embodiment of the present application can quickly locate the candidate defect area in the first stage of rough detection, significantly reduce the required computing resources and time for subsequent fine processing, and is suitable for deployment in edge or production line real-time detection systems. It can be applied to various metal types (such as aluminum plate, stainless steel, die casting, etc.) surface defect recognition, and has good universality and expandability.
[0101] In addition, the embodiment of the present application uses a fixed camera to shoot with a normal image reference, does not rely on large-scale sample training and complex modeling, has flexible deployment and low training cost. It can be seamlessly integrated with industrial image acquisition systems, detection terminals and other modules, and is suitable for pipeline, online detection and other efficient scene requirements.
[0102] It should be noted that each of the above modules can be implemented in the form of a computer program, which can run on a computer device, and the computer program composed of each module can be stored in the memory of the computer device to enable the processor to execute each step of the above method.
[0103] It should be understood that, although the steps in the flowcharts of the embodiments of the present application are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other sequences. Moreover, at least some of the steps in the embodiments can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of the sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least some of the other steps or sub-steps or stages of the other steps.
[0104] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware by a computer program, and the program can be stored in a non-volatile computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments of the methods. Any reference to memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory.
[0105] The above-described embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be noted that, for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A method for detecting defects in a metal workpiece based on image differencing, the method comprising: The method comprises the following steps: Collecting a to-be-detected image of a metal workpiece to be detected and a corresponding normal reference image without defects, and pre-processing the two images; Performing pixel-level absolute difference operation on the pre-processed to-be-detected image and the normal reference image to generate a difference image; Splicing the to-be-detected image, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor; Inputting the multi-channel input tensor into a lightweight convolutional neural network to output a defect probability heat map, and obtaining a coarse positioning mask according to the defect probability heat map; Performing connected domain analysis on the coarse positioning mask, filtering noise based on an area threshold method, and obtaining a candidate defect region; Based on multi-scale context information, performing fine segmentation on the candidate defect region to obtain an accurate defect mask; Superimposing the candidate defect region and the accurate defect mask on the original to-be-detected image to obtain a detection result.
2. The image-difference-based metal workpiece defect detection method of claim 1, wherein, The pre-processing method includes uniform size scaling and pixel normalization.
3. The image-difference-based metal workpiece defect detection method of claim 1, wherein, The formula of the pixel-level absolute difference operation is as follows: ; In the formula, (x, y) is a pixel; is the image to be detected; is the normal reference image; is the difference image.
4. The metal workpiece defect detection method based on image difference according to claim 1 or 3, characterized in that, Before the step of splicing the to-be-detected image, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor, the method further comprises: performing Gaussian blur processing on the difference image.
5. The image-difference-based metal workpiece defect detection method of claim 4, wherein, The formula of the Gaussian blur processing is as follows: ; ; where (x, y) is a pixel; is a difference image after Gaussian blur; is an original difference image; is a Gaussian kernel; is to control the degree of blur, The larger, the stronger the blur.
6. The image-difference-based metal workpiece defect detection method of claim 1, wherein, The step of inputting the multi-channel input tensor into a lightweight convolutional neural network to output a defect probability heat map, and obtaining a coarse positioning mask according to the defect probability heat map, specifically comprises: Based on the lightweight convolutional neural network, the multi-channel input tensor is inputted to output a defect probability heat map; the brightness intensity in the defect probability heat map represents the probability that the pixel is a defect; After upsampling processing of the defect probability heat map, the first threshold is used for binaryzation processing to generate a coarse positioning mask.
7. The image-difference-based metal workpiece defect detection method of claim 6, wherein, The generation formula of the coarse positioning mask is as follows: ; In the formula, (x, y) is a pixel; is a probability value of a corresponding pixel point in the defect probability heat map; is a first threshold value; is a coarse positioning mask; when , it indicates a region in which a defect may exist; when , it indicates a background region or a normal defect-free region.
8. The image-difference-based metal workpiece defect detection method of claim 1, wherein, The step of performing connected domain analysis on the coarse positioning mask, filtering noise based on an area threshold method, and obtaining a candidate defect region, specifically comprises: Performing connected domain analysis on the coarse positioning mask, extracting all connected regions and surrounding them with minimum bounding rectangles, if the area of a connected region is less than the second threshold, it is considered as noise and removed, and the remaining part is outputted as a candidate defect region set in the form of minimum bounding rectangle.
9. The image-difference-based metal workpiece defect detection method of claim 1, wherein, The step of performing fine segmentation on the candidate defect region based on multi-scale context information to obtain an accurate defect mask, specifically comprises: Performing adaptive average pooling of different sizes on the candidate defect region and upsampling to obtain multi-scale features; Splicing the multi-scale features with original features and performing convolution fusion to obtain a pixel-level defect probability map; After normalization processing of the pixel-level defect probability map, binaryzation processing is performed to obtain an accurate defect mask.
10. A metal workpiece defect detection system based on image difference for implementing the metal workpiece defect detection method of any one of claims 1-9, characterized in that, The method comprises: An image acquisition and pre-processing module for collecting a to-be-detected image of a metal workpiece to be detected and a corresponding normal reference image without defects, and pre-processing the two images; A difference image generation module for performing pixel-level absolute difference operation on the pre-processed to-be-detected image and the normal reference image to generate a difference image; An image splicing module for splicing the to-be-detected image, the normal reference image and the difference image along the channel direction to form a multi-channel input tensor; The defect coarse positioning module is configured to input a multi-channel input tensor into a lightweight convolutional neural network, output a defect probability heat map, and obtain a coarse positioning mask according to the defect probability heat map; The candidate region extraction module is configured to perform connected domain analysis on the coarse positioning mask, filter noise based on an area threshold method, and obtain a candidate defect region; The fine segmentation module is configured to perform fine segmentation on the candidate defect region based on multi-scale context information, and obtain an accurate defect mask; The result visualization module is configured to superimpose the candidate defect region and the accurate defect mask on the original image to be detected, and obtain a detection result.
Citation Information
Patent Citations
Intelligent detection method for machining process of automobile decorative plate
CN119919400A
Container bottom plate surface defect intelligent detection method based on deep learning
CN120635066A