X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=utilities_LW%2FFresnelTransform_2D.m;fp=utilities_LW%2FFresnelTransform_2D.m;h=770ec46e3ab99f7b3e5b6add62d8218b549ef30d;hb=d0401c49b6b7511cfdaa0534b78bd3c5b2b0637a;hp=0000000000000000000000000000000000000000;hpb=f8358f5ec65f099f3080043580ef861c3fd3ba2e;p=CreaPhase.git diff --git a/utilities_LW/FresnelTransform_2D.m b/utilities_LW/FresnelTransform_2D.m new file mode 100644 index 0000000..770ec46 --- /dev/null +++ b/utilities_LW/FresnelTransform_2D.m @@ -0,0 +1,68 @@ +## Copyright (C) 2015 Loriane Weber +## +## 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 Octave; see the file COPYING. If not, see +## . + +## FresnelTransform + +## Author: Loriane Weber +## Created: 2015-07-01 + + +function Id = FresnelTransform_2D(ph, B, D, lambda, oversamp, ftot, gtot) + +[m, n]=size(ph); +[m_a, n_a] = size(B); + +% check dimensions +if (m_a != m || n_a != n) + disp('error in the dimensions !! Phi and B should have the same dimension') +return; +end + +u = exp(-B).*exp(+i.*ph); + +% propagator for the distance D +Pd = exp(-i*pi*lambda*D*(ftot.^2+gtot.^2)); % ifftshift +ud = ones(2*m, 2*n); +ud(1:m,1:n) = u; + +ud=fft2(ud); + +ud = ud.*(Pd)'; +ud = ifft2(ud); + +ud = ud(1:m,1:n); +Id = abs(ud).^2; + + if oversamp==2 + ipf = [0.25 0.5 0.25; + 0.50 1.0 0.50; + 0.25 0.5 0.25]; + Idd = conv2(Id,ipf,'same')./conv2(ones(size(Id)),ipf,'same'); + Idd = Idd(oversamp:oversamp:end, oversamp:oversamp:end); + Id=Idd; + elseif oversamp ==4 + + ipf = [0.25 0.5 0.5 0.5 0.25; + 0.50 1.0 1.0 1.0 0.50; + 0.50 1.0 1.0 1.0 0.50; + 0.50 1.0 1.0 1.0 0.50; + 0.25 0.5 0.5 0.5 0.25]; + Idd = conv2(Id,ipf,'same')./conv2(ones(size(Id)),ipf,'same'); + Idd = Idd(oversamp:oversamp:end, oversamp:oversamp:end); + Id=Idd; + end % end binning detector + +endfunction