Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FFT2D.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #ifndef __2DFFT_hh__
27 #define __2DFFT_hh__
28 
29 #include <bias_config.h>
30 #ifndef BIAS_HAVE_FFTW3
31 # error You need BIAS_HAVE_FFTW3 to use FFT2D. Please enable USE_FFTW3 and recompile BIAS.
32 #endif
33 
34 #include "Filter/FilterNTo2N.hh"
35 
36 #include <complex>
37 #include <iostream>
38 #include <fftw3.h>
39 
40 namespace BIAS {
41 
42  /** \class FFT2D
43  * \brief Wrapper to the fftw3 library adapted for 2D image filtering
44  * \note Use fast as follows:
45  * - call Init() with appropriate size
46  * - call Filter()
47  * \author evers and koeser, jw, oniemann
48  * \date 2004/01, 2006 */
49  template <class InputStorageType, class OutputStorageType>
50  class BIASImage_EXPORT FFT2D /*: public FilterNTo2N<InputStorageType, OutputStorageType>*/
51  {
52  public:
53  FFT2D();
54  virtual ~FFT2D();
55 
56  /** @brief initializes for forward transformation on complete image.
57  This may take some time
58  (i.e. several seconds) since some measurements are done. */
59  void Init(int width, int height);
60 
61  /** call this before a second call to Init() */
62  void Release();
63 
64  /** dst.GetChannelCount()==2*src.GetCHannelCount()
65  The result is not normalized! */
66  virtual int Filter(const Image<InputStorageType>& src,
68 
69  /** dstX.GetChannelCount()==src.GetCHannelCount()
70  The result is not normalized! */
71  virtual int Filter(const Image<InputStorageType>& src,
74 
75  /** Transform forward and get absolute value from complex result
76  The result is not normalized! */
77  virtual int TransformAbs(const Image<InputStorageType>& src,
79  virtual int TransformLogAbs(const Image<InputStorageType>& src,
81  virtual int TransformPhase(const Image<InputStorageType>& src,
83 
84  /** Transform reverse, src _must_ be of _SizeX,_OutSizeY,2
85  */
86  virtual int TransformReverse(const Image<OutputStorageType>& src,
88 
89  /** Normalize output after transformation */
90  virtual int Normalize(Image<OutputStorageType>& dst);
91 
92  virtual int CrossPowerSpectrum(const Image<InputStorageType>& src1,
93  const Image<InputStorageType>& src2,
95 
96 
97  protected:
98 
99  virtual int Forward_(const Image<InputStorageType>& src);
100 
101  // assumes src.GetChannelCount() == 2
102  virtual int Reverse_(const Image<OutputStorageType>& src);
103 
104  virtual void GetBordersValid_(int& border_x, int& border_y) const;
105 
106  fftw_complex *_out;
107  double *_in;
108  fftw_plan _p_forward, _p_reverse;
109  // size of input _Size = SizeX * _SizeY
110  // Warning: _SizeX is height and _SizeY is width of image
111  int _SizeX, _SizeY, _Size;
113  int _OutNum; // length of output = _SizeX * (_SizeY/2 + 1)
114  };
115 
116 } // namespace
117 
118 #endif // __FFT2D_hh__
int _OutSizeY
Definition: FFT2D.hh:112
double * _in
Definition: FFT2D.hh:107
int _SizeY
Definition: FFT2D.hh:111
fftw_complex * _out
Definition: FFT2D.hh:106
fftw_plan _p_reverse
Definition: FFT2D.hh:108
int _OutNum
Definition: FFT2D.hh:113
Wrapper to the fftw3 library adapted for 2D image filtering.
Definition: FFT2D.hh:50