28 #define M_PI 3.14159265358979323846264338327950288
54 long N,
long stride,
double sigma)
56 const fftw_r2r_kind dct_2 = FFTW_REDFT10, dct_3 = FFTW_REDFT01;
60 assert(c && dest && src && N > 0 && stride != 0 && sigma > 0);
61 c->forward_plan = c->inverse_plan = NULL;
63 if (!(c->forward_plan =
FFT(plan_many_r2r)(1, &length, 1, (
num *)src,
64 NULL, stride, 0, dest, NULL, stride, 0, &dct_2,
65 FFTW_ESTIMATE | ((src != dest) ? FFTW_PRESERVE_INPUT : 0)))
66 || !(c->inverse_plan =
FFT(plan_many_r2r)(1, &length, 1, dest,
67 NULL, stride, 0, dest, NULL, stride, 0, &dct_3, FFTW_ESTIMATE)))
76 temp = (sigma *
M_PI) / N;
77 c->dims.
one.alpha = (
num)(temp * temp / 2);
79 c->dims.
one.stride = stride;
101 int width,
int height,
int num_channels,
double sigma)
103 const fftw_r2r_kind dct_2[] = {FFTW_REDFT10, FFTW_REDFT10};
104 const fftw_r2r_kind dct_3[] = {FFTW_REDFT01, FFTW_REDFT01};
105 const int dist = width * height;
109 assert(c && dest && src && width > 0 && height > 0 && sigma > 0);
112 c->forward_plan = c->inverse_plan = NULL;
114 if (!(c->forward_plan =
FFT(plan_many_r2r)(2, size, num_channels,
115 (
num *)src, NULL, 1, dist, dest, NULL, 1, dist, dct_2,
116 FFTW_ESTIMATE | ((src != dest) ? FFTW_PRESERVE_INPUT : 0)))
117 || !(c->inverse_plan =
FFT(plan_many_r2r)(2, size, num_channels,
118 dest, NULL, 1, dist, dest, NULL, 1, dist, dct_3, FFTW_ESTIMATE)))
127 temp = (sigma *
M_PI) / width;
128 c->dims.
image.alpha_x = (
num)(temp * temp / 2);
129 temp = (sigma *
M_PI) / height;
130 c->dims.
image.alpha_y = (
num)(temp * temp / 2);
131 c->dims.
image.width = width;
132 c->dims.
image.height = height;
133 c->dims.
image.num_channels = num_channels;
158 assert(c.forward_plan && c.inverse_plan);
161 FFT(execute)(c.forward_plan);
167 num denom = 2 * c.dims.
one.N;
170 for (n = 0; n < c.dims.
one.N; ++n)
172 *c.
dest *= ((
num)exp(-c.dims.
one.alpha * n * n)) / denom;
182 for (channel = 0; channel < c.dims.
image.num_channels; ++channel)
183 for (y = 0; y < c.dims.
image.height; ++y)
185 for (x = 0; x < c.dims.
image.width; ++x)
187 -c.dims.
image.alpha_x * x * x
188 -c.dims.
image.alpha_y * y * y)) / denom;
195 FFT(execute)(c.inverse_plan);
208 FFT(destroy_plan)(c->inverse_plan);
210 FFT(destroy_plan)(c->forward_plan);
213 c->forward_plan = c->inverse_plan = NULL;