bayes_generator.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 class YuvColormap;
00033 class BayesHistosToLut;
00034
00035 class BayesColormapGenerator : public ColormapGenerator
00036 {
00037
00038 public:
00039 BayesColormapGenerator( unsigned int lut_depth = 1,
00040 hint_t fg_object = H_UNKNOWN,
00041 unsigned int lut_width = 256, unsigned int lut_height = 256);
00042 ~BayesColormapGenerator();
00043
00044 virtual void set_fg_object(hint_t object);
00045 virtual void set_buffer(unsigned char *buffer,
00046 unsigned int width, unsigned int height);
00047 virtual YuvColormap * get_current();
00048 virtual void consider();
00049 virtual void calc();
00050 virtual void undo();
00051 virtual void reset();
00052 virtual void reset_undo();
00053
00054 virtual void set_selection(std::vector< fawkes::rectangle_t > region);
00055
00056 virtual bool has_histograms();
00057 virtual std::map< hint_t, Histogram * > * get_histograms();
00058
00059 virtual void load_histograms(const char *filename);
00060 virtual void save_histograms(const char *filename);
00061
00062 void set_min_probability(float min_prob);
00063
00064 private:
00065 bool is_in_region(unsigned int x, unsigned int y);
00066 void normalize_histos();
00067
00068 typedef std::map< hint_t, Histogram * > HistogramMap;
00069 HistogramMap fg_histos;
00070 HistogramMap bg_histos;
00071 HistogramMap histos;
00072 HistogramMap::iterator histo_it;
00073
00074 BayesHistosToLut *bhtl;
00075 YuvColormap *cm;
00076
00077 hint_t fg_object;
00078
00079 unsigned int lut_width;
00080 unsigned int lut_height;
00081 unsigned int lut_depth;
00082
00083 unsigned int image_width;
00084 unsigned int image_height;
00085
00086 unsigned int norm_size;
00087
00088 unsigned char *buffer;
00089 std::vector< fawkes::rectangle_t > region;
00090 std::vector< fawkes::rectangle_t >::iterator rit;
00091
00092 bool *selection_mask;
00093 };
00094
00095 #endif