-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathmisc_01_integralImage.cpp
More file actions
22 lines (21 loc) · 943 Bytes
/
misc_01_integralImage.cpp
File metadata and controls
22 lines (21 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "misc_01_integralImage.h"
namespace misc{
std::shared_ptr<Eigen::MatrixXd> makeIntegralImage(const Eigen::MatrixXd& input){
auto output = std::shared_ptr<Eigen::MatrixXd>(new Eigen::MatrixXd(input.rows(), input.cols()));
(*output) << Eigen::MatrixXd::Zero(input.rows(), input.cols());
for (int r = 0; r < input.rows(); r++){
for (int c = 0; c < input.cols(); c++){
if (r == 0 && c == 0){
(*output)(r, c) = input(r, c);
} else if (r == 0) {
(*output)(r, c) = input(r, c) + (*output)(r, c - 1);
} else if (c == 0){
(*output)(r, c) = input(r, c) + (*output)(r - 1, c);
} else {
(*output)(r, c) = input(r, c) + (*output)(r, c - 1) + (*output)(r - 1, c) - (*output)(r - 1, c - 1);
}
}
}
return output;
}
}