Can we rotate sobel operator and still get the same results for gradient image
5 次查看(过去 30 天)
显示 更早的评论
I have a 5*5 image and I applied imgradient() on it and got the directions(just focussing on directions). I also tried to calculate the directions for the same image on paper using the following sobel operators.
gx=[-1 0 1; -2 0 2; -1 0 1] gy=[-1 -2 -1; 0 0 0; 1 2 1]
I found theta using
Gdir = atan2(-gy,gx)*180/pi %Note: gy is negative as y moves from top to bottom
and got same answers as were obtained using imgradient().
But when I used
gx=[1 0 -1; 2 0 -2; 1 0 -1] gy=[1 2 1; 0 0 0; -1 -2 -1]
I got different answers. Why?
Can't we rotate sobel operator and still get the same results. Does MATLAB uses a fixed set of sobel operators to find gradient and never uses the rotated version? What is the problem. Please explain.
0 个评论
回答(1 个)
Anand
2016-2-9
The imgradient function uses the following kernels for the 'sobel':
hx = -fspecial('sobel')'
hx =
-1 0 1
-2 0 2
-1 0 1
hy = -fspecial('sobel')
hy =
-1 -2 -1
0 0 0
1 2 1
You get different results with the rotated kernels because the Sobel kernel is not symmetric.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!