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/>.
25 #include "vision_problem_8.h"
28 VisionProblem_8::VisionProblem_8() { }
30 void VisionProblem_8::generate(int label, Vignette *vignette) {
31 int x_big, y_big, x_small, y_small;
32 Shape big_shape, small_shape;
41 big_shape.randomize(big_part_size / 2, big_part_hole_size / 2);
42 small_shape.copy(&big_shape);
43 small_shape.scale(0.5);
46 x_big = int(random_uniform_0_1() * Vignette::width);
47 y_big = int(random_uniform_0_1() * Vignette::height);
48 } while(big_shape.overwrites(vignette, x_big, y_big));
51 big_shape.draw(0, vignette, x_big, y_big);
53 vignette->fill(x_big, y_big, 128);
56 vignette->switch_values(128, 255);
58 if(random_uniform_0_1() < 0.5) {
59 vignette->switch_values(128, 255);
61 tmp.randomize(big_part_size / 2, big_part_hole_size / 2);
62 small_shape.copy(&tmp);
63 small_shape.scale(0.5);
69 x_small = int(random_uniform_0_1() * Vignette::width);
70 y_small = int(random_uniform_0_1() * Vignette::height);
71 error = small_shape.overwrites(vignette, x_small, y_small);
73 } while(error && nb_attempts < 10);
76 vignette->replace_value(128, 255);
77 small_shape.draw(1, vignette, x_small, y_small);