68 if ((
unsigned)p < (
unsigned)n)
return p;
82 p = n - 1 - (p - n) - delta;
83 }
while ((
unsigned)p >= (unsigned)n);
87 p = (p < 0) ? 0 : n - 1;
91 p -= ((p - n + 1) / n) * n;
105 #define castOp(x) ((x + 128) >> 8)
127 template <
typename T1,
typename T2>
130 const uword KERNEL_SIZE = 5;
137 ivec dummy(out.n_rows); dummy.zeros();
139 for (arma::uword i = 0 ; i < KERNEL_SIZE ; i++)
146 int sx0 = -(int)KERNEL_SIZE / 2, sx = sx0;
148 arma::umat tab(KERNEL_SIZE + 2, 2);
149 uword* lptr = tab.colptr(0),
150 * rptr = tab.colptr(1);
151 for (uword y = 0 ; y <= KERNEL_SIZE + 1 ; y++) {
153 rptr[y] =
borderInterpolate((
int)(y + (out.n_rows - 1) * 2) + sx0, (
int)in.n_rows);
157 for (arma::uword x = 0 ; x < out.n_cols ; x++) {
158 typename T2::elem_type* dst = out.colptr(x);
161 for ( ; sx <= (int)x * 2 + 2 ; sx++) {
162 ivec& col = cols.
next();
163 int* colptr = col.memptr();
166 const typename T2::elem_type* src = in.colptr(
borderInterpolate(sx, (
int)in.n_cols));
168 colptr[0] = src[lptr[2]] * 6 + (src[lptr[1]] + src[lptr[3]]) * 4 + (src[lptr[0]] + src[lptr[4]]);
170 for (arma::uword y = 1 ; y < out.n_rows - 1; y++)
172 colptr[y] = src[y * 2] * 6 +
173 (src[y * 2 - 1] + src[y * 2 + 1]) * 4 +
174 (src[y * 2 - 2] + src[y * 2 + 2]);
177 colptr[out.n_rows - 1] = src[rptr[2]] * 6 +
178 (src[rptr[1]] + src[rptr[3]]) * 4 +
179 (src[rptr[0]] + src[rptr[4]]);
182 const int* col0 = cols[0].memptr();
183 const int* col1 = cols[1].memptr();
184 const int* col2 = cols[2].memptr();
185 const int* col3 = cols[3].memptr();
186 const int* col4 = cols[4].memptr();
209 for (arma::uword y = 0 ; y < out.n_rows ; y++)
211 dst[y] = (
typename T2::elem_type)
castOp(col2[y] * 6 + (col1[y] + col3[y]) * 4 + col0[y] + col4[y]);
arma::uword borderInterpolate(int p, int n, border_type type=reflect101)
Computes the location of an extrapolated pixel.
Definition: pyramid.hpp:65
void pyrDown(const T1 &in, T2 &out)
Blurs an image and downsamples it. This function performs the downsampling step of the Gaussian pyra...
Definition: pyramid.hpp:128
dcb | abcde | dcb
Definition: pyramid.hpp:55
#define castOp(x)
Definition: pyramid.hpp:105
cde | abcde | abc
Definition: pyramid.hpp:54
border_type
Various border types, image boundaries are denoted with '|'.
Definition: pyramid.hpp:48
A minimal implementation of circular buffer class.
Definition: circular_buffer.hpp:45
iii | abcde | iii with some specified 'i'
Definition: pyramid.hpp:51
reference next()
Get next element in the circular buffer.
Definition: circular_buffer.hpp:55
aaa | abcde | eee
Definition: pyramid.hpp:53
not specified
Definition: pyramid.hpp:56
cba | abcde | edc
Definition: pyramid.hpp:52
void push_back(const value_type &item)
Add new last element.
Definition: circular_buffer.hpp:64