Question

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

Was it helpful?

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

OTHER TIPS

You have to identify the circles using HoughCircles and then use clusterisation (K-Means algorithm). OpenCV has K-Means implementation: see example1, example2 and docs.

HoughCircles has as one of its parameters the distance between possible circles before they are considered separate circles. Simply keep tweaking this parameter. As long as your groups of circles are farther apart than the actual circles in each group, HoughCircles will count each circle as part of the same 'circle'.

If your groups of circles overlap, though, then this won't work. You'd have to separate each group somehow. Maybe if all the circles in a group are in a line (like in your pictures) then the basic Hough line detection would give you the lines - then you could check for parallel lines that are close together, and those would indicate each group?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top