Search code examples
image-processingopencvobject-recognition

How to detect groups of circles with openCV?


I have a picture like that below. I would like to find groups of circles (their positions) in the image. In the following example there should be three groups. The background is white or will be whitish color.

(In the source image there will not be such rectangulars. I have just painted to show how groups should be like)

Is it possible to find it?

Circles do detect

What about such picture: Example 2

Circles without rectangulars: Example 3

Example 4


Solution

  • 1 - Simply invert the image,

    2 - then dilate the image so that all circles are joined together,

    3 - Find the contours,

    4 - find bounding box.

    eg :

    enter image description here