core/vnl/algo/vnl_fft_2d.h
Go to the documentation of this file.
00001 // This is core/vnl/algo/vnl_fft_2d.h
00002 #ifndef vnl_fft_2d_h_
00003 #define vnl_fft_2d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief In-place 2D fast Fourier transform
00010 // \author fsm
00011 
00012 #include <vnl/vnl_matrix.h>
00013 #include <vnl/algo/vnl_fft_base.h>
00014 
00015 //: In-place 2D fast Fourier transform
00016 
00017 template <class T>
00018 struct vnl_fft_2d : public vnl_fft_base<2, T>
00019 {
00020   typedef vnl_fft_base<2, T> base;
00021 
00022   //: constructor takes size of signal.
00023   vnl_fft_2d(int M, int N) {
00024     base::factors_[0].resize(M);
00025     base::factors_[1].resize(N);
00026   }
00027 
00028   //: dir = +1/-1 according to direction of transform.
00029   void transform(vnl_matrix<vcl_complex<T> > &signal, int dir)
00030   { base::transform(signal.data_block(), dir); }
00031 
00032   //: forward FFT
00033   void fwd_transform(vnl_matrix<vcl_complex<T> > &signal)
00034   { transform(signal, +1); }
00035 
00036   //: backward (inverse) FFT
00037   void bwd_transform(vnl_matrix<vcl_complex<T> > &signal)
00038   { transform(signal, -1); }
00039 
00040   //: return size of signal.
00041   unsigned rows() const { return base::factors_[0].number(); }
00042   unsigned cols() const { return base::factors_[1].number(); }
00043 };
00044 
00045 #endif // vnl_fft_2d_h_