Simplified things.
[svrt.git] / shape.h
1 /*
2  *  svrt is the ``Synthetic Visual Reasoning Test'', an image
3  *  generator for evaluating classification performance of machine
4  *  learning systems, humans and primates.
5  *
6  *  Copyright (c) 2009 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of svrt.
10  *
11  *  svrt is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  svrt is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef SHAPE_H
26 #define SHAPE_H
27
28 #include "misc.h"
29 #include "vignette.h"
30
31 class Shape {
32   static const int margin = 1;
33   static const int nb_max_pixels = Vignette::width * Vignette::height;
34   static const scalar_t gap_max = 0.25;
35   int n_pixels1, n_pixels2, n_pixels3, n_pixels4;
36   int nb_pixels;
37   scalar_t xc, yc;
38   scalar_t *x_pixels;
39   scalar_t *y_pixels;
40
41   int generate_part_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius,
42                          scalar_t x1, scalar_t y1, scalar_t x2, scalar_t y2);
43   void generate_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius);
44   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
45   void draw(Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
46
47 public:
48   Shape();
49   ~Shape();
50
51   void randomize(scalar_t radius, scalar_t hole_radius);
52   void copy(Shape *shape);
53   void scale(scalar_t s);
54   void rotate(scalar_t alpha);
55   void symmetrize(scalar_t axis_x, scalar_t axis_y);
56
57   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc);
58   void draw(Vignette *vignette, scalar_t xc, scalar_t yc);
59 };
60
61 #endif