bazar  1.3.1
affine_image_generator.h
Go to the documentation of this file.
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 All rights reserved.
5 
6 This file is part of BazAR.
7 
8 BazAR is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21 #ifndef AFFINE_IMAGE_GENERATOR_H
22 #define AFFINE_IMAGE_GENERATOR_H
23 
24 #include <starter.h>
25 #include <viewsets/object_view.h>
27 #include "example_generator.h"
28 
29 
33 {
34  static const int max_point_number = 5000;
35  public:
37  virtual ~affine_image_generator(void);
38 
39  void set_original_image(IplImage * original_image,
40  int _u_corner1 = -1, int _v_corner1 = -1, int _u_corner2 = -1, int _v_corner2 = -1,
41  int _u_corner3 = -1, int _v_corner3 = -1, int _u_corner4 = -1, int _v_corner4 = -1,
42  int affine_image_width = -1, int affine_image_height = -1);
43 
44  void set_preprocessed_image(IplImage *preprocessed);
45 
46  void set_object_keypoints(object_keypoint * keypoint_array, int point_number);
47 
48  void reset_keypoints(void);
49  void add_keypoint(float u, float v, int scale, int class_index);
50 
51  void generate_affine_image(void);
52  void generate_object_view(void);
53 
55  void set_noise_level(int p_noise_level);
57  void set_level_number(int p_level_number);
59  void set_patch_size(int p_patch_size);
61  void set_use_random_background(bool p_use_random_background) { use_random_background = p_use_random_background; }
65  void set_range_variation_for_phi(float min_phi, float max_phi);
67  void independent_scaling(float min_lambda1, float max_lambda1, float min_lambda2, float max_lambda2);
69  void constrained_scaling(float min_lambda1, float max_lambda1,
70  float min_lambda2, float max_lambda2,
71  float min_l1_l2, float max_l1_l2);
73  void set_use_orientation_correction(bool p_use_orientation_correction)
74  { use_orientation_correction = p_use_orientation_correction; }
76  void set_add_gaussian_smoothing(bool p_add_gaussian_smoothing)
77  { add_gaussian_smoothing = p_add_gaussian_smoothing; }
79  void set_change_intensities(bool p_change_intensities)
80  { change_intensities = p_change_intensities; }
81 
82  void set_gaussian_smoothing_kernel_size(int p_gaussian_smoothing_kernel_size)
83  { gaussian_smoothing_kernel_size = p_gaussian_smoothing_kernel_size; }
84 
87 
88  void set_roi(int _u_corner1, int _v_corner1,
89  int _u_corner2, int _v_corner2,
90  int _u_corner3, int _v_corner3,
91  int _u_corner4, int _v_corner4);
92  bool inside_roi(int u, int v);
93  void set_default_values(void);
94 
95  vector<image_class_example *> * generate_random_examples(void);
96  void release_examples(void);
97 
98  void affine_transformation(float u, float v, float & nu, float & nv);
99  void inverse_affine_transformation(float u, float v, float & nu, float & nv);
100 
101  static void affine_transformation(float a[6], int width, int height, float u, float v, float & nu, float & nv);
102  static void inverse_affine_transformation(float a[6], int width, int height, float u, float v, float & nu, float & nv);
103 
105 
106  void add_white_noise(IplImage * image);
107  void replace_by_noise(IplImage * image, int value);
110 
112  IplImage * affine_image;
113  float a[6];
114 
116  vector<object_view *> generated_object_views_for_learning;
117  vector<image_class_example *> point_views;
118 
122 
124 
129 
134 
136  float min_phi, max_phi;
139  float min_lambda2, max_lambda2; // for scaling method 0
140  float min_l1_l2, max_l1_l2; // for scaling method 1
141 
143 };
144 
145 #endif // AFFINE_IMAGE_GENERATOR_H