if its gauranteed youll always have a single large blob and nothing else in a binary image, can you use houghcircles to determine how much like a circle that 1 large blob is? what would be the best parameters to use with houghcircles if so?

edit retag close merge delete

I don't think it is the appropiate function (I'm not even sure it will work at all if the blob is too different). To determine how much like a circle your contour is, you'd better use shape descriptors like compactness, elongation, convexity, moments, etc.

( 2015-10-17 08:47:50 -0500 )edit

Sort by » oldest newest most voted

I agree with LorenaGdL:

I don't think it is the appropiate function (I'm not even sure it will work at all if the blob is too different). To determine how much like a circle your contour is, you'd better use shape descriptors like compactness, elongation, convexity, moments, etc.

Take a look at this tutorial:

http://opencv-code.com/tutorials/dete...

Given some contours, the program approximate a polygonal curve for that contours. This polygonal curve is the key for detecting the contour’s shape.

A contour is a circle if:

• Has more than 6 vertices.
• Has diameter of the same size in each direction.
• The area of the contour is ~πr2

I have modified this tutorial in order to add a pre-processing step in order to build a robust algorithm to deal with different illumination conditions [1]. Afterwards, I run several times the canny detector with different parameters. The last step to detect all contours is to put together the same contours (two contours are the same contour is their center of mass is the same: the euclidean distance between the center of gravity is less than 1/2/3/4/ pixels depending on the size of the image).

[1] you can use this preprocessing algorithm https://github.com/bytefish/opencv/bl... or even, you can use histogram equalization, or CLAHE (http://answers.opencv.org/question/12...)

You can see the results I get:

more

Well, how many rods are there?

( 2015-10-19 17:46:08 -0500 )edit

~ 300/350 .

( 2015-10-20 05:20:57 -0500 )edit

Official site

GitHub

Wiki

Documentation