0

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.

Maerorek
  • 109
  • 1
  • 3
  • 9
  • 1
    Can you post an example picture? – Nico Schertler Feb 28 '14 at 11:07
  • What it the color format (24 bit, grayscale?) – Gary Walker Feb 28 '14 at 11:09
  • If you are able to find 3 different points on a circle, you can compute the circle's diameter and its cneter. If you have more than 3 points you can combine points by 3 and check are the diameters/centers are the same. – Dmitry Bychenko Feb 28 '14 at 11:15
  • For any question about image processing, please post at least one sample image. A number of us have experience finding circles in images for industrial applications. The first rule of any image processing app: show the image. – Rethunk Mar 01 '14 at 05:49
  • Hi, Maerorek you mention precise measuring for industry but there is a lot of information you need to provided first. You say you've attempted HoughCircles but did you do background subtraction to minimise false positives. The contour detection method may work more appropriately by using contour analysis.http://www.codeproject.com/Articles/196168/Contour-Analysis-for-Image-Recognition-in-C do light conditions change? what accuracy do you need and is your hardware capable of providing the accuracy you need? Cheers – Chris Mar 01 '14 at 21:26

2 Answers2

1

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

Y.AL
  • 1,808
  • 13
  • 27
  • 1
    As an alternative, the width and height of the bounding box of the contour should be equal to the diameter. – Olivier A Feb 28 '14 at 12:00
1

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

Community
  • 1
  • 1
Gary Walker
  • 8,831
  • 3
  • 19
  • 41