How Sobel Operator works in edge function?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
C J
el 28 de Abr. de 2021
Respondida: Sarvesh Kale
el 31 de En. de 2023
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.
0 comentarios
Respuesta aceptada
Sarvesh Kale
el 31 de En. de 2023
The sobel operator is used in Image processing edge detection, it works in the following manner
1.) Compute gradient in X direction
This can be done by multiple methods, simplest is to use conv2 function, call the resultant image Gx
2.) Compute gradient in Y direction
This can be done by multiple methods, simplest is to use conv2 function, call the resultant image Gy
3.) Obtain magnitude of the resultant image
I = sqrt(Gx*Gx + Gy*Gy)
4.) Choose threshold based on application
the following lines of code does all the above steps
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)
OR
you can use the inbuilt function in MATLAB that does the same functionality
I = imread('cameraman.tif');
I = edge(I, 'sobel') % there are also other operators like canny
imshow(I)
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!