Skip to content
Snippets Groups Projects
Commit 83c61465 authored by Wolfgang Ludwig's avatar Wolfgang Ludwig Committed by Nicola Vigano
Browse files

add fallback solution to gtThresholdGrain3D

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@654 4c865b51-4357-4376-afb4-474e03ccb993
parent 0182fed8
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ function rec = gtRecDefaultParameters()
rec.method = '2DFBP'; % can be '3DART' or '2DFBP'
rec.list = [];
rec.percentile1 = 25;
rec.percentile2 = 20;
rec.do_morph_recon = true;
rec.absinterval = 10;
......
......@@ -36,7 +36,7 @@ ngrains = length(grain);
%create / reset sample.mat spot2grain.mat
filename = fullfile(parameters.acq.dir, '4_grains', 'sample.mat');
if exist(filename, 'file') && (nof_phases > 1)
sample = GtSample.loadFromFile(filetable, filename); % do not create from scratch - we want to keep information related to other phases
sample = GtSample.loadFromFile(filename); % do not create from scratch - we want to keep information related to other phases
else
sample = GtSample(nof_phases);
sample.fileTable = sprintf('%s_filetable',parameters.acq.name);
......
......@@ -32,11 +32,22 @@ background = mean2(vol(centerx, centery, centerz)) / 10;
% Small performance boost
indexes = vol > background;
% define threshold as percentile/100 x standard dev below the mean, excluding low (10 percentile background) values
threshold_val = mean( vol(indexes) ) ...
- (rec.percentile2/100) * std( vol(indexes) );
stdvol = std( vol(indexes) );
meanvol = mean( vol(indexes) );
if stdvol > meanvol
threshold_val = rec.percentile1/100 * meanvol;
else
threshold_val = meanvol - rec.percentile2/100 * stdvol;
end
segvol = vol > threshold_val;
% while any(size(segvol) == size(vol))
% threshold_val = threshold_val + 0.1
% segvol = vol > threshold_val;
% end
% morphological reconstruction removes not connected areas
if (rec.do_morph_recon)
try
......@@ -56,7 +67,7 @@ if isempty(regprop)
segbb = [];
grain.seg = [];
grain.Area = [];
grain.segbb = [];
grain.segbb = [];
else
segbb = regprop.BoundingBox([2 1 3 5 4 6]);
......
......@@ -756,7 +756,7 @@ list.rec{2,1} = 'list'; list.rec{2,2} = 'list of
list.rec{3,1} = 'percentile2'; list.rec{3,2} = 'Adaptive threshold: percentile/100 * std below grain average value';
list.rec{3,3} = 'double'; % scalar
list.rec{3,4} = 2;
list.rec{4,1} = 'do_morph_recon'; list.rec{4,2} = 'Perform morphological reconstruction during segmentation';
list.rec{4,1} = 'do_morph_recon'; list.rec{4,2} = 'Perform morphological reconstruction during segmentation';
list.rec{4,3} = 'logical';
list.rec{4,4} = 2;
list.rec{5,1} = 'absinterval'; list.rec{5,2} = 'Interval between radiographs used for reconstruction of absorption scan';
......@@ -768,7 +768,11 @@ list.rec{6,1} = 'abs_num_iter'; list.rec{6,2} = 'Number o
list.rec{7,1} = 'num_iter'; list.rec{7,2} = 'Number of iterations used in SIRT reconstruction of grain volumes';
list.rec{7,3} = 'double'; % scalar
list.rec{7,4} = 2;
% list.rec{8,1} = 'select_projections_auto'; list.rec{8,2} = 'select projecions automatically';
list.rec{8,1} = 'percentile1'; list.rec{8,2} = 'Alternative adaptive threshold: percentile/100 * mean below grain average value';
list.rec{8,3} = 'double'; % scalar
list.rec{8,4} = 2;
%list.rec{8,1} = 'select_projections_auto'; list.rec{8,2} = 'select projecions automatically';
% list.rec{8,3} = 'logical';
% list.rec{8,4} = 2;
% list.rec{9,1} = 'use_extspots'; list.rec{9,2} = 'Use extension spots';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment