diff --git a/4_grains/GtThreshold.m b/4_grains/GtThreshold.m index df14ad61543a8b5202d7af620a7b3dd7c23fb10f..eff7f57429983be4d600de3b2689147d4b894aa3 100644 --- a/4_grains/GtThreshold.m +++ b/4_grains/GtThreshold.m @@ -223,7 +223,7 @@ classdef GtThreshold < handle tmp_seg = obj.thresholdAutoSingleGrainSimpleSearch(cl_sub_recs(ii_g), 0.02); 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.segbb(1:3) - cl_seg(1).segbb(1:3) ); tmp_seg.segbb = cl_seg(1).segbb; @@ -365,6 +365,10 @@ classdef GtThreshold < handle if (~isfield(thr_params, 'do_extended')) thr_params.do_extended = false; end + + if (~isfield(thr_params, 'percent_of_peak')) + thr_params.percent_of_peak = 2.5; + end end function grain_seg = thresholdAutoSingleGrain(obj, grain_rec) @@ -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); 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, ... par_thr.do_morph_recon, seed); diff --git a/5_reconstruction/GtAssembleVol3D.m b/5_reconstruction/GtAssembleVol3D.m index 8c0136d3ce685fe7a271de011942df2a94131356..a9c2bfba83bdb8b3753d461c2c1d6415146f272e 100644 --- a/5_reconstruction/GtAssembleVol3D.m +++ b/5_reconstruction/GtAssembleVol3D.m @@ -544,7 +544,7 @@ classdef GtAssembleVol3D < handle % Sample translation sample_shift = obj.localPar.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]; end diff --git a/5_reconstruction/GtGuiThresholdVolume.m b/5_reconstruction/GtGuiThresholdVolume.m index fda8e9b68b88b68c22b898bfdc7ca7a4013fe501..19bf40faf13bea136229e0e0bd14f470d305f772 100644 --- a/5_reconstruction/GtGuiThresholdVolume.m +++ b/5_reconstruction/GtGuiThresholdVolume.m @@ -18,19 +18,21 @@ classdef GtGuiThresholdVolume < GtGuiThresholdGrain filter, 'Select file...', ... fullfile('5_reconstruction', 'volume_mask.mat')); - thr = GtThreshold(); - if (exist('morpho_seed', 'var')) - seg_struct = thr.volumeThreshold(obj.conf.vol, threshold, morpho_seed); - else - seg_struct = thr.volumeThreshold(obj.conf.vol, threshold); - end - 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 (~isempty(filename) && filename) + thr = GtThreshold(); + if (exist('morpho_seed', 'var')) + seg_struct = thr.volumeThreshold(obj.conf.vol, threshold, morpho_seed); + else + seg_struct = thr.volumeThreshold(obj.conf.vol, threshold); + end + 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) - save(fullfile(pathname, filename), '-struct', 'seg_struct', '-v7.3'); - else - edf_write(seg_struct.vol, fullfile(pathname, filename)); + if (filerIndex == 1) + save(fullfile(pathname, filename), '-struct', 'seg_struct', '-v7.3'); + else + edf_write(seg_struct.vol, fullfile(pathname, filename)); + end end end end diff --git a/5_reconstruction/gtRecDefaultParameters.m b/5_reconstruction/gtRecDefaultParameters.m index cb5dce27fc2194f66bc5e762d9e2e3a9216f2e11..271c09060082166cdda3540b1e581a602c450ba7 100644 --- a/5_reconstruction/gtRecDefaultParameters.m +++ b/5_reconstruction/gtRecDefaultParameters.m @@ -21,5 +21,5 @@ function par_rec = gtRecDefaultParameters(varargin) % Grain segmentation related values par_rec.thresholding = struct( ... 'percentile', 20, 'do_morph_recon', true, ... - 'num_iter', 0, 'iter_factor', 1); + 'percent_of_peak', 2.5, 'num_iter', 0, 'iter_factor', 1); end