Fawkes API  Fawkes Development Version
bayes_generator.h
1 
2 /**************************************************************************
3  * bayes_generator.h - generator for colormap using a bayesian method
4  *
5  * Created: Wed Mar 01 14:00:41 2006
6  * Copyright 2005-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ***************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_MODELS_COLOR_BAYES_BAYES_GENERATOR_
25 #define __FIREVISION_MODELS_COLOR_BAYES_BAYES_GENERATOR_
26 
27 #include <fvutils/colormap/generator.h>
28 
29 #include <vector>
30 #include <map>
31 
32 namespace firevision {
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
37 class YuvColormap;
38 class BayesHistosToLut;
39 
41 {
42 
43  public:
44  BayesColormapGenerator( unsigned int lut_depth = 1,
45  hint_t fg_object = H_UNKNOWN,
46  unsigned int lut_width = 256, unsigned int lut_height = 256);
48 
49  virtual void set_fg_object(hint_t object);
50  virtual void set_buffer(unsigned char *buffer,
51  unsigned int width, unsigned int height);
52  virtual YuvColormap * get_current();
53  virtual void consider();
54  virtual void calc();
55  virtual void undo();
56  virtual void reset();
57  virtual void reset_undo();
58 
59  virtual void set_selection(std::vector< fawkes::rectangle_t > region);
60 
61  virtual bool has_histograms();
62  virtual std::map< hint_t, Histogram * > * get_histograms();
63 
64  virtual void load_histograms(const char *filename);
65  virtual void save_histograms(const char *filename);
66 
67  void set_min_probability(float min_prob);
68 
69  private:
70  bool is_in_region(unsigned int x, unsigned int y);
71  void normalize_histos();
72 
73  typedef std::map< hint_t, Histogram * > HistogramMap;
74  HistogramMap fg_histos;
75  HistogramMap bg_histos;
76  HistogramMap histos;
77  HistogramMap::iterator histo_it;
78 
79  BayesHistosToLut *bhtl;
80  YuvColormap *cm;
81 
82  hint_t fg_object;
83 
84  unsigned int lut_width;
85  unsigned int lut_height;
86  unsigned int lut_depth;
87 
88  unsigned int image_width;
89  unsigned int image_height;
90 
91  unsigned int norm_size;
92 
93  unsigned char *buffer;
94  std::vector< fawkes::rectangle_t > region;
95  std::vector< fawkes::rectangle_t >::iterator rit;
96 
97  bool *selection_mask;
98 };
99 
100 } // end namespace firevision
101 
102 #endif
LUT generation by using Bayesian method on histograms.
virtual void set_selection(std::vector< fawkes::rectangle_t > region)
Set selection.
virtual void undo()
Undo last inclusion.
void set_min_probability(float min_prob)
Set min probability.
YUV Colormap.
Definition: yuvcm.h:39
virtual std::map< hint_t, Histogram *> * get_histograms()
Get histograms.
virtual YuvColormap * get_current()
Get current color model.
virtual void save_histograms(const char *filename)
Save histograms to a file.
virtual void reset_undo()
Reset undo.
virtual void calc()
Calculate.
virtual void reset()
Reset color model.
BayesColormapGenerator(unsigned int lut_depth=1, hint_t fg_object=H_UNKNOWN, unsigned int lut_width=256, unsigned int lut_height=256)
Constructor.
Interface for colormap generators.
Definition: generator.h:39
Colormap Generator using Bayes method.
virtual void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height)
Set buffer.
virtual void set_fg_object(hint_t object)
Set foreground object.
virtual void load_histograms(const char *filename)
Load histogram from a file.
virtual bool has_histograms()
Check if this color model uses histograms.
virtual void consider()
Consider current image.