Sobel Edge Thresholds
88 views (last 30 days)
I would like to test several sobel edge threshold values to identify which threshold is the best suited to a particular task... However, I do not know what range of threshold values to test.
My input images are all grayscale from the range 0-255. I read on a previous answer that if the max. value is 255 and the min. value is 0, the max. gradient becomes
(1 + 2 + 1)*255 - (1 + 2 + 1)*0 = 1020.
Which means the threshold can range from -1020:1020... However, when I use a threshold as small as 0.4, the threshold seems too high because no edges are found.
I would be grateful if anyone can help me to understand the most suitable threshold range to evaluate...
Sean de Wolski on 9 Dec 2011
Have you looked at the output for
I would recommend using a for-loop to traverse a few values to hone in on what threshold you think is best.
David Young on 10 Dec 2011
I think there are two problems here.
The first is that it's not clear exactly what the Sobel option in edge() really does, as the threshold that it returns seems much lower that is reasonable. Some kind of normalisation seems to be going on, but it's not properly documented. The gv and gh results from edge('sobel', ...) are also smaller in amplitude that I'd expect, by more than the factor of 8 shown in the documentation.
I'd address this by using my own sobel masks (you can use fspecial as Sean suggests, or you can just write them down) and then convolving with conv2, and thresholding myself.
The second problem is that the Sobel operation on its own is too small-scale for most real images - you'll likely get fragmentary edges all over. For most cases a detector that incorporates some smoothing (e.g. Canny, also available using edge()), will give more useful results.