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
31namespace firevision {
32
33class HistogramBlock;
34
36{
37public:
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
73private:
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
This class defines a file block for histograms.
unsigned int get_sum() const
Get sum of all values.
Definition: histogram.cpp:525
unsigned int * get_histogram()
Get histogram data buffer.
Definition: histogram.cpp:177
unsigned int get_average()
Get average of all values.
Definition: histogram.cpp:503
unsigned int get_value(unsigned int x, unsigned int y)
Get value from histogram.
Definition: histogram.cpp:210
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:324
unsigned int get_median()
Get median of all values.
Definition: histogram.cpp:477
unsigned int get_num_undos()
Get number of undos.
Definition: histogram.cpp:468
void operator+=(fawkes::upoint_t *p)
Add point.
Definition: histogram.cpp:135
unsigned int switch_undo(unsigned int undo_id)
Switch undo to another undo buffer.
Definition: histogram.cpp:451
void reset_undo()
Reset undo.
Definition: histogram.cpp:424
void print_to_stream(std::ostream &s)
Print to stream.
Definition: histogram.cpp:361
void reset()
Reset histogram.
Definition: histogram.cpp:345
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:306
void get_dimensions(unsigned int &width, unsigned int &height, unsigned int &depth)
Obtain dimensions of the histogram.
Definition: histogram.cpp:197
void set_value(unsigned int x, unsigned int y, unsigned int value)
Set value in histogram.
Definition: histogram.cpp:233
~Histogram()
Destructor.
Definition: histogram.cpp:121
Histogram(unsigned int width, unsigned int height, unsigned int depth=1, unsigned int num_undos=1)
Constructor.
Definition: histogram.cpp:53
bool load(const char *filename)
Load from file.
Definition: histogram.cpp:395
void save(const char *filename, bool formatted_output=false)
Save to file.
Definition: histogram.cpp:380
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:288
HistogramBlock * get_histogram_block()
Obtain the histogram block of this histogram.
Definition: histogram.cpp:186
Point with cartesian coordinates as unsigned integers.
Definition: types.h:35