Added the images for test.
[pom.git] / proba_view.h
1
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.                                //
6 //                                                                              //
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.                                     //
11 //                                                                              //
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/>.         //
14 //                                                                              //
15 // Written by Francois Fleuret                                                  //
16 // (C) Ecole Polytechnique Federale de Lausanne                                 //
17 // Contact <pom@epfl.ch> for comments & bug reports                             //
18 //////////////////////////////////////////////////////////////////////////////////
19
20 #ifndef PROBA_VIEW_H
21 #define PROBA_VIEW_H
22
23 #include "misc.h"
24 #include "array.h"
25 #include "rgb_image.h"
26
27 class ProbaView : public Array<scalar_t> {
28 public:
29   ProbaView(int view_width, int view_height);
30
31   void from_image(const RGBImage *picture);
32
33   inline void fill(const scalar_t &t) {
34     register scalar_t *s = content;
35     register int i = 0;
36     for(i = 0; i < width * height - 7; i += 8) {
37       *(s++) = t; *(s++) = t; *(s++) = t; *(s++) = t;
38       *(s++) = t; *(s++) = t; *(s++) = t; *(s++) = t;
39     }
40     for(; i < width * height; i++) *(s++) = t;
41   }
42
43   inline void multiply_subarray(int xmin, int ymin, int xmax, int ymax, scalar_t k) {
44     register scalar_t *s = content + xmin * height + ymin;
45     for(register int x = 0; x < xmax - xmin; x++) {
46       for(register int y = 0; y < ymax - ymin; y++) *(s++) *= k;
47       s += height - ymax + ymin;
48     }
49   }
50 };
51
52 #endif