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 pysvrt. If not, see <http://www.gnu.org/licenses/>.
25 #include "vision_problem_11.h"
28 VisionProblem_11::VisionProblem_11() { }
30 void VisionProblem_11::generate(int label, Vignette *vignette) {
32 int xs, ys, i = 0, pxs, pys;
33 const int dist_min = Vignette::width/12;
34 int nb_attempts, max_nb_attempts = 100;
48 for(int s = 0; nb_attempts < max_nb_attempts && s < nb_shapes; s++) {
57 shape.randomize(big_part_size / 2, big_part_hole_size / 2);
59 shape.randomize(small_part_size / 2, small_part_hole_size / 2);
62 if(nb_shapes == 2 || s == 0 || label == 0) {
63 xs = int(random_uniform_0_1() * Vignette::width);
64 ys = int(random_uniform_0_1() * Vignette::height);
66 xs = pxs + int(4 * (random_uniform_0_1() - 0.5) * small_part_hole_size);
67 ys = pys + int(4 * (random_uniform_0_1() - 0.5) * small_part_hole_size);
71 } while(nb_attempts < max_nb_attempts &&
72 shape.overwrites(&tmp, xs, ys));
74 if(nb_attempts < max_nb_attempts) {
75 shape.draw(s, &tmp, xs, ys);
76 tmp.fill(xs, ys, 128);
77 i = tmp.intersection(&mask);
81 } while(nb_attempts < max_nb_attempts &&
83 ((label == 0 && i > 0) || (label == 1 && (i < 1 || i > 4))));
85 if(nb_attempts < max_nb_attempts) {
86 shape.draw(s, vignette, xs, ys);
90 for(int k = 0; k < dist_min; k++) tmp.grow();
93 mask.superpose(&mask, &tmp);
96 } while(nb_attempts >= max_nb_attempts);