Skip to content
Snippets Groups Projects
Commit 1bcd0dd3 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Random fixes from segmentation and assembling

parent 7921e202
No related branches found
No related tags found
No related merge requests found
...@@ -223,7 +223,7 @@ classdef GtThreshold < handle ...@@ -223,7 +223,7 @@ classdef GtThreshold < handle
tmp_seg = obj.thresholdAutoSingleGrainSimpleSearch(cl_sub_recs(ii_g), 0.02); tmp_seg = obj.thresholdAutoSingleGrainSimpleSearch(cl_sub_recs(ii_g), 0.02);
tmp_seg.seg = gtPlaceSubVolume( ... tmp_seg.seg = gtPlaceSubVolume( ...
zeros(cl_seg.segbb(4:6), 'like', cl_seg(1).seg), ... zeros(cl_seg(1).segbb(4:6), 'like', cl_seg(1).seg), ...
tmp_seg.seg, ... tmp_seg.seg, ...
tmp_seg.segbb(1:3) - cl_seg(1).segbb(1:3) ); tmp_seg.segbb(1:3) - cl_seg(1).segbb(1:3) );
tmp_seg.segbb = cl_seg(1).segbb; tmp_seg.segbb = cl_seg(1).segbb;
...@@ -365,6 +365,10 @@ classdef GtThreshold < handle ...@@ -365,6 +365,10 @@ classdef GtThreshold < handle
if (~isfield(thr_params, 'do_extended')) if (~isfield(thr_params, 'do_extended'))
thr_params.do_extended = false; thr_params.do_extended = false;
end end
if (~isfield(thr_params, 'percent_of_peak'))
thr_params.percent_of_peak = 2.5;
end
end end
function grain_seg = thresholdAutoSingleGrain(obj, grain_rec) function grain_seg = thresholdAutoSingleGrain(obj, grain_rec)
...@@ -467,7 +471,7 @@ classdef GtThreshold < handle ...@@ -467,7 +471,7 @@ classdef GtThreshold < handle
centery = round(seed(2) - size(vol, 2) * peak_region_fact) : round(seed(2) + size(vol, 2) * peak_region_fact); centery = round(seed(2) - size(vol, 2) * peak_region_fact) : round(seed(2) + size(vol, 2) * peak_region_fact);
centerz = round(seed(3) - size(vol, 3) * peak_region_fact) : round(seed(3) + size(vol, 3) * peak_region_fact); centerz = round(seed(3) - size(vol, 3) * peak_region_fact) : round(seed(3) + size(vol, 3) * peak_region_fact);
threshold_val = gtImgMeanValue(vol(centerx, centery, centerz)) / 2.5 threshold_val = gtImgMeanValue(vol(centerx, centery, centerz)) / par_thr.percent_of_peak
grain_seg = obj.segmentAndDoMorph(grain_rec, threshold_val, ... grain_seg = obj.segmentAndDoMorph(grain_rec, threshold_val, ...
par_thr.do_morph_recon, seed); par_thr.do_morph_recon, seed);
......
...@@ -544,7 +544,7 @@ classdef GtAssembleVol3D < handle ...@@ -544,7 +544,7 @@ classdef GtAssembleVol3D < handle
% Sample translation % Sample translation
sample_shift = obj.localPar.sample_shift; sample_shift = obj.localPar.sample_shift;
sample_shift_size = size(sample_shift); sample_shift_size = size(sample_shift);
if sample_shift_size(2)<3 if (isempty(sample_shift) || (sample_shift_size(2) < 3))
sample_shift = [0, 0, 0]; sample_shift = [0, 0, 0];
end end
......
...@@ -18,19 +18,21 @@ classdef GtGuiThresholdVolume < GtGuiThresholdGrain ...@@ -18,19 +18,21 @@ classdef GtGuiThresholdVolume < GtGuiThresholdGrain
filter, 'Select file...', ... filter, 'Select file...', ...
fullfile('5_reconstruction', 'volume_mask.mat')); fullfile('5_reconstruction', 'volume_mask.mat'));
thr = GtThreshold(); if (~isempty(filename) && filename)
if (exist('morpho_seed', 'var')) thr = GtThreshold();
seg_struct = thr.volumeThreshold(obj.conf.vol, threshold, morpho_seed); if (exist('morpho_seed', 'var'))
else seg_struct = thr.volumeThreshold(obj.conf.vol, threshold, morpho_seed);
seg_struct = thr.volumeThreshold(obj.conf.vol, threshold); else
end seg_struct = thr.volumeThreshold(obj.conf.vol, threshold);
seg_struct.vol = zeros(size(obj.conf.vol), 'like', seg_struct.seg); end
seg_struct.vol = gtPlaceSubVolume(seg_struct.vol, seg_struct.seg, seg_struct.segbb(1:3)); seg_struct.vol = zeros(size(obj.conf.vol), 'like', seg_struct.seg);
seg_struct.vol = gtPlaceSubVolume(seg_struct.vol, seg_struct.seg, seg_struct.segbb(1:3));
if (filerIndex == 1) if (filerIndex == 1)
save(fullfile(pathname, filename), '-struct', 'seg_struct', '-v7.3'); save(fullfile(pathname, filename), '-struct', 'seg_struct', '-v7.3');
else else
edf_write(seg_struct.vol, fullfile(pathname, filename)); edf_write(seg_struct.vol, fullfile(pathname, filename));
end
end end
end end
end end
......
...@@ -21,5 +21,5 @@ function par_rec = gtRecDefaultParameters(varargin) ...@@ -21,5 +21,5 @@ function par_rec = gtRecDefaultParameters(varargin)
% Grain segmentation related values % Grain segmentation related values
par_rec.thresholding = struct( ... par_rec.thresholding = struct( ...
'percentile', 20, 'do_morph_recon', true, ... 'percentile', 20, 'do_morph_recon', true, ...
'num_iter', 0, 'iter_factor', 1); 'percent_of_peak', 2.5, 'num_iter', 0, 'iter_factor', 1);
end end
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