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 svrt. If not, see <http://www.gnu.org/licenses/>.
27 void Vignette::clear() {
28 for(int k = 0; k < width * height; k++) {
30 #ifdef KEEP_PART_PRESENCE
36 void Vignette::fill(int x, int y, int v) {
37 if(x >= 0 && x < Vignette::width && y >= 0 && y < Vignette::height &&
38 content[x + Vignette::width * y] == 255) {
39 content[x + Vignette::width * y] = v;
47 void Vignette::switch_values(int v1, int v2) {
48 for(int k = 0; k < Vignette::height * Vignette::width; k++) {
49 if(content[k] == v1) {
51 } else if(content[k] == v2) {
57 void Vignette::replace_value(int from, int to) {
58 for(int k = 0; k < Vignette::height * Vignette::width; k++) {
59 if(content[k] == from) {
65 void Vignette::superpose(Vignette *infront, Vignette *inback) {
66 for(int k = 0; k < Vignette::height * Vignette::width; k++) {
67 if(infront->content[k] < 255) {
68 content[k] = infront->content[k];
70 content[k] = inback->content[k];
75 int Vignette::intersection(Vignette *v) {
77 for(int k = 0; k < Vignette::height * Vignette::width; k++) {
78 if(content[k] < 255 && v->content[k] < 255) {
85 void Vignette::grow() {
86 int tmp[Vignette::width * Vignette::height];
87 for(int k = 0; k < Vignette::height * Vignette::width; k++) {
91 for(int y = 1; y < Vignette::height - 1; y++) {
92 for(int x = 1; x < Vignette::width - 1; x++) {
93 k = x + Vignette::width * y;
94 content[k] = min(tmp[k],
95 min(min(tmp[k - Vignette::width], tmp[k - 1]),
96 min(tmp[k + 1], tmp[k + Vignette::width])));