KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
feature_histogram.h
Go to the documentation of this file.
1 /*
2 *@class - Geometric_context.cpp
3 *
4 *@author - Luca Del Pero
5 *
6 *@brief - creates an omap from an image that can call compare_omap(compareto)
7 * to see how similar it is.
8 */
9 
10 //#include "Geometric_context.h"
11 #ifndef FEATURE_HISTOGRAM_H
12 #define FEATURE_HISTOGRAM_H
13 
14 #include "i_cpp/i_image.h"
15 #include "i/i_float_io.h"
16 #include "i/i_float.h"
17 #include <stdio.h>
18 #include <l_cpp/l_exception.h>
19 #include <wrap_dtlib_cpp/texture.h>
20 
21 namespace kjb{
22 
23 #warning "[Code police] Please don't indent code using tabs, in libkjb."
24 #warning "[Code police] Please use a 4-space indent, instead."
25 class Fh_type
26 {
27 public:
28  unsigned int element_1; // object_id or room
29  unsigned int element_2; // object_polymesh, always the same for room
30  unsigned int element_3; // polymesh_surface
31  unsigned int extra_field; // for application purposes, for room it is the code
32 };
33 
35 {
36 public:
37  class Image_dart
38  {
39  public:
40  Image_dart(unsigned int irow, unsigned int icol)
41  {
42  _row = irow;
43  _col = icol;
44  }
45 
46  unsigned int _row;
47  unsigned int _col;
48  };
49 
51  (
53  unsigned int dart_window_size,
54  unsigned int num_rows,
55  unsigned int num_cols,
56  int padding
57  );
58 
59  void draw_darts(kjb::Image & img);
60 
61  inline unsigned int get_num_darts()
62  {
63  return darts.size();
64  }
65 
67 
68  double compute_score
69  (
70  const kjb::Int_matrix & map,
71  std::vector<Fh_type> & previous_darts,
72  std::vector<Fh_type> & new_darts,
73  std::vector<bool> changed_darts,
74  double previous_score
75  );
76 
77  double compute_score
78  (
79  const kjb::Int_matrix & map,
80  std::vector<Fh_type> & new_darts
81  );
82 
83  double compute_score2
84  (
85  const kjb::Int_matrix & map,
86  std::vector<Fh_type> & previous_darts,
87  std::vector<Fh_type> & new_darts,
88  std::vector<bool> changed_darts,
89  double previous_score
90  );
91 
92  double compute_score2
93  (
94  const kjb::Int_matrix & map,
95  std::vector<Fh_type> & new_darts
96  );
97 
98  double compute_score3
99  (
100  const kjb::Int_matrix & map,
101  std::vector<Fh_type> & new_darts
102  );
103 
104  double compute_score4
105  (
106  const kjb::Int_matrix & map,
107  std::vector<Fh_type> & new_darts
108  );
109 
110  const Matrix & get_diff_matrix() const
111  {
112  return diff_matrix;
113  }
114 
115  void draw_room
116  (
117  const kjb::Int_matrix & map,
118  std::vector<Fh_type> & new_darts,
119  kjb::Image & img
120  );
121 
122  void draw_room_floor
123  (
124  const kjb::Int_matrix & map,
125  std::vector<Fh_type> & new_darts,
126  kjb::Image & img
127  );
128 
129  void draw_room_ceiling
130  (
131  const kjb::Int_matrix & map,
132  std::vector<Fh_type> & new_darts,
133  kjb::Image & img
134  );
135 
136  void draw_room_walls
137  (
138  const kjb::Int_matrix & map,
139  std::vector<Fh_type> & new_darts,
140  kjb::Image & img
141  );
142 
143  void draw_object
144  (
145  const kjb::Int_matrix & map,
146  std::vector<Fh_type> & new_darts,
147  unsigned int obj_index,
148  kjb::Image & img
149  );
150 
151 
153  (
154  const kjb::Int_matrix & map,
155  std::vector<Fh_type> & new_darts,
156  unsigned int obj_index,
157  unsigned int polymsh_index,
158  kjb::Image & img
159  ) const;
160 
161  double compute_differential
162  (
163  const kjb::Matrix & assignment_matrix
164  ) const;
165 
166  const std::vector<Image_dart> & get_darts() const { return darts;}
167 
168 private:
169 
170  double find_weight(const Fh_type & dart1, const Fh_type & dart2);
171 
172  double find_probability(const Fh_type & dart1, const Fh_type & dart2, double diff);
173 
174  bool find_probability2(const Fh_type & dart1, const Fh_type & dart2, double diff, double & prob);
175 
176  bool find_probability3(const Fh_type & dart1, const Fh_type & dart2, double diff, double & prob);
177 
178  std::vector<Image_dart> darts;
179 #warning "[Code police] Please don't start identifiers with underscore."
180  unsigned int _num_rows;
181  unsigned int _num_cols;
182  unsigned int _padding;
183 
184  Matrix diff_matrix;
185  Matrix differential_matrix;
186  double all_different;
187 
188 }; //class Feature_histogram
189 
190 }//namespace kjb
191 
192 #endif
double compute_differential(const kjb::Matrix &assignment_matrix) const
Definition: feature_histogram.cpp:86
Definition: feature_histogram.h:25
unsigned int _col
Definition: feature_histogram.h:47
unsigned int get_num_darts()
Definition: feature_histogram.h:61
Definition: feature_histogram.h:37
Feature_histogram(DTLib::CImg< DTLib::FloatCHistogramPtr > &histo, unsigned int dart_window_size, unsigned int num_rows, unsigned int num_cols, int padding)
Definition: feature_histogram.cpp:28
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
void draw_object_polymesh(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, unsigned int obj_index, unsigned int polymsh_index, kjb::Image &img) const
Definition: feature_histogram.cpp:685
double compute_score(const kjb::Int_matrix &map, std::vector< Fh_type > &previous_darts, std::vector< Fh_type > &new_darts, std::vector< bool > changed_darts, double previous_score)
Definition: feature_histogram.cpp:107
const std::vector< Image_dart > & get_darts() const
Definition: feature_histogram.h:166
unsigned int extra_field
Definition: feature_histogram.h:31
Definition: img.h:51
void prepare_diff_matrix(DTLib::CImg< DTLib::FloatCHistogramPtr > &histo)
Definition: feature_histogram.cpp:67
double compute_score3(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts)
Definition: feature_histogram.cpp:520
void draw_object(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, unsigned int obj_index, kjb::Image &img)
Definition: feature_histogram.cpp:642
Definition: feature_histogram.h:34
void draw_room_floor(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, kjb::Image &img)
Definition: feature_histogram.cpp:728
void draw_room(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, kjb::Image &img)
Definition: feature_histogram.cpp:600
void draw_room_ceiling(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, kjb::Image &img)
Definition: feature_histogram.cpp:770
void draw_darts(kjb::Image &img)
Definition: feature_histogram.cpp:58
unsigned int element_1
Definition: feature_histogram.h:28
void draw_room_walls(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts, kjb::Image &img)
Definition: feature_histogram.cpp:812
double compute_score2(const kjb::Int_matrix &map, std::vector< Fh_type > &previous_darts, std::vector< Fh_type > &new_darts, std::vector< bool > changed_darts, double previous_score)
Definition: feature_histogram.cpp:427
unsigned int _row
Definition: feature_histogram.h:46
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Code for a wrapper class around the C struct KJB_Image.
Support for error handling exception classes in libKJB.
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
double compute_score4(const kjb::Int_matrix &map, std::vector< Fh_type > &new_darts)
Definition: feature_histogram.cpp:560
Image_dart(unsigned int irow, unsigned int icol)
Definition: feature_histogram.h:40
unsigned int element_3
Definition: feature_histogram.h:30
const Matrix & get_diff_matrix() const
Definition: feature_histogram.h:110
unsigned int element_2
Definition: feature_histogram.h:29