What does the edge function do when using the Sobel operator? How to automatically choosing a threshold? The edge is different from my own Sobel function.
Prashant Kumar answered .
2025-11-20
G = imread('cameraman.tif')
Gx = conv2(G , [1 0 -1;...
2 0 -2;...
1 0 -1]);
Gy = conv2(G , [1 2 1;...
0 0 0;...
-1 -2 -1]);
I = sqrt(Gx.*Gx + Gy.*Gy);
I_final = I > 150 % choose the thresold on your application need, experiment with different value to pick the best
imshow(255*I_final)
I = imread('cameraman.tif');
I = edge(I, 'sobel') % there are also other operators like canny
imshow(I)