Fawkes API Fawkes Development Version
|
00001 00002 /************************************************************************** 00003 * bayes_generator.h - generator for colormap using a bayesian method 00004 * 00005 * Created: Wed Mar 01 14:00:41 2006 00006 * Copyright 2005-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ***************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __FIREVISION_MODELS_COLOR_BAYES_BAYES_GENERATOR_ 00025 #define __FIREVISION_MODELS_COLOR_BAYES_BAYES_GENERATOR_ 00026 00027 #include <fvutils/colormap/generator.h> 00028 00029 #include <vector> 00030 #include <map> 00031 00032 namespace firevision { 00033 #if 0 /* just to make Emacs auto-indent happy */ 00034 } 00035 #endif 00036 00037 class YuvColormap; 00038 class BayesHistosToLut; 00039 00040 class BayesColormapGenerator : public ColormapGenerator 00041 { 00042 00043 public: 00044 BayesColormapGenerator( unsigned int lut_depth = 1, 00045 hint_t fg_object = H_UNKNOWN, 00046 unsigned int lut_width = 256, unsigned int lut_height = 256); 00047 ~BayesColormapGenerator(); 00048 00049 virtual void set_fg_object(hint_t object); 00050 virtual void set_buffer(unsigned char *buffer, 00051 unsigned int width, unsigned int height); 00052 virtual YuvColormap * get_current(); 00053 virtual void consider(); 00054 virtual void calc(); 00055 virtual void undo(); 00056 virtual void reset(); 00057 virtual void reset_undo(); 00058 00059 virtual void set_selection(std::vector< fawkes::rectangle_t > region); 00060 00061 virtual bool has_histograms(); 00062 virtual std::map< hint_t, Histogram * > * get_histograms(); 00063 00064 virtual void load_histograms(const char *filename); 00065 virtual void save_histograms(const char *filename); 00066 00067 void set_min_probability(float min_prob); 00068 00069 private: 00070 bool is_in_region(unsigned int x, unsigned int y); 00071 void normalize_histos(); 00072 00073 typedef std::map< hint_t, Histogram * > HistogramMap; 00074 HistogramMap fg_histos; 00075 HistogramMap bg_histos; 00076 HistogramMap histos; 00077 HistogramMap::iterator histo_it; 00078 00079 BayesHistosToLut *bhtl; 00080 YuvColormap *cm; 00081 00082 hint_t fg_object; 00083 00084 unsigned int lut_width; 00085 unsigned int lut_height; 00086 unsigned int lut_depth; 00087 00088 unsigned int image_width; 00089 unsigned int image_height; 00090 00091 unsigned int norm_size; 00092 00093 unsigned char *buffer; 00094 std::vector< fawkes::rectangle_t > region; 00095 std::vector< fawkes::rectangle_t >::iterator rit; 00096 00097 bool *selection_mask; 00098 }; 00099 00100 } // end namespace firevision 00101 00102 #endif