31 #define M_SQRT2PI 2.50662827463100050241576528481104525
66 {{0.48145, 0.971}, {0.48145, -0.971}},
67 {{-0.44645, 0.5105}, {-0.44645, -0.5105}, {1.898, 0}},
68 {{0.84, 1.8675}, {0.84, -1.8675},
69 {-0.34015, -0.1299}, {-0.34015, 0.1299}}
72 {{1.26, 0.8448}, {1.26, -0.8448}},
73 {{1.512, 1.475}, {1.512, -1.475}, {1.556, 0}},
74 {{1.783, 0.6318}, {1.783, -0.6318},
75 {1.723, 1.997}, {1.723, -1.997}}
80 double accum, accum_denom = 1.0;
84 for (k = 0; k < K; ++k)
86 double temp = exp(-lambda[K -
DERICHE_MIN_K][k].real / sigma);
98 for (k = 1; k < K; ++k)
104 for (k = 1; k <= K; ++k)
105 accum_denom += c->
a[k];
107 for (k = 0, accum = 0.0; k < K; ++k)
112 for (k = 1, accum = 0.0; k <= K; ++k)
120 c->max_iter = (
num)ceil(10 * sigma);
156 for (k = 1; k < K; ++k)
158 b[k] =
c_mul(beta[k], b[k-1]);
160 for (j = k - 1; j > 0; --j)
163 for (j = 0; j <= k; ++j)
166 a[k + 1] =
c_mul(beta[k], a[k]);
168 for (j = k; j > 0; --j)
172 for (k = 0; k < K; ++k)
174 result_b[k] = (
num)(b[k].real / denom);
175 result_a[k + 1] = (
num)a[k + 1].real;
212 num *dest,
num *buffer,
const num *src,
long N,
long stride)
214 const long stride_2 = stride * 2;
215 const long stride_3 = stride * 3;
216 const long stride_4 = stride * 4;
217 const long stride_N = stride * N;
218 num *y_causal, *y_anticausal;
221 assert(dest && buffer && src && buffer != src && N > 0 && stride != 0);
231 y_anticausal = buffer + N;
249 for (n = 2, i = stride_2; n < N; ++n, i += stride)
250 y_causal[n] = c.
b_causal[0] * src[i]
252 - c.
a[1] * y_causal[n - 1]
253 - c.
a[2] * y_causal[n - 2];
256 for (n = 3, i = stride_3; n < N; ++n, i += stride)
257 y_causal[n] = c.
b_causal[0] * src[i]
260 - c.
a[1] * y_causal[n - 1]
261 - c.
a[2] * y_causal[n - 2]
262 - c.
a[3] * y_causal[n - 3];
265 for (n = 4, i = stride_4; n < N; ++n, i += stride)
266 y_causal[n] = c.
b_causal[0] * src[i]
270 - c.
a[1] * y_causal[n - 1]
271 - c.
a[2] * y_causal[n - 2]
272 - c.
a[3] * y_causal[n - 3]
273 - c.
a[4] * y_causal[n - 4];
292 for (n = 2, i = stride_N - stride_3; n < N; ++n, i -= stride)
295 - c.
a[1] * y_anticausal[n - 1]
296 - c.
a[2] * y_anticausal[n - 2];
299 for (n = 3, i = stride_N - stride_4; n < N; ++n, i -= stride)
303 - c.
a[1] * y_anticausal[n - 1]
304 - c.
a[2] * y_anticausal[n - 2]
305 - c.
a[3] * y_anticausal[n - 3];
308 for (n = 4, i = stride_N - stride * 5; n < N; ++n, i -= stride)
313 - c.
a[1] * y_anticausal[n - 1]
314 - c.
a[2] * y_anticausal[n - 2]
315 - c.
a[3] * y_anticausal[n - 3]
316 - c.
a[4] * y_anticausal[n - 4];
321 for (n = 0, i = 0; n < N; ++n, i += stride)
322 dest[i] = y_causal[n] + y_anticausal[N - n - 1];
349 int width,
int height,
int num_channels)
351 long num_pixels = ((long)width) * ((long)height);
354 assert(dest && buffer && src && num_pixels > 0);
357 for (channel = 0; channel < num_channels; ++channel)
360 const num *src_y = src;
363 for (y = 0; y < height; ++y)
366 dest_y, buffer, src_y, width, 1);
372 for (x = 0; x < width; ++x)
374 dest + x, buffer, dest + x, height, width);