function [mag,ori] = tedge(a)
%
% tedge - compute edge magnitude and orientation for texture analysis
%         (magnitudes are in 0-255 range and orientation is 0-360 for
%         co-occurrence matrix analysis)
% On input:
%     a: 2D texture image
% On output:
%     mag: edge magnitude (scaled into [0,255])
%     ori: edge orientation (in degrees [0,360])
% Call:
%     [mag,ori] = tedge(a);
%

[ax,ay] = gradient(a);
amag = (ax.^2 + ay.^2);
mag = fix(255*(amag/max(max(amag))));
aori = atan2(ay,ax);
ori = fix(360*(posori(aori)/(2*pi)));
