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 namespace firevision {
00033 #if 0
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 }
00101
00102 #endif