Commit 62785ba5 authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

Improve mask_to_objects.

- Directly permute X & Y to have boundary coordinates in the proper
referential, like junctions.
- Reduce the number of vertices in the polygon, using reducepoly.
With this setting (0.005) reducepoly is very conservative, but
effectively decimate useless vertices. This has a positive impact
on the area calculation (fewer, larger triangles), and on all
performance.
parent ba351464
......@@ -32,8 +32,9 @@ for i = 1 : n_cells
temp = false( CC.ImageSize );
temp( CC.PixelIdxList{ i } ) = true;
temp = imdilate( temp, se, 'same' );
bounds = bwboundaries( temp, 4, 'noholes' );
B{ i } = bounds{ 1 };
bounds = bwboundaries( temp, 8, 'noholes' );
b = reducepoly( bounds{ 1 }, 0.005 );
B{ i } = b;
end
%% Remove cells touching the border.
......@@ -127,8 +128,9 @@ for i = n_cells : -1 : 1
end
objects( i ).junctions = unique( visited_junctions );
objects( i ).boundary = boundary;
objects( i ).center = mean( boundary );
% Permute X and Y.
objects( i ).boundary = [ boundary(:,2) boundary(:,1) ];
objects( i ).center = mean( objects( i ).boundary );
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