RunExample.m 2 KB
Newer Older
1
2
%% Example de-projection script.

3
%% Clear all.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

close all
clear
clc

%% Parameters, scripts and files location.

% Add DeProj functions to the path.
addpath('./src')

% Where are the images.
root_folder = 'samples';

% You can proovide directly the segmentation results as a mask image, and
% the code below will convert it into a list of objects.
% For this to work, the mask image must be an 'ImageJ' mask, that is: the
% cell contours must be black (pixel value == 0) and the cell interiors
21
22
% must be white (pixel value > 0).
mask_filename       = 'Segmentation-2.tif';
23
24
25
26
27

% The height-map is an image that stores at every pixel the location of the
% plane of interest in the source 3D image. Since the pixel values store 
% the index of the plane, we will need to convert it to an elevation in µm
% (see the voxel_depth parameter below).
28
heightmap_filename   = 'HeightMap-2.tif';
29
30
31
32
33

% Pixel XY size.
% Physical size of a pixel in X and Y. This will be used to report sizes in
% µm.
pixel_size = 0.183; % µm
34
units = 'µm';
35
36
37
38
39
40

% Z spacing.
% How many µm bewtween each Z-slices. We need this to convert the
% height-map values, that stores the plane of interest, into µm.
voxel_depth = 1.; % µm

41

42
43
44
% Try to remove objects that have a Z position equal to 0. Normally this
% value reports objects that are out of the region-of-interest.
prune_zeros = true;
45
46
47
48
inpaint_zeros = true;

% Invert z for plotting.
invert_z = true;
49

50
%% Read files.
51
52
53
54
55

% ImageJ mask.
fprintf('Opening mask image: %s\n', mask_filename )
I = imread( fullfile( root_folder, mask_filename ) );

56
57
58
fprintf('Opening height-map image: %s\n', heightmap_filename )
H = imread( fullfile( root_folder, heightmap_filename ) );

59
60
61
62
63
64
65
66
67
68
69
%% Create deproj instance.

dpr = deproj.from_heightmap( ...
    I, ...
    H, ...
    pixel_size, ...
    voxel_depth, ...
    units, ...
    invert_z, ...    
    inpaint_zeros, ...
    prune_zeros );
70

71
%% Plot morphological parameters.
72

Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
73
close all
74
plot_sizes( dpr );
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
75
76
77
78
plot_fit_plane( dpr );
plot_fit_ellipse( dpr );
plot_curvatures( dpr );
plot_distorsions( dpr );