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 <map>
30#include <vector>
31
32namespace firevision {
33
34class YuvColormap;
35class BayesHistosToLut;
36
38{
39public:
40 BayesColormapGenerator(unsigned int lut_depth = 1,
41 hint_t fg_object = H_UNKNOWN,
42 unsigned int lut_width = 256,
43 unsigned int lut_height = 256);
45
46 virtual void set_fg_object(hint_t object);
47 virtual void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height);
48 virtual YuvColormap *get_current();
49 virtual void consider();
50 virtual void calc();
51 virtual void undo();
52 virtual void reset();
53 virtual void reset_undo();
54
55 virtual void set_selection(std::vector<fawkes::rectangle_t> region);
56
57 virtual bool has_histograms();
58 virtual std::map<hint_t, Histogram *> *get_histograms();
59
60 virtual void load_histograms(const char *filename);
61 virtual void save_histograms(const char *filename);
62
63 void set_min_probability(float min_prob);
64
65private:
66 bool is_in_region(unsigned int x, unsigned int y);
67 void normalize_histos();
68
69 typedef std::map<hint_t, Histogram *> HistogramMap;
70 HistogramMap fg_histos;
71 HistogramMap bg_histos;
72 HistogramMap histos;
73 HistogramMap::iterator histo_it;
74
75 BayesHistosToLut *bhtl;
76 YuvColormap * cm;
77
78 hint_t fg_object;
79
80 unsigned int lut_width;
81 unsigned int lut_height;
82 unsigned int lut_depth;
83
84 unsigned int image_width;
85 unsigned int image_height;
86
87 unsigned int norm_size;
88
89 unsigned char * buffer;
90 std::vector<fawkes::rectangle_t> region;
91 std::vector<fawkes::rectangle_t>::iterator rit;
92
93 bool *selection_mask;
94};
95
96} // end namespace firevision
97
98#endif
Colormap Generator using Bayes method.
virtual void reset_undo()
Reset undo.
virtual void set_selection(std::vector< fawkes::rectangle_t > region)
Set selection.
virtual void save_histograms(const char *filename)
Save histograms to a file.
virtual void load_histograms(const char *filename)
Load histogram from a file.
virtual YuvColormap * get_current()
Get current color model.
virtual std::map< hint_t, Histogram * > * get_histograms()
Get histograms.
virtual void undo()
Undo last inclusion.
void set_min_probability(float min_prob)
Set min probability.
BayesColormapGenerator(unsigned int lut_depth=1, hint_t fg_object=H_UNKNOWN, unsigned int lut_width=256, unsigned int lut_height=256)
Constructor.
virtual void reset()
Reset color model.
virtual void set_fg_object(hint_t object)
Set foreground object.
virtual void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height)
Set buffer.
virtual bool has_histograms()
Check if this color model uses histograms.
virtual void consider()
Consider current image.
LUT generation by using Bayesian method on histograms.
Interface for colormap generators.
Definition: generator.h:38
YUV Colormap.
Definition: yuvcm.h:36