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_6.h"
28 VisionProblem_6::VisionProblem_6() { }
30 void VisionProblem_6::generate(int label, Vignette *vignette) {
31 const int nb_shapes = 4;
32 int xs[nb_shapes], ys[nb_shapes];
33 int shape_number[nb_shapes];
35 ASSERT(nb_shapes == 4);
43 shape1.randomize(part_size/2, hole_size/2);
44 shape2.randomize(part_size/2, hole_size/2);
46 scalar_t xc1, yc1, alpha1;
47 scalar_t xc2, yc2, alpha2;
55 xc1 = random_uniform_0_1() * (Vignette::width - part_size) ;
56 yc1 = random_uniform_0_1() * (Vignette::width - part_size) ;
57 alpha1 = random_uniform_0_1() * M_PI * 2;
58 r = random_uniform_0_1() * (Vignette::width + Vignette::height)/2;
60 xc2 = random_uniform_0_1() * (Vignette::width - part_size) ;
61 yc2 = random_uniform_0_1() * (Vignette::width - part_size) ;
62 alpha2 = random_uniform_0_1() * M_PI * 2;
64 xs[0] = int(xc1 + r * cos(alpha1));
65 ys[0] = int(yc1 + r * sin(alpha1));
66 xs[1] = int(xc1 - r * cos(alpha1));
67 ys[1] = int(yc1 - r * sin(alpha1));
68 xs[2] = int(xc2 + r * cos(alpha2));
69 ys[2] = int(yc2 + r * sin(alpha2));
70 xs[3] = int(xc2 - r * cos(alpha2));
71 ys[3] = int(yc2 - r * sin(alpha2));
74 for(int n = 0; n < nb_shapes; n++) {
75 xs[n] = int(random_uniform_0_1() * (Vignette::width - part_size));
76 ys[n] = int(random_uniform_0_1() * (Vignette::width - part_size));
78 scalar_t d1 = sqrt(sq(xs[0] - xs[1]) + sq(ys[0] - ys[1]));
79 scalar_t d2 = sqrt(sq(xs[2] - xs[3]) + sq(ys[2] - ys[3]));
80 too_ambiguous = abs(d1 - d2) < scalar_t(part_size);
82 } while(too_ambiguous ||
83 cluttered_shapes(part_size, nb_shapes, xs, ys));
88 for(int n = 0; n < nb_shapes; n++) {
89 if(shape_number[n] == 0) {
90 error |= shape1.overwrites(vignette, xs[n], ys[n]);
92 shape1.draw(n, vignette, xs[n], ys[n]);
95 error |= shape2.overwrites(vignette, xs[n], ys[n]);
97 shape2.draw(n, vignette, xs[n], ys[n]);