Fawkes API
Fawkes Development Version
|
00001 00002 /************************************************************************** 00003 * bayes_histos_to_lut.h - This header defines a class 00004 * that takes color histograms of objects as input, 00005 * and, together with probabilities of objects, 00006 * generates all the values for a lookup-table 00007 * that maps from colors to objects 00008 * 00009 * Created: Mon Jun 27 14:16:52 2005 00010 * Copyright 2005 Martin Heracles 00011 * 2005-2008 Tim Niemueller [www.niemueller.de] 00012 * 2007-2008 Daniel Beck 00013 * 00014 ***************************************************************************/ 00015 00016 /* This program is free software; you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation; either version 2 of the License, or 00019 * (at your option) any later version. A runtime exception applies to 00020 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00021 * 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU Library General Public License for more details. 00026 * 00027 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00028 */ 00029 00030 #ifndef __FIREVISION_COLORMODEL_BAYES_HISTOS_TO_LUT_H_ 00031 #define __FIREVISION_COLORMODEL_BAYES_HISTOS_TO_LUT_H_ 00032 00033 #include <fvutils/base/roi.h> 00034 00035 #include <map> 00036 #include <string> 00037 00038 namespace firevision { 00039 #if 0 /* just to make Emacs auto-indent happy */ 00040 } 00041 #endif 00042 00043 class Histogram; 00044 class YuvColormap; 00045 00046 class BayesHistosToLut 00047 { 00048 public: 00049 BayesHistosToLut(std::map< hint_t, Histogram * > &histos, 00050 unsigned int d = 1, 00051 hint_t fg_object = H_UNKNOWN, 00052 unsigned int w = 256, 00053 unsigned int h = 256); 00054 ~BayesHistosToLut(); 00055 00056 std::string getName(); 00057 00058 float getObjectProb(hint_t object); 00059 00060 float getAPrioriProb( unsigned int u, 00061 unsigned int v, 00062 hint_t object ); 00063 float getAPrioriProb( unsigned int y, 00064 unsigned int u, 00065 unsigned int v, 00066 hint_t object ); 00067 00068 float getAPosterioriProb( hint_t object, 00069 unsigned int u, 00070 unsigned int v ); 00071 float getAPosterioriProb( hint_t object, 00072 unsigned int y, 00073 unsigned int u, 00074 unsigned int v ); 00075 00076 hint_t getMostLikelyObject( unsigned int u, 00077 unsigned int v ); 00078 hint_t getMostLikelyObject( unsigned int y, 00079 unsigned int u, 00080 unsigned int v ); 00081 00082 void setMinProbability( float min_prob ); 00083 void setMinProbForColor( float min_prob, hint_t hint ); 00084 00085 YuvColormap * get_colormap(); 00086 00087 /* method "calculateLutValues" calculates lut values 00088 following the bayesian approach */ 00089 void calculateLutValues( bool penalty = false ); 00090 /* method "calculateLutAllColors" calculates lut values 00091 _without_ following the bayesian approach, but it can handle all colors 00092 (not only "ball" and "background") */ 00093 void calculateLutAllColors(); 00094 void saveLut(char *file); 00095 void save(std::string filename); 00096 00097 private: 00098 std::map<hint_t, Histogram*> &histograms; 00099 std::map<hint_t, unsigned int> numberOfOccurrences; 00100 std::map<hint_t, float> object_probabilities; 00101 00102 YuvColormap *lut; 00103 unsigned int width; 00104 unsigned int height; 00105 unsigned int depth; 00106 00107 hint_t fg_object; 00108 00109 float min_probability; 00110 00111 // color thresholds: 00112 float min_prob_ball; 00113 float min_prob_green; 00114 float min_prob_yellow; 00115 float min_prob_blue; 00116 float min_prob_white; 00117 float min_prob_black; 00118 }; 00119 00120 } // end namespace firevision 00121 00122 #endif