Llamero / Local_Hough_Circle

An improved implementation
GNU General Public License v3.0
10 stars 1 forks source link

Exclusion of nearby circles #3

Closed tischi closed 6 years ago

tischi commented 6 years ago

Hello! Awesome plugin! I am having trouble to get the exclusion of nearby circles working. I entered a number of 10.0 there but it still shows also nearby circles (see screenshot) Am I doing something wrong? (Example image is attached as zip file).

image

hough-trafo-example.zip

Llamero commented 6 years ago

I bumped up the score threshold and was able to resolve the problem (see below). What was happening is that if the small circles are found first, then only the centroids within the small circles are cleared, meaning the large over-lapping circle can be found too, even with a large clearing radius, The mask is also pretty thick, with some circles even being filled. This will prove challenging for the algorithm, as this means there are many equally valid circles across a wide range of radii that can fit in a filled circle. As long as the circles are somewhat hollow, one thing you can do is skeletonize the mask to thin out the edges (or use a higher threshold when binarizing).

Finally, one other trick is to split the Hough into two steps if need be: 1) A small radius search with a high score threshold, and then 2) a large radius search with a lower score threshold. This can also help avoid the problem you are seeing.

Hope this helps, Ben Smith

settings output

jmmroldan commented 6 years ago

I am having a similar problem. I cannot be sure, but I would say that clear neighbour ratio greater than 1.0 is not working. I don't think the problem is related to finding smaller circles first. tischi was using a ratio of 10.0 and I would say that the big circle centroid is closer thant 10 times the radius of the smaller one. Also you can see a bunch of similar sized circles with centroids closer than 10 times the radius on the bottom right. If I understood how this parameter works, whichever circle was found first, should prevent any other circle to be detected in an area of 10 times its radius, but this seems not to be happening. Maybe I am not understanding it correctly?

Llamero commented 6 years ago

Hey jmmroldan, Good catch! I tested it and found the same issue. It turns out that in the the clear function, even though the ratio variable was being called, it was being ignored for reasons. Breaking the math up into two steps solved the problem. I have uploaded the fix, so if you update FIJI, it will replace your version with the fix.