I am trying to implement Canny Edge detection algorithm and I've encountered some problems along the way. I think I understand every step of Canny edge detection, but when compared to results given by OpenCv implementation they vary greatly.
It seems that I just can't get the 1px wide edges like the algorithm should produce. Here are the steps and results for this very simple binary image:
Binary Image that is being processed:
Gradient magnitude calculated using Sobel operators:
Edge directions:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 <br>
1 / - - - - - - - - - - - \ 1 <br>
1 | / - - - - - - - - - \ | 1 <br>
1 | | / - - - - - - - \ | | 1 <br>
1 | | | / - - - - - \ | | | 1 <br>
1 | | | | | | | | | | | | | 1 <br>
1 | | | | | | | | | | | | | 1 <br>
1 | | | | | | | | | | | | | 1 <br>
1 | | | | | | | | | | | | | 1 <br>
1 | | | | | | | | | | | | | 1 <br>
1 | | | \ - - - - - / | | | 1 <br>
1 | | \ - - - - - - - / | | 1 <br>
1 | \ - - - - - - - - - / | 1 <br>
1 \ - - - - - - - - - - - / 1 <br>
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Non maxima suppressed image:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 255 0 0 0 0 0 0 0 0 0 255 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 255 0 0 0 0 0 255 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 255 0 0 0 0 0 255 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 255 0 0 0 0 0 0 0 0 0 255 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0<br>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
If I perform hysteresis thresholding at this step, I get very thick-edged result. The obvious issue is gradient magnitude values, but I have no idea how to solve it. If someone more experienced and knowledgeable would, be kind enough to point me in the right direction, I would be extremely thankful.