43 template <
typename T1,
typename T2>
44 void integral(
const arma::Mat<T1>& A, arma::Mat<T2>& I)
46 typedef typename arma::uword size_type;
49 I.set_size(A.n_rows, A.n_cols);
52 const T1* ptr = A.memptr();
53 T2* iptr = I.memptr();
55 iptr[0] =
static_cast<T2
>(ptr[0]);
58 for (size_type y = 1 ; y < A.n_rows ; y++)
59 iptr[y] = iptr[y - 1] + static_cast<T2>(ptr[y]);
62 for (size_type x = 1 ; x < A.n_cols ; x++)
63 I.at(0, x) = I.at(0, x - 1) +
static_cast<T2
>(A.at(0, x));
65 const T2* iptr0 = iptr;
66 for (size_type x = 1 ; x < A.n_cols ; x++) {
68 T2* iptr1 = I.colptr(x);
70 for (size_type y = 1 ; y < A.n_rows ; y++) {
71 s +=
static_cast<T2
>(ptr[y]);
72 iptr1[y] = iptr0[y] + s;
83 template <
typename T1,
typename T2,
typename T3>
93 const T1* ptr = img.memptr();
94 T2* sumptr = sum.memptr();
95 T3* sqsumptr = sqsum.memptr();
102 for (size_type y = 0 ; y < img.
height() ; y++) {
103 const T1 it = ptr[y];
113 for (size_type x = 1 ; x < img.
width() ; x++) {
121 T2* sptr0 = sum.colptr(0);
122 T3* sqptr0 = sqsum.colptr(0);
124 for (size_type x = 1 ; x < img.
width() ; x++) {
128 T2* sptr1 = sum.colptr(x);
129 T3* sqptr1 = sqsum.colptr(x);
131 for (size_type y = 0 ; y < img.
height() ; y++) {
136 sptr1[y] = sptr0[y] + s;
138 sqptr1[y] = sqptr0[y] + sq;
void integral(const arma::Mat< T1 > &A, arma::Mat< T2 > &I)
Compute integral.
Definition: integral.hpp:44
A template image class.
Definition: imgproc_aux.hpp:86
void resize(size_type width, size_type height)
Resize image.
Definition: imgproc_aux.hpp:136
size_type height() const
Get image height.
Definition: imgproc_aux.hpp:133
size_type width() const
Get image width.
Definition: imgproc_aux.hpp:130
arma::uword size_type
Definition: imgproc_aux.hpp:92