Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
45  void operator+=(fawkes::point_t *p);
46  void operator+=(fawkes::point_t p);
47 
48  unsigned int * get_histogram();
49  HistogramBlock* get_histogram_block();
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