30 #define YVY_NUM_NEWTON_ITERATIONS 6
45 for (k = 0; k < K; ++k)
71 for (k = 0; k < K; ++k)
81 return (2 / q) * sum.real;
100 double sigma,
double q0)
102 double sigma2 = sigma * sigma;
107 q -= (
variance(poles0, K, q) - sigma2)
133 for (k = 1; k < K; ++k)
135 denom[k + 1] =
c_neg(denom[k]);
137 for (j = k; j > 0; --j)
138 denom[j] =
c_sub(
c_mul(denom[j], poles[k]), denom[j - 1]);
140 denom[0] =
c_mul(denom[0], poles[k]);
143 for (k = 1; k <= K; ++k)
144 c[k] =
c_div(denom[k], denom[0]).real;
146 for (c[0] = 1, k = 1; k <= K; ++k)
185 {{1.4165, 1.00829}, {1.4165, -1.00829}, {1.86543, 0}},
186 {{1.13228, 1.28114}, {1.13228, -1.28114},
187 {1.78534, 0.46763}, {1.78534, -0.46763}},
188 {{0.8643, 1.45389}, {0.8643, -1.45389},
189 {1.61433, 0.83134}, {1.61433, -0.83134}, {1.87504, 0}}
194 int i, j, matrix_size;
196 assert(c && sigma > 0 &&
VYV_VALID_K(K) && tol > 0);
203 for (i = 0; i < K; ++i)
210 for (i = 0, matrix_size = K * K; i < matrix_size; ++i)
213 for (i = 0; i < K; ++i)
214 for (A[i + K * i] = 1.0, j = 1; j <= K; ++j)
215 A[i + K *
extension(K, i + j)] += filter[j];
219 for (i = 0; i < matrix_size; ++i)
220 inv_A[i] *= filter[0];
223 for (i = 0; i <= K; ++i)
226 for (i = 0; i < matrix_size; ++i)
227 c->
M[i] = (
num)inv_A[i];
260 num *dest,
const num *src,
long N,
long stride)
262 const long stride_2 = stride * 2;
263 const long stride_3 = stride * 3;
264 const long stride_4 = stride * 4;
265 const long stride_5 = stride * 5;
266 const long stride_N = stride * N;
271 assert(dest && src && N > 0 && stride != 0);
283 for (m = 0; m < c.
K; ++m)
284 dest[stride * m] = q[m];
297 for (i = stride_3; i < stride_N; i += stride)
298 dest[i] = c.
filter[0] * src[i]
299 - c.
filter[1] * dest[i - stride]
300 - c.
filter[2] * dest[i - stride_2]
301 - c.
filter[3] * dest[i - stride_3];
304 for (i = stride_4; i < stride_N; i += stride)
305 dest[i] = c.
filter[0] * src[i]
306 - c.
filter[1] * dest[i - stride]
307 - c.
filter[2] * dest[i - stride_2]
308 - c.
filter[3] * dest[i - stride_3]
309 - c.
filter[4] * dest[i - stride_4];
312 for (i = stride_5; i < stride_N; i += stride)
313 dest[i] = c.
filter[0] * src[i]
314 - c.
filter[1] * dest[i - stride]
315 - c.
filter[2] * dest[i - stride_2]
316 - c.
filter[3] * dest[i - stride_3]
317 - c.
filter[4] * dest[i - stride_4]
318 - c.
filter[5] * dest[i - stride_5];
326 for (m = 0; m < c.
K; ++m)
327 q[m] = dest[stride_N - stride * (c.
K - m)];
331 for (m = 0; m < c.
K; ++m)
335 for (n = 0; n < c.
K; ++n)
336 accum += c.
M[m + c.
K*n] * q[n];
338 dest[stride_N - stride * (c.
K - m)] = accum;
351 for (i = stride_N - stride_4; i >= 0; i -= stride)
352 dest[i] = c.
filter[0] * dest[i]
353 - c.
filter[1] * dest[i + stride]
354 - c.
filter[2] * dest[i + stride_2]
355 - c.
filter[3] * dest[i + stride_3];
358 for (i = stride_N - stride_5; i >= 0; i -= stride)
359 dest[i] = c.
filter[0] * dest[i]
360 - c.
filter[1] * dest[i + stride]
361 - c.
filter[2] * dest[i + stride_2]
362 - c.
filter[3] * dest[i + stride_3]
363 - c.
filter[4] * dest[i + stride_4];
366 for (i = stride_N - stride * 6; i >= 0; i -= stride)
367 dest[i] = c.
filter[0] * dest[i]
368 - c.
filter[1] * dest[i + stride]
369 - c.
filter[2] * dest[i + stride_2]
370 - c.
filter[3] * dest[i + stride_3]
371 - c.
filter[4] * dest[i + stride_4]
372 - c.
filter[5] * dest[i + stride_5];
398 int width,
int height,
int num_channels)
400 const long num_pixels = ((long)width) * ((long)height);
403 assert(dest && src && num_pixels > 0);
406 for (channel = 0; channel < num_channels; ++channel)
409 const num *src_y = src;
412 for (y = 0; y < height; ++y)
420 for (x = 0; x < width; ++x)