39 assert(c && sigma > 0 && K > 0);
42 c->
r = (long)(0.5 * sqrt((12.0 * sigma * sigma) / K + 1.0) - 0.5);
43 alpha = (2 * c->
r + 1) * (c->
r * (c->
r + 1) - 3.0 * sigma * sigma / K)
44 / (6.0 * (sigma * sigma / K - (c->
r + 1) * (c->
r + 1)));
45 c->
c_1 = alpha / (2.0 * (alpha + c->
r) + 1);
46 c->
c_2 = (1.0 - alpha) / (2.0 * (alpha + c->
r) + 1);
70 const num *src,
long src_stride,
long N,
long r,
num c_1,
num c_2)
75 assert(dest && src && dest != src && N > 0 && r >= 0);
77 for (n = -r; n <= r; ++n)
78 accum += src[src_stride *
extension(N, n)];
80 dest[0] = accum = c_1 * (src[src_stride *
extension(N, r + 1)]
82 + (c_1 + c_2) * accum;
84 for (n = 1; n < N; ++n)
86 accum += c_1 * (src[src_stride *
extension(N, n + r + 1)]
87 - src[src_stride *
extension(N, n - r - 2)])
88 + c_2 * (src[src_stride *
extension(N, n + r)]
89 - src[src_stride *
extension(N, n - r - 1)]);
90 dest[dest_stride * n] = accum;
118 const num *src,
long N,
long stride)
124 } dest, buffer, cur, next;
127 assert(dest_data && buffer_data && src
128 && dest_data != buffer_data && N > 0);
130 dest.data = dest_data;
131 dest.stride = stride;
132 buffer.data = buffer_data;
133 buffer.stride = (buffer_data == src) ? stride : 1;
135 next = (buffer_data == src || (dest_data != src && c.
K % 2 == 1))
143 for (step = 1; step < c.
K; ++step)
146 next = (cur.data == buffer_data) ? dest : buffer;
147 ebox_filter(next.data, next.stride, cur.data, cur.stride,
152 if (next.data != dest_data)
155 memcpy(dest_data, buffer_data,
sizeof(
num) * N);
160 for (n = i = 0; n < N; ++n, i += stride)
161 dest_data[i] = buffer_data[n];
186 const num *src,
int width,
int height,
int num_channels)
188 const long num_pixels = ((long)width) * ((long)height);
191 assert(dest && buffer && src && dest != buffer && num_pixels > 0);
194 for (channel = 0; channel < num_channels; ++channel)
197 const num *src_y = src;
200 for (y = 0; y < height; ++y)
208 for (x = 0; x < width; ++x)