Doubt about Hough Circle Transform

asked 2018-05-06 02:51:55 -0600

bznm gravatar image

In the book "Learning OpenCv" I can read

The Hough gradient method works as follows. First the image is passed through an edge detection phase (in this case, cvCanny() ). Next, for every nonzero point in the edge image, the local gradient is considered (the gradient is computed by first computing the first- order Sobel x - and y-derivatives via cvSobel()). Using this gradient, every point along the line indicated by this slope—from a specified minimum to a specified maximum distance—is incremented in the accumulator. At the same time, the location of every one of these nonzero pixels in the edge image is noted. The candidate centers are then selected from those points in this (two-dimensional) accumulator that are both above some given threshold and larger than all of their immediate neighbors. These candidate centers are sorted in descending order of their accumulator values, so that the centers with the most supporting pixels appear first. Next, for each center, all of the nonzero pixels (recall that this list was built earlier) are considered. These pixels are sorted according to their distance from the center. Working out from the smallest distances to the maximum radius, a single radius is selected that is best supported by the nonzero pixels.

Now I am not sure about the "these pixels are sorted according to their distance from the center". Why do we do that? In order to speed up radius support checking? I wasn't able to find any explanation. Thanks a lot for the help

edit retag flag offensive close merge delete

Comments

I can just guess that you are right and this is done for efficiency as stated in https://docs.opencv.org/3.4/d4/d70/tu... Also it is possible to limit the detection of circles with a predefined minimum and maximum radius. These are the 8th and 9th values in the function HoughCircles like you already saw.

A note in the source code additionally says: "Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure."

Grillteller gravatar imageGrillteller ( 2018-05-08 07:39:05 -0600 )edit