Fawkes API  Fawkes Development Version
bayes_histos_to_lut.h
1 
2 /**************************************************************************
3  * bayes_histos_to_lut.h - This header defines a class
4  * that takes color histograms of objects as input,
5  * and, together with probabilities of objects,
6  * generates all the values for a lookup-table
7  * that maps from colors to objects
8  *
9  * Created: Mon Jun 27 14:16:52 2005
10  * Copyright 2005 Martin Heracles
11  * 2005-2008 Tim Niemueller [www.niemueller.de]
12  * 2007-2008 Daniel Beck
13  *
14  ***************************************************************************/
15 
16 /* This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version. A runtime exception applies to
20  * this software (see LICENSE.GPL_WRE file mentioned below for details).
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Library General Public License for more details.
26  *
27  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
28  */
29 
30 #ifndef __FIREVISION_COLORMODEL_BAYES_HISTOS_TO_LUT_H_
31 #define __FIREVISION_COLORMODEL_BAYES_HISTOS_TO_LUT_H_
32 
33 #include <fvutils/base/roi.h>
34 
35 #include <map>
36 #include <string>
37 
38 namespace firevision {
39 #if 0 /* just to make Emacs auto-indent happy */
40 }
41 #endif
42 
43 class Histogram;
44 class YuvColormap;
45 
47 {
48  public:
49  BayesHistosToLut(std::map< hint_t, Histogram * > &histos,
50  unsigned int d = 1,
51  hint_t fg_object = H_UNKNOWN,
52  unsigned int w = 256,
53  unsigned int h = 256);
55 
56  std::string getName();
57 
58  float getObjectProb(hint_t object);
59 
60  float getAPrioriProb( unsigned int u,
61  unsigned int v,
62  hint_t object );
63  float getAPrioriProb( unsigned int y,
64  unsigned int u,
65  unsigned int v,
66  hint_t object );
67 
68  float getAPosterioriProb( hint_t object,
69  unsigned int u,
70  unsigned int v );
71  float getAPosterioriProb( hint_t object,
72  unsigned int y,
73  unsigned int u,
74  unsigned int v );
75 
76  hint_t getMostLikelyObject( unsigned int u,
77  unsigned int v );
78  hint_t getMostLikelyObject( unsigned int y,
79  unsigned int u,
80  unsigned int v );
81 
82  void setMinProbability( float min_prob );
83  void setMinProbForColor( float min_prob, hint_t hint );
84 
86 
87  /* method "calculateLutValues" calculates lut values
88  following the bayesian approach */
89  void calculateLutValues( bool penalty = false );
90  /* method "calculateLutAllColors" calculates lut values
91  _without_ following the bayesian approach, but it can handle all colors
92  (not only "ball" and "background") */
93  void calculateLutAllColors();
94  void saveLut(char *file);
95  void save(std::string filename);
96 
97  private:
98  std::map<hint_t, Histogram*> &histograms;
99  std::map<hint_t, unsigned int> numberOfOccurrences;
100  std::map<hint_t, float> object_probabilities;
101 
102  YuvColormap *lut;
103  unsigned int width;
104  unsigned int height;
105  unsigned int depth;
106 
107  hint_t fg_object;
108 
109  float min_probability;
110 
111  // color thresholds:
112  float min_prob_ball;
113  float min_prob_green;
114  float min_prob_yellow;
115  float min_prob_blue;
116  float min_prob_white;
117  float min_prob_black;
118 };
119 
120 } // end namespace firevision
121 
122 #endif
LUT generation by using Bayesian method on histograms.
void saveLut(char *file)
Save LUT to file.
float getAPosterioriProb(hint_t object, unsigned int u, unsigned int v)
P(object| u, v).
BayesHistosToLut(std::map< hint_t, Histogram * > &histos, unsigned int d=1, hint_t fg_object=H_UNKNOWN, unsigned int w=256, unsigned int h=256)
Constructor.
void setMinProbability(float min_prob)
Set min probability.
YUV Colormap.
Definition: yuvcm.h:39
std::string getName()
Get name.
void setMinProbForColor(float min_prob, hint_t hint)
Set min probability for color.
float getAPrioriProb(unsigned int u, unsigned int v, hint_t object)
P(u, v| object).
void calculateLutValues(bool penalty=false)
Calculate LUT values.
void save(std::string filename)
Save LUT to file.
float getObjectProb(hint_t object)
Get object probability.
void calculateLutAllColors()
Calculate all LUT colors.
YuvColormap * get_colormap()
Get generated color model.
hint_t getMostLikelyObject(unsigned int u, unsigned int v)
Get most likely object.