Reputation: 835
In the example here, I do not know why it called the median filter first before the hough circle algorithm. Is this meant to give better detection?
Also, is there any other tricks in general that maybe useful when calling Hough circle algorithm? In particular, if the circular object has same brightness with its background, hence looking homogeneous on the grey scale, is there anything I can do here?
Also, if I cannot get perfect detection, I would prefer having less detected circles but rather the detected ones are correct.
Thanks
Upvotes: 3
Views: 2714
Reputation: 21
Yes, it is meant to reduce the noise within the image, with the aim to improve edge detection. Edge detection algorithms are sensitive to noise.
Described here: https://en.wikipedia.org/wiki/Median_filter
But this image better illustrates how blur improves (even your brain's) edge detection: https://upload.wikimedia.org/wikipedia/commons/6/62/Cappadocia_Gaussian_Blur.svg
This image is from an article on Gaussian Blur, another smoothing technique that reduces noise in signals (like images). However, Median Filter preserves edges better than Gaussian Blur, hence its use in image processing. (Described under "Edge preservation properties" in Wiki's Median Filter article)
Upvotes: 1
Reputation: 883
The blur will help avoid false circle detection by reducing noise, because openCV uses a gradient version of the hough circle detection algorithm, outlined here: http://homepages.inf.ed.ac.uk/rbf/BOOKS/BANDB/LIB/bandb4_3.pdf
The size of the blur will interplay with the upper threshold for the internal Canny edge detector, which is param_1. You'll want to play around with that.
To get around the brightness problem, try detecting just with isolated R, G and B channels. To get more complete results, you can then shift hue by 60 and then use isolated channels again.
Upvotes: 1