The invention discloses a method for on-line detection of surface defects of a
metal arc-shaped workpiece. The method comprises the steps: first, obtaining
grayscale images of the surface of a
metal arc-shaped workpiece and establishing a
data field; if the maximum potential value of the
data field is smaller than a set threshold, determining that the
metal arc-shaped workpiece has no defect, ending the detection, if not, executing the next step; conducting threshold segmentation on the image
data field to obtain a
binary image B1W(x, y), and marking defect areas; then for each defect area, determining a contrast threshold T according to its externally connected rectangular area; then, calculating the contrast of any pixel inside the externally connected rectangle of each defect area, andconducting threshold segmentation according to the contrast and T pairs of
grayscale images to obtain a
binary image B2W(x, y); finally, uniting the B1W(x, y) and the B2W (x, y) and removing the noiseto obtain a final defect image, thereby detecting defects. The problem of low defect detection accuracy caused by uneven reflection,
low contrast and many kinds of defects of the surface of the metalarc-shaped workpiece is effectively solved, and the method has good detection precision and robustness for detection of different defects.