Commit 5f725368 authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

WIP: Builder from the Bellaiche format.

parent e2e2719d
......@@ -96,7 +96,7 @@ classdef deproj
%% Public static methods: builders & util.
methods ( Access = public, Hidden = false, Static = true )
% Returns the Z position of points taken from a height-map.
% Returns a deproj object built from segmentation and height-map.
obj = from_heightmap( I, ...
H, ...
pixel_size, ...
......@@ -106,11 +106,25 @@ classdef deproj
inpaint_zeros, ...
prune_zeros );
% Returns a deproj object built from the results of the tool
% from Yohannes Bellaiche lab.
obj = from_bellaiche( ...
cells, ...
frame, ...
sides, ...
vertices, ...
voxel_depth, ...
units )
% Returns the seismic colormap.
cmap = cmap_seismic();
% Compute local curvature from the smoothed height-map.
[ curvMean, curvGauss, curvK1, curvK2 ] = compute_curvatures( H, object_scale, pixel_size, voxel_depth, invert_z )
% Sort the points of a polygon in clockwise manner.
P2 = sort_polygon( P )
end
......
function obj = from_bellaiche( ...
cells, ...
frame, ...
sides, ...
vertices, ...
voxel_depth, ...
units )
%FROM_BELLAICHE Returns a deproj object built from the results of the tool
%from Yohannes Bellaiche lab.
%% Get information about source image.
width = frame.imageSize( 1 );
pixel_size = frame.scale1D;
%% Build the junction graph.
tic
fprintf('Building the junction graph.\n' )
edge_table = table();
edge_table.EndNodes = sides.vertices;
node_table = table();
jxy = vertices.XYs;
% TODO
jz = zeros( size( jxy, 1 ), 1 );
node_table.Centroid = [ jxy jz ];
node_table.ID = vertices.numbers;
junction_graph = graph( edge_table, node_table, 'omitselfloops' );
fprintf('Built the junction graph with %d nodes and %d edges in %.1f seconds.\n', ...
junction_graph.numnodes, junction_graph.numedges, toc )
%% Convert YB structure to epicells.
fprintf('Converting to objects.\n' )
tic
n_cells = numel( cells.contour_indices );
% We don't go for the first one, which contains the contour of the tissue.
% Get boundary.
for i = n_cells : -1 : 2
% Get the boundary.
% It is about converting linear indices to XY coordinates. We do
% this by integer division since we know the image width.
ids = int32( cells.contour_indices{ i } );
x = idivide( ids, width);
y = rem( ids, width);
P = double( [ x y ] );
P = deproj.sort_polygon( P );
P = P * pixel_size;
% TODO
z = zeros( numel(x), 1 );
boundary = [ P z ];
% Get the junction ids.
junction_ids = cells.vertices{ i };
id = cells.numbers( i );
epicells( i ) = epicell( boundary, junction_ids, id );
end
obj = deproj( epicells, junction_graph, units );
end
function P2 = sort_polygon( P )
%SORT_POLYGON Sort the points of a polygon in clockwise manner.
center = mean( P );
x = P( :, 1 ) - center( 1 );
y = P( :, 2 ) - center( 2 );
angles = atan2( y , x );
[ ~, sort_indexes ] = sort(angles);
P2 = P( sort_indexes, : );
end
Markdown is supported
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