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
25 int width_, height_;
\r
26 int left, top, x_zero, y_zero;
\r
27 fftw_complex *img_spc;
\r
28 fftw_complex *frq_spc;
\r
29 void construct_default();
\r
34 FFT2(int width, int height);
\r
35 FFT2(const Image &source);
\r
36 FFT2(const Matrix &source);
\r
37 FFT2(const Matrix &reali, const Matrix &imagi);
\r
40 void set(int wid, int hei);
\r
41 void set(const Image &source);
\r
42 void set(const Matrix &source);
\r
43 void set(const Matrix &reali, const Matrix &imagi);
\r
44 void setSpectrum(const Matrix &reali, const Matrix &imagi);
\r
46 // Accesser to elements
\r
47 int freqX(int x) const;
\r
48 int freqY(int y) const;
\r
50 double pix(int x, int y, double l);
\r
51 double pix(int x, int y, const Color &c);
\r
52 double getPix(int x, int y);
\r
55 double setDC(double l);
\r
57 // Core FFT Execution
\r
60 void normalizeFFT();
\r
61 //Matrix normalizeMichelson(const Matrix &matrix);
\r
62 //Matrix normalizeRMS(const Matrix &matrix);
\r
65 void filtering(const Matrix &filter);
\r
66 void filtering(double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
68 // Visualizer (read only)
\r
69 void getImage(Image &absolute);
\r
70 void getSpectrum(Image &absolute, double gamma);
\r
71 void getImage(Matrix &absolute);
\r
72 void getSpectrum(Matrix &absolute, double gamma = 1.0);
\r
73 void getImage(Matrix &reali, Matrix &imagi);
\r
74 void getSpectrum(Matrix &reali, Matrix &imagi);
\r
79 static void getSpectrumExec(FFT2 &tmp, Image &result, double gamma);
\r
80 static void getRawSpectrumExec(FFT2 &tmp, Image &reali, Image &imagi, double gamma);
\r
82 static void getSpectrum(const Image &source, Image &result, double gamma);
\r
83 static void getSpectrum(const Matrix &source, Image &result, double gamma);
\r
84 static void getSpectrum(const Image &source, Image &reali, Image &imagi, double gamma);
\r
85 static void getSpectrum(const Matrix &source, Image &reali, Image &imagi, double gamma);
\r
87 static void filterImageExec(FFT2 &tmp, Image &result, const Matrix &carnel);
\r
89 static void filterImage(const Image &source, Image &result, const Matrix &carnel);
\r
90 static void filterImage(const Matrix &source, Image &result, const Matrix &carnel);
\r
91 static void filterImage(const Image &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
92 static void filterImage(const Matrix &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
93 static Matrix makeFilter(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double half_power_width = 0.0625);
\r
94 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
95 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
98 static void copyBoxSpectrum(FFT2 &source, int s_left, int s_top, FFT2 &target, int t_left, int t_top, int width, int height);
\r
100 static void resizeImage(const Image &source, Image &result, int new_width, int new_height);
\r
102 static int originFor(int size);
\r
108 int width_, height_, depth_, image_size_;
\r
109 int left, top, front, x_zero, y_zero, z_zero;
\r
110 fftw_complex *img_spc;
\r
111 fftw_complex *frq_spc;
\r
116 FFTW3D(int wid, int hei, int dep);
\r
117 FFTW3D(const Image *source, int framsize);
\r
118 FFTW3D(const Matrix *source, int framsize);
\r
120 void set(int wid, int hei, int dep);
\r
121 void set(const Image *source, int framsize);
\r
122 void set(const Matrix *source, int framsize);
\r
124 int freqX(int x) const;
\r
125 int freqY(int y) const;
\r
126 int freqT(int t) const;
\r
128 double pix(int x, int y, int z, double l);
\r
129 double pix(int x, int y, int z, const Color &c);
\r
130 double getPix(int x, int y, int z);
\r
133 double setDC(double l);
\r
137 //FFT2 filter(const Matrix &filter);
\r
139 void normalizeFFT();
\r
140 //Matrix normalizeMichelson(const Matrix &matrix);
\r
141 //Matrix normalizeRMS(const Matrix &matrix);
\r
142 //void getImage(Image &target);
\r
143 //void getSpectrum(Image &target, double gamma);
\r
144 //void getImage(Matrix &real, Matrix &imag);
\r
145 //void getSpectrum(Matrix &real, Matrix &imag);
\r
146 void drawCloudImage(Drawable &target = *Drawable::prime);
\r
147 void drawCloudSpectrum(Point c, double gamma, Drawable &target = *Drawable::prime);
\r
149 void filtering(const Matrix &filter);
\r
150 void filtering(double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
153 static void getSpectrumExec(FFT2 &tmp, Image &result, double gamma);
\r
155 static void getSpectrum(const Image &source, Image &result, double gamma);
\r
156 static void getSpectrum(const Matrix &source, Image &result, double gamma);
\r
158 static void filterImageExec(FFT2 &tmp, Image &result, const Matrix &carnel);
\r
160 static void filterImage(const Image &source, Image &result, const Matrix &carnel);
\r
161 static void filterImage(const Matrix &source, Image &result, const Matrix &carnel);
\r
162 static void filterImage(const Image &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
163 static void filterImage(const Matrix &source, Image &result, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
164 static Matrix makeFilter(int height, int width, double cutoff_lambda1, double cutoff_lambda2, double slope);
\r
168 } /* <- namespace Psycholops */
\r