📄 orient.m
字号:
% 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -