Maerorek
Maerorek

Reputation: 109

Get diameter of circle in bitmap

My problem is following. I need precisely measure diameter of circles in bitmap. I have Bitmap with several circles. Some of them are concentric. I need values of their diameters. I tried OpenCV and EmguCV and their method HoughCircles. But this method find circles on the places where is are no circles (I tried a lot of combinations of input parameters). Ad if it finds them there is no case, when it found exatly same circle as in the bitmap. Their centers and diameters are different then circles on the original picture. So this method is only for some kind of game. Not for my purpose(precise measuring for industry).

Do you know some way or algorithm how to do it? (I prefer C#, but if it will be in pseudocode or different langueage, I will rewrite it)

Thanks in advance.

Upvotes: 0

Views: 1300

Answers (2)

Gary Walker
Gary Walker

Reputation: 9134

You are asking for an answer to a very hard problem. The hough algorithm is not a toy solution, but it is not appropriate for all machine visions circle detection situations. Human eyes are very good at such thing (if a bit imprecise). You basically need to know a lot more about your data to approach a robust solution.

Take a look at this dicussion about Hough Circle detection as well as this paper Hough Circle Transform for a deeper understanding of the limitations

You might also want to review this paper on the ant system for ideas on a different approach.

You also might want to read up on Morpological thinning as a possible pre-preprocessing step before Houghton

Best of luck

Upvotes: 1

Y.AL
Y.AL

Reputation: 1793

If you could detect circles, you may benefits from this opencv function findContours() in order to get all circles as contours, then you will be able easily to calculate their areas

Then, use this formula Area = pi*r^2 to calculate r.

diameter = 2*r

Upvotes: 1

Related Questions