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.