2 * psychlops_FFTW_bridge.h
\r
3 * Psychlops Standard Library (Universal)
\r
5 * Last Modified 2010/03/05 by Kenchi HOSOKAWA
\r
6 * (C) 2010 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
\r
10 #ifndef HEADER_PSYCHLOPS_FFTW
\r
11 #define HEADER_PSYCHLOPS_FFTW
\r
13 #include "../../../psychlops_core.h"
\r
17 namespace Psychlops {
\r
19 double log2NormalDistibution(double log_x, double octave_mu, double octave_sigma);
\r
20 double cumulativeLog2NormalDistibution(double log_x, double octave_mu, double octave_sigma);
\r
27 fftw_complex *img_spc;
\r
28 fftw_complex *frq_spc;
\r
29 void construct_default();
\r
35 FFT1(const Matrix &source);
\r
39 void set(const Matrix &source);
\r
41 // Accesser to elements
\r
43 double setDC(double l);
\r
45 // Core FFT Execution
\r
48 void normalizeFFT();
\r
50 void getImage(Matrix &absolute);
\r
51 void getSpectrum(Matrix &absolute, double gamma = 1.0);
\r
52 //void getImage(Matrix &reali, Matrix &imagi);
\r
53 //void getSpectrum(Matrix &reali, Matrix &imagi);
\r
59 int width_, height_;
\r
60 int left, top, x_zero, y_zero;
\r
61 fftw_complex *img_spc;
\r
62 fftw_complex *frq_spc;
\r
63 void construct_default();
\r
68 FFT2(int width, int height);
\r
69 FFT2(const Image &source);
\r
70 FFT2(const Matrix &source);
\r
71 FFT2(const Matrix &reali, const Matrix &imagi);
\r
74 void set(int wid, int hei);
\r
75 void set(const Image &source);
\r
76 void set(const Matrix &source);
\r
77 void set(const Matrix &reali, const Matrix &imagi);
\r
78 void setSpectrum(const Matrix &reali, const Matrix &imagi);
\r
80 // Accesser to elements
\r
81 int freqX(int x) const;
\r
82 int freqY(int y) const;
\r
84 double pix(int x, int y, double l);
\r
85 double pix(int x, int y, const Color &c);
\r
86 double getPix(int x, int y);
\r
89 double setDC(double l);
\r
91 // Core FFT Execution
\r
94 void normalizeFFT();
\r
95 //Matrix normalizeMichelson(const Matrix &matrix);
\r
96 //Matrix normalizeRMS(const Matrix &matrix);
\r
99 void filtering(const Matrix &filter);
\r
100 void filtering(double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
102 // Visualizer (read only)
\r
103 void getImage(Image &absolute);
\r
104 void getSpectrum(Image &absolute, double gamma);
\r
105 void getImage(Matrix &absolute);
\r
106 void getSpectrum(Matrix &absolute, double gamma = 1.0);
\r
107 void getImage(Matrix &reali, Matrix &imagi);
\r
108 void getSpectrum(Matrix &reali, Matrix &imagi);
\r
113 static void getSpectrumExec(FFT2 &tmp, Image &result, double gamma);
\r
114 static void getRawSpectrumExec(FFT2 &tmp, Image &reali, Image &imagi, double gamma);
\r
116 static void getSpectrum(const Image &source, Image &result, double gamma);
\r
117 static void getSpectrum(const Matrix &source, Image &result, double gamma);
\r
118 static void getSpectrum(const Image &source, Image &reali, Image &imagi, double gamma);
\r
119 static void getSpectrum(const Matrix &source, Image &reali, Image &imagi, double gamma);
\r
121 static void filterImageExec(FFT2 &tmp, Image &result, const Matrix &carnel);
\r
123 static void filterImage(const Image &source, Image &result, const Matrix &carnel);
\r
124 static void filterImage(const Matrix &source, Image &result, const Matrix &carnel);
\r
125 static void filterImage(const Image &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
126 static void filterImage(const Matrix &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
127 static Matrix makeFilter(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
128 static Matrix makeFilterSector(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double theta1, double theta2, double half_power_width = 0.0625, double half_power_width_ori = PI/90.0);
\r
129 static Matrix makeFilter(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double cutoff_lambda3, double cutoff_lambda4, double theta1, double theta2, double half_power_width = 0.0625);
\r
132 static void copyBoxSpectrum(FFT2 &source, int s_left, int s_top, FFT2 &target, int t_left, int t_top, int width, int height);
\r
134 static void resizeImage(const Image &source, Image &result, int new_width, int new_height);
\r
136 static int originFor(int size);
\r
142 int width_, height_, depth_, image_size_;
\r
143 int left, top, front, x_zero, y_zero, z_zero;
\r
144 fftw_complex *img_spc;
\r
145 fftw_complex *frq_spc;
\r
150 FFTW3D(int wid, int hei, int dep);
\r
151 FFTW3D(const Image *source, int framsize);
\r
152 FFTW3D(const Matrix *source, int framsize);
\r
154 void set(int wid, int hei, int dep);
\r
155 void set(const Image *source, int framsize);
\r
156 void set(const Matrix *source, int framsize);
\r
158 int freqX(int x) const;
\r
159 int freqY(int y) const;
\r
160 int freqT(int t) const;
\r
162 double pix(int x, int y, int z, double l);
\r
163 double pix(int x, int y, int z, const Color &c);
\r
164 double getPix(int x, int y, int z);
\r
167 double setDC(double l);
\r
171 //FFT2 filter(const Matrix &filter);
\r
173 void normalizeFFT();
\r
174 //Matrix normalizeMichelson(const Matrix &matrix);
\r
175 //Matrix normalizeRMS(const Matrix &matrix);
\r
176 //void getImage(Image &target);
\r
177 //void getSpectrum(Image &target, double gamma);
\r
178 //void getImage(Matrix &real, Matrix &imag);
\r
179 //void getSpectrum(Matrix &real, Matrix &imag);
\r
180 void drawCloudImage(Drawable &target = *Drawable::prime);
\r
181 void drawCloudSpectrum(Point c, double gamma, Drawable &target = *Drawable::prime);
\r
183 void filtering(const Matrix &filter);
\r
184 void filtering(double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
187 static void getSpectrumExec(FFT2 &tmp, Image &result, double gamma);
\r
189 static void getSpectrum(const Image &source, Image &result, double gamma);
\r
190 static void getSpectrum(const Matrix &source, Image &result, double gamma);
\r
192 static void filterImageExec(FFT2 &tmp, Image &result, const Matrix &carnel);
\r
194 static void filterImage(const Image &source, Image &result, const Matrix &carnel);
\r
195 static void filterImage(const Matrix &source, Image &result, const Matrix &carnel);
\r
196 static void filterImage(const Image &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
197 static void filterImage(const Matrix &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
198 static Matrix makeFilter(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
202 } /* <- namespace Psycholops */
\r