]> Creatis software - CreaPhase.git/blob - utilities_LW/FresnelTransform_1D.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / FresnelTransform_1D.m
1 ## Copyright (C) 2015 Loriane Weber
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with Octave; see the file COPYING.  If not, see
15 ## <http://www.gnu.org/licenses/>.
16
17 ## FresnelTransform
18
19 ## Author: Loriane Weber <lweber@hpc2-0601>
20 ## Created: 2015-07-01
21
22
23 function [FrIm] = FresnelTransform_1D(ph, B, D, lambda, oversamp, ftot)
24
25 [m, n]=size(ph);
26 u = exp(-B).*exp(+i*ph);
27 ftot=ftot';
28
29 Pd = exp(-i*pi*lambda*D*(ftot.^2)); 
30
31 ud = ones(size(ftot, 1), 1);
32 ud(1:m,1) = u;
33
34 ud= ifft( fft(ud).*Pd );
35 ud=ud(1:m, 1);
36 FrIm = abs(ud).^2;
37 %keyboard
38         if oversamp==2
39                 ipf = [0.5 1 0.5];
40                 Idd = conv2(FrIm,ipf,'same')./conv2(ones(size(FrIm)),ipf,'same');
41                 Idd = Idd(oversamp:oversamp:end, :);
42                 FrIm=Idd; 
43         elseif oversamp==4
44                 ipf = [0.5 1 1 1 0.5 ];
45                 Idd = conv2(FrIm,ipf,'same')./conv2(ones(size(FrIm)),ipf,'same');
46                 Idd = Idd(oversamp:oversamp:end, :);
47                 % smooth the data
48                 %ipf = [0.5 1 0.5]; % modelise le binning du detecteur
49                 %Idd = conv(Idd,ipf,'same')./conv(ones(size(Idd)),ipf,'same');
50                 FrIm=Idd; 
51         end
52 %keyboard
53 endfunction