2 //////////////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation. //
7 // This program is distributed in the hope that it will be useful, but //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
10 // General Public License for more details. //
12 // You should have received a copy of the GNU General Public License //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
15 // Written by Francois Fleuret //
16 // (C) Ecole Polytechnique Federale de Lausanne //
17 // Contact <pom@epfl.ch> for comments & bug reports //
18 //////////////////////////////////////////////////////////////////////////////////
20 #ifndef INTEGRAL_PROBA_VIEW_H
21 #define INTEGRAL_PROBA_VIEW_H
23 #include "proba_view.h"
24 #include "integral_array.h"
26 class IntegralProbaView : public IntegralArray<scalar_t> {
28 IntegralProbaView(int view_width, int view_height) : IntegralArray<scalar_t>(view_width, view_height) {};
30 // Computes the integral image and returns the sum of all the
31 // original image pixels
33 inline scalar_t compute_sum(const ProbaView *m) {
34 scalar_t *p = content, *pm = m->content;
35 for(int x = 0; x < height; x++) *(p++) = 0;
37 register scalar_t st = 0;
39 for(register int y = 1; y < width; y++) {
41 for(register int x = 0; x < height - 1; x++) {
43 *p = sl + *(p - height);
52 // Computes the integral image and returns the sum of (2m-1)*b
54 inline scalar_t compute_sum(const ProbaView *m, const ProbaView *b) {
55 scalar_t *p = content, *pm = m->content, *pb = b->content;
57 for(int x = 0; x < height; x++) *(p++) = 0;
61 for(int y = 1; y < width; y++) {
63 for(int x = 0; x < height - 1; x++) {
65 sl += *(pm++) * *(pb++);
66 *p = sl + *(p - height);