123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- %% Author: Rodrigo de Barros Vimieiro / Aleks Prša
- % Date: April, 2018 / May 2022
- % rodrigo.vimieiro@gmail.com / alex.prsa@gmail.com
- % =========================================================================
- %{
- % -------------------------------------------------------------------------
- % dataPreprocess(data,parameter)
- % -------------------------------------------------------------------------
- % DESCRIPTION:
- % This function pre process the projection images.
- %
- %
- % INPUT:
- %
- % - data = Projections.
- % - parameter = Parameters.
- %
- % OUTPUT:
- %
- % - data_mod = Modified image.
- % - parameter_mod = Modified parameters.
- %
- % ---------------------------------------------------------------------
- % Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
- %
- % This program is free software: you can redistribute it and/or modify
- % it under the terms of the GNU General Public License as published by
- % the Free Software Foundation, either version 3 of the License, or
- % (at your option) any later version.
- %
- % This program is distributed in the hope that it will be useful,
- % but WITHOUT ANY WARRANTY; without even the implied warranty of
- % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- % GNU General Public License for more details.
- %
- % You should have received a copy of the GNU General Public License
- % along with this program. If not, see <http://www.gnu.org/licenses/>.
- %
- %}
- % =========================================================================
- %% Pre-processing Code
- function [data_mod,parameter_mod] = dataPreprocess(data,parameter)
- parameter_mod = parameter;
- Gap = 200;
- meanSlideW = 201;
- centerProj = (parameter.nProj+1)/2; % Center projection - 90° projection
- if(rem(centerProj,2) == 0)
- fprintf('Center projection determination error')
- return
- end
- vertProj = sum(abs(data(:,:,centerProj))); % Horizontal Profile
- [~,Ind] = max(diff(movmean(vertProj,meanSlideW))); % Smooth the signal and takes its max positive derivative
- Ind = Ind + Gap; % Subtract the ind found to a gap
- data_mod = data(:,1:Ind,:);
- %data_mod = flip(data_mod, 2); % Switch source position left-to-right
- % Modifies parameters based on segmentation
- parameter_mod.nu = size(data_mod,2); % Number of pixels (columns)
- parameter_mod.nv = size(data_mod,1); % Number of pixels (rows)
- parameter_mod.su = parameter_mod.nu.*parameter_mod.du;
- parameter_mod.sv = parameter_mod.nv.*parameter_mod.dv;
- parameter_mod.us = (parameter_mod.nu-1:-1:0)*parameter_mod.du;
- parameter_mod.vs = (-(parameter_mod.nv-1)/2:1:(parameter_mod.nv-1)/2)*parameter_mod.dv;
- end
|