Commit ab5d17a4 authored by Zheheng Liu's avatar Zheheng Liu
Browse files

detector l2 norm weight default structure.



Signed-off-by: Zheheng Liu's avatarZheheng Liu <zheheng.liu@esrf.fr>
parent 5a6cf0cd
function detector_l2_norm_weight = gtRecGrainsOptionsDetectorL2NormWeightDefaultParameters(weight_type, weight_coef, acq)
possible_weight_types = {'linear','sqrt','log'};
if ((~exist('weight_type', 'var')) || (~ismember(lower(weight_type), possible_weight_types)))
detector_l2_norm_weight = [];
else
weight_type = lower(weight_type);
if ((~exist('weight_coef', 'var')) || isempty(weight_coef) || (~isnumeric(weight_coef)))
if (~exist('acq', 'var') || isempty(acq))
acq = gtLoadParameters;
acq = acq.acq;
end
weight_coef = sfCalcDarkImagesVariance(acq);
else
weight_coef = weight_coef(1);
end
detector_l2_norm_weight = struct('type', weight_type, 'coefficient', weight_coef);
end
end
function noise_var = sfCalcDarkImagesVariance(acq)
darkend = cell(1, acq.ndark);
for ii_dark = 1:acq.ndark
darkname = fullfile(acq.dir,'0_rawdata',acq.name,sprintf('darkend%04d.edf', ii_dark-1));
darkend{ii_dark} = edf_read(darkname);
end
darkend = cat(3, darkend{:});
dark = sum(darkend, 3) / acq.ndark;
darkend = bsxfun(@minus, darkend, dark);
noise_var = sum(darkend(:) .^ 2) / numel(dark(:)) / (acq.ndark - 1);
end
\ No newline at end of file
Supports Markdown
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