X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=pom.git;a=blobdiff_plain;f=integral_proba_view.h;fp=integral_proba_view.h;h=ff164b028142fcc1bced00f9c3a55652f340e599;hp=0000000000000000000000000000000000000000;hb=97a7e68f234cc09807d2d55f550e2516be0e9093;hpb=48c9926a2ed03737a3b024a85cda348caebf4cfe
diff --git a/integral_proba_view.h b/integral_proba_view.h
new file mode 100644
index 0000000..ff164b0
--- /dev/null
+++ b/integral_proba_view.h
@@ -0,0 +1,75 @@
+
+//////////////////////////////////////////////////////////////////////////////////
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the version 3 of the GNU General Public License //
+// as published by the Free Software Foundation. //
+// //
+// This program is distributed in the hope that it will be useful, but //
+// WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
+// General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+// //
+// Written by Francois Fleuret //
+// (C) Ecole Polytechnique Federale de Lausanne //
+// Contact for comments & bug reports //
+//////////////////////////////////////////////////////////////////////////////////
+
+#ifndef INTEGRAL_PROBA_VIEW_H
+#define INTEGRAL_PROBA_VIEW_H
+
+#include "proba_view.h"
+#include "integral_array.h"
+
+class IntegralProbaView : public IntegralArray {
+public:
+ IntegralProbaView(int view_width, int view_height) : IntegralArray(view_width, view_height) {};
+
+ // Computes the integral image and returns the sum of all the
+ // original image pixels
+
+ inline scalar_t compute_sum(const ProbaView *m) {
+ scalar_t *p = content, *pm = m->content;
+ for(int x = 0; x < height; x++) *(p++) = 0;
+
+ register scalar_t st = 0;
+ register scalar_t sl;
+ for(register int y = 1; y < width; y++) {
+ sl = 0; *(p++) = sl;
+ for(register int x = 0; x < height - 1; x++) {
+ sl += *(pm++);
+ *p = sl + *(p - height);
+ p++;
+ }
+ st += sl;
+ }
+
+ return st;
+ }
+
+ // Computes the integral image and returns the sum of (2m-1)*b
+
+ inline scalar_t compute_sum(const ProbaView *m, const ProbaView *b) {
+ scalar_t *p = content, *pm = m->content, *pb = b->content;
+
+ for(int x = 0; x < height; x++) *(p++) = 0;
+
+ scalar_t st = 0;
+ register scalar_t sl;
+ for(int y = 1; y < width; y++) {
+ sl = 0; *(p++) = 0;
+ for(int x = 0; x < height - 1; x++) {
+ st -= *pb;
+ sl += *(pm++) * *(pb++);
+ *p = sl + *(p - height);
+ p++;
+ }
+ st += 2 * sl;
+ }
+
+ return st;
+ }
+};
+#endif