ac_area.m

来自「active contours in matlab」· M 代码 · 共 27 行

M
27
字号
function acarea = ac_area(acontour)
%ac_area: signed area of an active contour
%   r = ac_area(a) computes the signed area, r, of an active contour, a, using
%   the Green's theorem. If a is oriented counterclockwise, r is positive.
%
%See also po_orientation, acontour.
%
%Active Contour Toolbox by Eric Debreuve
%Last update: June 20, 2006

acarea = 0;

for subac_idx = 1:length(acontour)
   [breaks, coefs, interval] = ppbrk(acontour(subac_idx), 'breaks', 'coefs', 'interval');

   %/!\ this might not be valid if the ppform structure changes
   first_coordinate  = mkpp(breaks, coefs(1:2:end,:));
   second_coordinate = mkpp(breaks, coefs(2:2:end,:));

   acarea = acarea + 0.5 * fnval(fnint(...
      fncmb(...
         fncmb(first_coordinate,  '*', fnder(second_coordinate)), ...
         '-', ...
         fncmb(second_coordinate, '*', fnder(first_coordinate))...
      )), interval(2));
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?