dataPreprocess.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. %% Author: Rodrigo de Barros Vimieiro / Aleks Prša
  2. % Date: April, 2018 / May 2022
  3. % rodrigo.vimieiro@gmail.com / alex.prsa@gmail.com
  4. % =========================================================================
  5. %{
  6. % -------------------------------------------------------------------------
  7. % dataPreprocess(data,parameter)
  8. % -------------------------------------------------------------------------
  9. % DESCRIPTION:
  10. % This function pre process the projection images.
  11. %
  12. %
  13. % INPUT:
  14. %
  15. % - data = Projections.
  16. % - parameter = Parameters.
  17. %
  18. % OUTPUT:
  19. %
  20. % - data_mod = Modified image.
  21. % - parameter_mod = Modified parameters.
  22. %
  23. % ---------------------------------------------------------------------
  24. % Copyright (C) <2018> <Rodrigo de Barros Vimieiro>
  25. %
  26. % This program is free software: you can redistribute it and/or modify
  27. % it under the terms of the GNU General Public License as published by
  28. % the Free Software Foundation, either version 3 of the License, or
  29. % (at your option) any later version.
  30. %
  31. % This program is distributed in the hope that it will be useful,
  32. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. % GNU General Public License for more details.
  35. %
  36. % You should have received a copy of the GNU General Public License
  37. % along with this program. If not, see <http://www.gnu.org/licenses/>.
  38. %
  39. %}
  40. % =========================================================================
  41. %% Pre-processing Code
  42. function [data_mod,parameter_mod] = dataPreprocess(data,parameter)
  43. parameter_mod = parameter;
  44. Gap = 200;
  45. meanSlideW = 201;
  46. centerProj = (parameter.nProj+1)/2; % Center projection - 90° projection
  47. if(rem(centerProj,2) == 0)
  48. fprintf('Center projection determination error')
  49. return
  50. end
  51. vertProj = sum(abs(data(:,:,centerProj))); % Horizontal Profile
  52. [~,Ind] = max(diff(movmean(vertProj,meanSlideW))); % Smooth the signal and takes its max positive derivative
  53. Ind = Ind + Gap; % Subtract the ind found to a gap
  54. data_mod = data(:,1:Ind,:);
  55. %data_mod = flip(data_mod, 2); % Switch source position left-to-right
  56. % Modifies parameters based on segmentation
  57. parameter_mod.nu = size(data_mod,2); % Number of pixels (columns)
  58. parameter_mod.nv = size(data_mod,1); % Number of pixels (rows)
  59. parameter_mod.su = parameter_mod.nu.*parameter_mod.du;
  60. parameter_mod.sv = parameter_mod.nv.*parameter_mod.dv;
  61. parameter_mod.us = (parameter_mod.nu-1:-1:0)*parameter_mod.du;
  62. parameter_mod.vs = (-(parameter_mod.nv-1)/2:1:(parameter_mod.nv-1)/2)*parameter_mod.dv;
  63. end