I use the function imgradientxy to get the Gx and Gy firstly. Then obtain the direction of the gradient.
some codes like:
% code
b = zeros(100);b(1:4:end,:) = 1;[Gx, Gy] = imgradientxy(b);theta = atan(Gy./Gx);
The image only has some horizontal lines. So The Gx is all zeros and the theta have a lot NAN. What should I do to get the gradient for this image and for other?
Best Answer