Changeset 3356 in Sophya for trunk/SophyaPI/DemoPIApp/fft2d.cc
- Timestamp:
- Oct 23, 2007, 12:17:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/DemoPIApp/fft2d.cc
r2600 r3356 1 #define TF r_8 2 1 3 int nlig = 128; int ncol = 128; 2 TMatrix< r_8> in(nlig,ncol);4 TMatrix<TF> in(nlig,ncol); 3 5 int l,c; 4 6 for(l=40; l<80; l++) 5 7 for(c=40; c<80; c++) { 6 8 double r2 = (l-60.5)*(l-60.5)+(c-60.5)*(c-60.5); 7 in(l,c) = 30.*exp(-r2/9.);9 in(l,c) = (TF)30.*exp(-r2/9.); 8 10 } 9 11 // Le dernier argument de RandomSequence est le sigma du bruit 10 12 // Si on veut rajouter du bruit, decommenter les 3 lignes suivantes 11 TMatrix< r_8> noise(nlig,ncol);13 TMatrix<TF> noise(nlig,ncol); 12 14 noise = RandomSequence(RandomSequence::Gaussian, 0., 0.5); 13 15 in += noise; 14 TMatrix< complex< r_8> > fftin;16 TMatrix< complex<TF> > fftin; 15 17 FFTWServer ffts; 16 18 ffts.setNormalize(true); … … 25 27 // dans la seconde moitie du tableau en numero de ligne 26 28 int kx, ky; 27 TMatrix< complex< r_8> > fftfb(fftin.NRows(), fftin.NCols());28 TMatrix< complex< r_8> > fftfd(fftin.NRows(), fftin.NCols());29 TMatrix< complex<TF> > fftfb(fftin.NRows(), fftin.NCols()); 30 TMatrix< complex<TF> > fftfd(fftin.NRows(), fftin.NCols()); 29 31 // fb : Filtrage brutal , fd : Filtrage doux 30 32 for(ky=0; ky<fftin.NRows(); ky++) … … 34 36 if (ky > fftin.NRows()/2) kyy = fftin.NRows()-ky; 35 37 double kr = sqrt((double)kx*kx+kyy*kyy); 36 complex< double> att;38 complex<TF> att; 37 39 // Filtrage brutal fonction en escalier 38 if (kr < 10) att = complex< double>(0.5,0.);40 if (kr < 10) att = complex<TF>((TF)0.5, (TF)0.); 39 41 else att = complex<double>(1., 0.); 40 42 fftfb(ky, kx) = fftin(ky, kx) * att ; 41 43 // Filtrage doux sous forme de 1-exp(-alpha k_r) 42 att = complex< double>(1.-exp(-kr*0.1),0.);44 att = complex<TF>((TF)(1.-exp(-kr*0.1)), (TF)0.); 43 45 fftfd(ky, kx) = fftin(ky, kx) * att ; 44 46 } 45 TMatrix< r_8> infb(nlig,ncol);46 TMatrix< r_8> infd(nlig,ncol);47 TMatrix<TF> infb(nlig,ncol); 48 TMatrix<TF> infd(nlig,ncol); 47 49 // FFTBackward -- Attention, le tableau des coefficient de Fourier 48 50 // est modifie - On en fait une copie 49 TMatrix< complex< r_8> > fftf(fftin.NRows(), fftin.NCols());51 TMatrix< complex<TF> > fftf(fftin.NRows(), fftin.NCols()); 50 52 // Pour le filtre brutal 51 53 fftf = fftfb;
Note:
See TracChangeset
for help on using the changeset viewer.