- You use a rounded approximation to the Gaussian kernel for smoothing. It is likely that edge() uses a different approximation.
- You use a symmetrical operator (the Sobel operator) for differencing. I believe edge() uses non-centred nearest-neighbour differences, which introduce a half-pixel shift in the gradient estimate positions. Personally I prefer your approach.
- Your choice of non-maximum suppression is to quantise the gradient direction to the nearest 45 degrees and to compare gradient magnitudes at the pixels in the relevant direction. There are a number of other possible approaches - for example you can interpolate the gradient magnitude and then compare along the gradient direction. Canny did not specify what to do here, and everyone makes their own choice. I am not sure what edge() does, but it may well do something different from your method.
- Your implementation of hysteresis thresholding is not correct. It is not sufficient to test whether any of the nearest neighbours exceeds the high threshold. You need to test whether the current pixel can be connected to a pixel where the gradient exceeds the high threshold.
I am trying to write code for canny edge detection but it is not giving exact output like inbuilt function.can any one help me
5 ビュー (過去 30 日間)
古いコメントを表示
i attached code,pls check it and tell me where i did wrong in that
0 件のコメント
採用された回答
David Young
2014 年 11 月 17 日
編集済み: David Young
2014 年 11 月 17 日
The differences are quite small, and I don't think there is very much wrong. My own implementation of the Canny edge detector also produces slightly different results from edge().
Possible causes of differences include:
I suspect the second point above is the most important effect in making a difference between your output and that of edge(). The last point above is the only one which I would identify as a definite error on your part.
Your code is not in a good MATLAB style, by the way - all your loops could be vectorised - but that's another story.
3 件のコメント
David Young
2014 年 11 月 20 日
There are a number of ways of implementing hysteresis thresholding. To see the way I chose, you could look at this entry on the File Exchange.
Changing the thresholds will always have a big effect. Note that the thresholds used by edge() are relative to the maximum gradient. But I'm not sure what exactly you'd like me to explain.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!