]> Creatis software - CreaPhase.git/blobdiff - utilities_LW/FresnelTransform_1D.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / FresnelTransform_1D.m
diff --git a/utilities_LW/FresnelTransform_1D.m b/utilities_LW/FresnelTransform_1D.m
new file mode 100644 (file)
index 0000000..6a5d8ed
--- /dev/null
@@ -0,0 +1,53 @@
+## 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
+## <http://www.gnu.org/licenses/>.
+
+## FresnelTransform
+
+## Author: Loriane Weber <lweber@hpc2-0601>
+## Created: 2015-07-01
+
+
+function [FrIm] = FresnelTransform_1D(ph, B, D, lambda, oversamp, ftot)
+
+[m, n]=size(ph);
+u = exp(-B).*exp(+i*ph);
+ftot=ftot';
+
+Pd = exp(-i*pi*lambda*D*(ftot.^2)); 
+
+ud = ones(size(ftot, 1), 1);
+ud(1:m,1) = u;
+
+ud= ifft( fft(ud).*Pd );
+ud=ud(1:m, 1);
+FrIm = abs(ud).^2;
+%keyboard
+       if oversamp==2
+               ipf = [0.5 1 0.5];
+               Idd = conv2(FrIm,ipf,'same')./conv2(ones(size(FrIm)),ipf,'same');
+               Idd = Idd(oversamp:oversamp:end, :);
+               FrIm=Idd; 
+       elseif oversamp==4
+               ipf = [0.5 1 1 1 0.5 ];
+               Idd = conv2(FrIm,ipf,'same')./conv2(ones(size(FrIm)),ipf,'same');
+               Idd = Idd(oversamp:oversamp:end, :);
+               % smooth the data
+               %ipf = [0.5 1 0.5]; % modelise le binning du detecteur
+               %Idd = conv(Idd,ipf,'same')./conv(ones(size(Idd)),ipf,'same');
+               FrIm=Idd; 
+       end
+%keyboard
+endfunction