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
38namespace firevision {
39
40class Histogram;
41class YuvColormap;
42
44{
45public:
46 BayesHistosToLut(std::map<hint_t, Histogram *> &histos,
47 unsigned int d = 1,
48 hint_t fg_object = H_UNKNOWN,
49 unsigned int w = 256,
50 unsigned int h = 256);
52
53 std::string getName();
54
55 float getObjectProb(hint_t object);
56
57 float getAPrioriProb(unsigned int u, unsigned int v, hint_t object);
58 float getAPrioriProb(unsigned int y, unsigned int u, unsigned int v, hint_t object);
59
60 float getAPosterioriProb(hint_t object, unsigned int u, unsigned int v);
61 float getAPosterioriProb(hint_t object, unsigned int y, unsigned int u, unsigned int v);
62
63 hint_t getMostLikelyObject(unsigned int u, unsigned int v);
64 hint_t getMostLikelyObject(unsigned int y, unsigned int u, unsigned int v);
65
66 void setMinProbability(float min_prob);
67 void setMinProbForColor(float min_prob, hint_t hint);
68
70
71 /* method "calculateLutValues" calculates lut values
72 following the bayesian approach */
73 void calculateLutValues(bool penalty = false);
74 /* method "calculateLutAllColors" calculates lut values
75 _without_ following the bayesian approach, but it can handle all colors
76 (not only "ball" and "background") */
78 void saveLut(char *file);
79 void save(std::string filename);
80
81private:
82 std::map<hint_t, Histogram *> &histograms;
83 std::map<hint_t, unsigned int> numberOfOccurrences;
84 std::map<hint_t, float> object_probabilities;
85
86 YuvColormap *lut;
87 unsigned int width;
88 unsigned int height;
89 unsigned int depth;
90
91 hint_t fg_object;
92
93 float min_probability;
94
95 // color thresholds:
96 float min_prob_ball;
97 float min_prob_green;
98 float min_prob_yellow;
99 float min_prob_blue;
100 float min_prob_white;
101 float min_prob_black;
102};
103
104} // end namespace firevision
105
106#endif
LUT generation by using Bayesian method on histograms.
float getObjectProb(hint_t object)
Get object probability.
void setMinProbForColor(float min_prob, hint_t hint)
Set min probability for color.
YuvColormap * get_colormap()
Get generated color model.
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.
std::string getName()
Get name.
void calculateLutValues(bool penalty=false)
Calculate LUT values.
void saveLut(char *file)
Save LUT to file.
void save(std::string filename)
Save LUT to file.
void calculateLutAllColors()
Calculate all LUT colors.
float getAPosterioriProb(hint_t object, unsigned int u, unsigned int v)
P(object| u, v).
float getAPrioriProb(unsigned int u, unsigned int v, hint_t object)
P(u, v| object).
hint_t getMostLikelyObject(unsigned int u, unsigned int v)
Get most likely object.
void setMinProbability(float min_prob)
Set min probability.
YUV Colormap.
Definition: yuvcm.h:36