2 * svrt is the ``Synthetic Visual Reasoning Test'', an image
3 * generator for evaluating classification performance of machine
4 * learning systems, humans and primates.
6 * Copyright (c) 2009 Idiap Research Institute, http://www.idiap.ch/
7 * Written by Francois Fleuret <francois.fleuret@idiap.ch>
9 * This file is part of svrt.
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.
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.
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/>.
27 A simple image class to either load color images, or produce
40 unsigned char ***_bit_plans, **_bit_lines, *_bit_map;
41 static const int RED = 0;
42 static const int GREEN = 1;
43 static const int BLUE = 2;
44 static const int RGB_DEPTH = 3;
52 RGBImage(int width, int height);
53 RGBImage(RGBImage *image, scalar_t scale);
56 inline int width() const { return _width; }
57 inline int height() const { return _height; }
59 inline void set_pixel(int x, int y, unsigned char r, unsigned char g, unsigned char b) {
60 ASSERT(x >= 0 && x < _width && y >= 0 && y < _height);
61 _bit_plans[RED][y][x] = r;
62 _bit_plans[GREEN][y][x] = g;
63 _bit_plans[BLUE][y][x] = b;
66 inline unsigned char pixel(int x, int y, int d) {
67 ASSERT(x >= 0 && x < _width && y >= 0 && y < _height && d >= 0 && d < RGB_DEPTH);
68 return _bit_plans[d][y][x];
71 virtual void read_png(const char *filename);
72 virtual void write_png(const char *filename);
74 virtual void read_jpg(const char *filename);
75 virtual void write_jpg(const char *filename, int quality);
77 virtual void draw_line(int thickness,
78 unsigned char r, unsigned char g, unsigned char b,
79 scalar_t x0, scalar_t y0, scalar_t x1, scalar_t y1);
81 virtual void draw_ellipse(int thickness,
82 unsigned char r, unsigned char g, unsigned char b,
83 scalar_t xc, scalar_t yc, scalar_t radius_1, scalar_t radius_2, scalar_t tilt);