KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometric_context.h
Go to the documentation of this file.
1 /*
2 *@class - Geometric_context.cpp
3 *
4 *@author - Josh Bowdish
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 GEOMETRIC_CONTEXT_H
12 #define GEOMETRIC_CONTEXT_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 <m_cpp/m_matrix.h>
20 
21 #define MAX_NUM_ENTITIES 30
22 
23 namespace kjb{
24 
26 
27 enum Geometric_context_label {
28  CENTRAL = 0, // FLOOR
29  LEFT,
30  RIGHT,
31  FLOOR,
32  CEILING,
33  OBJECT_1,
34  OBJECT_2
35  };
36 
37 /* OLD:
38  * FLOOR = 0,
39  RIGHT,
40  CENTRAL,
41  LEFT,
42  OBJECT_1,
43  OBJECT_2,
44  CEILING
45  */
46 
47 
48 public:
49 
50 Geometric_context(const Int_matrix & iseg_map, const Matrix & iprobabilities)
51  : seg_map(iseg_map), probabilities(iprobabilities), num_segments(0)
52 {
53  init_context();
54 }
55 
56 Geometric_context(const std::string& seg_path, const std::string prob_path)
57  : seg_map(seg_path.c_str()), probabilities(prob_path.c_str()), num_segments(0)
58 {
59  init_context();
60 }
61 
62 void draw_geometric_context(Image & img) const;
63 
64 void draw_segmentation(Image & img) const ;
65 
66 double compute_score(const kjb::Image & img) const;
67 double compute_score(const kjb::Int_matrix & map) const;
68 double compute_score
69 (
70  const kjb::Int_matrix & map,
71  kjb::Vector & individual_scores,
72  int num_entities
73 ) const;
74 
75 void init_context();
76 
77 void draw_segment(Image & img, int segment_index) const;
78 
79 int get_num_segments() const
80 {
81  return num_segments;
82 }
83 
85 (
86  const Int_matrix & imap,
87  Image & img
88 );
89 
91 (
92  const Int_matrix & imap,
93  Image & img
94 );
95 
96 private:
97  void count_segments();
98 
99  /*
100  * We assume that the segment count starts from 1, not from zero
101  */
102  Matrix seg_map;
103  Matrix probabilities;
104  int num_segments;
105 
106 }; //class Geometric_context
107 
108 }//namespace kjb
109 
110 #endif
Definition: geometric_context.h:25
Geometric_context(const std::string &seg_path, const std::string prob_path)
Definition: geometric_context.h:56
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
void draw_geometric_context(Image &img) const
Definition: geometric_context.cpp:16
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
void draw_segment(Image &img, int segment_index) const
Definition: geometric_context.cpp:255
void draw_segmentation(Image &img) const
Definition: geometric_context.cpp:236
void convert_map_to_edges(const Int_matrix &imap, Image &img)
Definition: geometric_context.cpp:357
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
double compute_score(const kjb::Image &img) const
Definition: geometric_context.cpp:72
void init_context()
Definition: geometric_context.cpp:272
int get_num_segments() const
Definition: geometric_context.h:79
Geometric_context(const Int_matrix &iseg_map, const Matrix &iprobabilities)
Definition: geometric_context.h:50
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
void convert_map_to_image(const Int_matrix &imap, Image &img)
Definition: geometric_context.cpp:299