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 #include <iostream>
29 
30 namespace firevision {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 class HistogramBlock;
36 
37 class Histogram
38 {
39  public:
40  Histogram(unsigned int width, unsigned int height,
41  unsigned int depth = 1, 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
unsigned int get_average()
Get average of all values.
Definition: histogram.cpp:534
void reset()
Reset histogram.
Definition: histogram.cpp:366
unsigned int get_sum() const
Get sum of all values.
Definition: histogram.cpp:557
~Histogram()
Destructor.
Definition: histogram.cpp:126
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:303
unsigned int get_median()
Get median of all values.
Definition: histogram.cpp:507
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:322
unsigned int get_num_undos()
Get number of undos.
Definition: histogram.cpp:497
void reset_undo()
Reset undo.
Definition: histogram.cpp:450
Histogram(unsigned int width, unsigned int height, unsigned int depth=1, unsigned int num_undos=1)
Constructor.
Definition: histogram.cpp:58
void print_to_stream(std::ostream &s)
Print to stream.
Definition: histogram.cpp:383
unsigned int get_value(unsigned int x, unsigned int y)
Get value from histogram.
Definition: histogram.cpp:221
void get_dimensions(unsigned int &width, unsigned int &height, unsigned int &depth)
Obtain dimensions of the histogram.
Definition: histogram.cpp:207
void set_value(unsigned int x, unsigned int y, unsigned int value)
Set value in histogram.
Definition: histogram.cpp:246
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:341
HistogramBlock * get_histogram_block()
Obtain the histogram block of this histogram.
Definition: histogram.cpp:195
void operator+=(fawkes::upoint_t *p)
Add point.
Definition: histogram.cpp:141
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
bool load(const char *filename)
Load from file.
Definition: histogram.cpp:419
unsigned int switch_undo(unsigned int undo_id)
Switch undo to another undo buffer.
Definition: histogram.cpp:479
This class defines a file block for histograms.
unsigned int * get_histogram()
Get histogram data buffer.
Definition: histogram.cpp:185
void save(const char *filename, bool formatted_output=false)
Save to file.
Definition: histogram.cpp:403