Fawkes API  Fawkes Development Version
histogram.h
1 
2 /***************************************************************************
3  * histogram.h - Header for histograms
4  *
5  * Generated: Tue Jun 14 11:09:27 2005
6  * Copyright 2005 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_UTILS_HISTOGRAM_H_
25 #define _FIREVISION_UTILS_HISTOGRAM_H_
26 
27 #include <fvutils/base/types.h>
28 
29 #include <iostream>
30 
31 namespace firevision {
32 
33 class HistogramBlock;
34 
35 class Histogram
36 {
37 public:
38  Histogram(unsigned int width,
39  unsigned int height,
40  unsigned int depth = 1,
41  unsigned int num_undos = 1);
42  Histogram(HistogramBlock *histogram_block);
43  ~Histogram();
44 
47 
48  unsigned int * get_histogram();
50  void get_dimensions(unsigned int &width, unsigned int &height, unsigned int &depth);
51  unsigned int get_value(unsigned int x, unsigned int y);
52  unsigned int get_value(unsigned int x, unsigned int y, unsigned int z);
53  void set_value(unsigned int x, unsigned int y, unsigned int value);
54  void set_value(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
55  void inc_value(unsigned int x, unsigned int y, unsigned int z = 0);
56  void add(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
57  void sub(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
58  void reset();
59  unsigned int get_median();
60  unsigned int get_average();
61 
62  unsigned int get_sum() const;
63 
64  void reset_undo();
65  void undo();
66  unsigned int switch_undo(unsigned int undo_id);
67  unsigned int get_num_undos();
68 
69  void print_to_stream(std::ostream &s);
70  void save(const char *filename, bool formatted_output = false);
71  bool load(const char *filename);
72 
73 private:
74  unsigned int width;
75  unsigned int height;
76  unsigned int depth;
77  unsigned int dimension;
78  unsigned int histogram_size;
79  unsigned int * histogram;
80  HistogramBlock *histogram_block;
81  unsigned int number_of_values;
82 
83  unsigned int **undo_overlay;
84  unsigned int * undo_num_vals;
85  unsigned int undo_num;
86  unsigned int undo_current;
87 };
88 
89 } // end namespace firevision
90 
91 #endif
firevision::Histogram::Histogram
Histogram(unsigned int width, unsigned int height, unsigned int depth=1, unsigned int num_undos=1)
Constructor.
Definition: histogram.cpp:52
firevision::Histogram::add
void add(unsigned int x, unsigned int y, unsigned int z, unsigned int value)
Add value to value in histogram at given location.
Definition: histogram.cpp:305
firevision::Histogram::get_num_undos
unsigned int get_num_undos()
Get number of undos.
Definition: histogram.cpp:467
fawkes::upoint_t
Point with cartesian coordinates as unsigned integers.
Definition: types.h:33
firevision::Histogram::get_average
unsigned int get_average()
Get average of all values.
Definition: histogram.cpp:502
firevision::Histogram::sub
void sub(unsigned int x, unsigned int y, unsigned int z, unsigned int value)
Substract value from value in histogram at given location.
Definition: histogram.cpp:323
firevision::HistogramBlock
Definition: histogram_block.h:53
firevision::Histogram::get_dimensions
void get_dimensions(unsigned int &width, unsigned int &height, unsigned int &depth)
Obtain dimensions of the histogram.
Definition: histogram.cpp:196
firevision::Histogram::set_value
void set_value(unsigned int x, unsigned int y, unsigned int value)
Set value in histogram.
Definition: histogram.cpp:232
firevision::Histogram::get_median
unsigned int get_median()
Get median of all values.
Definition: histogram.cpp:476
firevision::Histogram::save
void save(const char *filename, bool formatted_output=false)
Save to file.
Definition: histogram.cpp:379
firevision::Histogram::get_sum
unsigned int get_sum() const
Get sum of all values.
Definition: histogram.cpp:524
firevision::Histogram::inc_value
void inc_value(unsigned int x, unsigned int y, unsigned int z=0)
Increase the value of the histogram at given position.
Definition: histogram.cpp:287
firevision::Histogram::~Histogram
~Histogram()
Destructor.
Definition: histogram.cpp:120
firevision::Histogram::load
bool load(const char *filename)
Load from file.
Definition: histogram.cpp:394
firevision::Histogram::get_histogram
unsigned int * get_histogram()
Get histogram data buffer.
Definition: histogram.cpp:176
firevision::Histogram::switch_undo
unsigned int switch_undo(unsigned int undo_id)
Switch undo to another undo buffer.
Definition: histogram.cpp:450
firevision::Histogram::get_histogram_block
HistogramBlock * get_histogram_block()
Obtain the histogram block of this histogram.
Definition: histogram.cpp:185
firevision::Histogram::reset_undo
void reset_undo()
Reset undo.
Definition: histogram.cpp:423
firevision::Histogram::get_value
unsigned int get_value(unsigned int x, unsigned int y)
Get value from histogram.
Definition: histogram.cpp:209
firevision::Histogram::undo
void undo()
Undo.
Definition: histogram.cpp:431
firevision::Histogram::reset
void reset()
Reset histogram.
Definition: histogram.cpp:344
firevision::Histogram::print_to_stream
void print_to_stream(std::ostream &s)
Print to stream.
Definition: histogram.cpp:360
firevision::Histogram::operator+=
void operator+=(fawkes::upoint_t *p)
Add point.
Definition: histogram.cpp:134