Are there any efficient algorithm to detect circular shape of arbitrary size in an image? I have images that are 1278 by 1024. They are pictures of a certain product that is rectangular in shape and are about 25mm by 20mm. As a part of a quality inspection process using computer vision, the goal is to detect contamination. The contamination are roughly circular in shape (caused by splattering of a certain material). Due to the special lighting, the contamination is seen as a roughly circular white area, surrounded by a green area (also circular, ring-like, concentric to the white area).

So basically it looks like a green donut, with a white 'hole'.

The goal is to detect such defect. However, the size of the contamination can vary. Furthermore, the size of the 'hole' can vary even if the outer diameter is the same.

I think I need to define a minimum and maximum size that I look for, and scan the image, but more advice and detail is needed.

Thanks
Usually this problem is tackled using the Hough transform. Check it here:


OpenCV
Scikit


After you have some hints for the possible location of the circles and their diameter then you can calculate the distance (e.g. Euclidean) from the pixels you have to an ideal model (circle parametric equations: x = r.cos a; y = r.cos a)