find gradient using sobel mask operator in matlab

12 visualizaciones (últimos 30 días)
DIWAKAR KUMAR
DIWAKAR KUMAR el 25 de Feb. de 2017
Comentada: Image Analyst el 26 de Feb. de 2017
I am using following code to mask image using sobel mask .
%------------------- C is an image
for i=1:size(C,1)-2
for j=1:size(C,2)-2
%Sobel mask for x-direction:
Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
%Sobel mask for y-direction:
Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
%The gradient of the image
%B(i,j)=abs(Gx)+abs(Gy);
B(i,j)=sqrt(Gx.^2+Gy.^2);
direction = atan(Gy./Gx)
end
end
My question is that sometimes gradient direction value is giving as "NaN", how to avoid it?
Second, how to quantize gradient direction into eight zone and find feature vector for the image? Please someone help me.

Respuestas (1)

Image Analyst
Image Analyst el 25 de Feb. de 2017
Why? Why not simply use imgradient() to get the Sobel filtered image?
  2 comentarios
DIWAKAR KUMAR
DIWAKAR KUMAR el 25 de Feb. de 2017
please tell me how to quantize gradient direction into eight zone and find feature vector for the image?
Image Analyst
Image Analyst el 26 de Feb. de 2017
What features do you want to measure?

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by