% Computes the inclination angle of the segmented region. % according to the centroid coordinates (xmean, ymean), and % the segmented region itself. % See reference [5] in the references section for more details. function [theta] = orient(bw,xmean,ymean) [m n] =size(bw); bw=double(bw); a = 0; b = 0; c = 0; for i=1:m, for j=1:n, a = a + (j - xmean)^2 * bw(i,j); b = b + (j - xmean) * (i - ymean) * bw(i,j); c = c + (i - ymean)^2 * bw(i,j); end; end; b = 2 * b; theta = atan(b/(a-c))/2; % change from radians to degrees. theta = theta*(180/pi);