我使用了imgradientxy();但是它给出了-600这样的值。我需要在两个方向上分别在-180至180.范围内的角度值。
The values are 0 and 90. The gradient is calculated in the X and Y direction by imgradientxy()
as you may infer from its name.
However the gradient in a point is defined by:
and you can do [Gx,Gy]=imgradientxy(img)
.
That means that your total gradient (not the "directional gradient", which is what Gx and Gy are) is a vector. the (Gxi,Gyi)
vector in point i
.
To calculate the modulus and angle of a vector is a straightforward algebra thing:
The modulus, magnitude, euclidean norm or however you preffer to call it is:
m=norm([Gx,Gy]);
And the angle:
theta=atan(Gy/Gx); %radians
theta=atand(Gy/Gx); %degrees
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.