Commit 49028dd1 authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

Compute perimeter 3d.

parent 40385764
......@@ -147,11 +147,14 @@ for i = 1 : n_objects
o = objects( i );
area = area3d( o.boundary );
perim = perimeter3d( o.boundary );
objects( i ).area = area;
objects( i ).perimeter = perim;
uncorr = struct();
uncorr.area = polyarea( o.boundary(:,1), o.boundary(:,2) );
objects( i ).area = area;
uncorr.perimeter = perimeter3d( o.boundary( :, 1:2 ) );
objects( i ).uncorr = uncorr;
end
......@@ -181,7 +184,10 @@ for i = 1 : n_objects
o = objects( i );
P = o.boundary;
patch( P(:,1), P(:,2), P(:,3), o.area / o.uncorr.area, ...
err = o.perimeter / o.uncorr.perimeter - 1;
patch( P(:,1), P(:,2), P(:,3), err, ...
'LineWidth', 2 );
text( o.center(1), o.center(2), o.center(3) + 0.5, num2str( i ), ...
'HorizontalAlignment', 'center', ...
......
function perim = perimeter3d( p )
%PERIMETER3D Perimeter of a closed N-dimensional polygon.
% p can be a N x d matrix, with d being the dimensionality.
p2 = [ p ; p( 1, : ) ];
p_diff = diff( p2 );
p_diff_2 = p_diff .* p_diff;
p_diff_2_sum = sum( p_diff_2, 2 );
sls = sqrt( p_diff_2_sum );
perim = sum( sls );
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment