Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * histogram.h - Header for histograms 00004 * 00005 * Generated: Tue Jun 14 11:09:27 2005 00006 * Copyright 2005 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __FIREVISION_UTILS_HISTOGRAM_H_ 00025 #define __FIREVISION_UTILS_HISTOGRAM_H_ 00026 00027 #include <fvutils/base/types.h> 00028 #include <iostream> 00029 00030 namespace firevision { 00031 #if 0 /* just to make Emacs auto-indent happy */ 00032 } 00033 #endif 00034 00035 class HistogramBlock; 00036 00037 class Histogram 00038 { 00039 public: 00040 Histogram(unsigned int width, unsigned int height, 00041 unsigned int depth = 1, unsigned int num_undos = 1); 00042 Histogram(HistogramBlock* histogram_block); 00043 ~Histogram(); 00044 00045 void operator+=(fawkes::point_t *p); 00046 void operator+=(fawkes::point_t p); 00047 00048 unsigned int * get_histogram(); 00049 HistogramBlock* get_histogram_block(); 00050 void get_dimensions(unsigned int& width, unsigned int& height, unsigned int& depth); 00051 unsigned int get_value(unsigned int x, unsigned int y); 00052 unsigned int get_value(unsigned int x, unsigned int y, unsigned int z); 00053 void set_value(unsigned int x, unsigned int y, unsigned int value); 00054 void set_value(unsigned int x, unsigned int y, unsigned int z, unsigned int value); 00055 void inc_value(unsigned int x, unsigned int y, unsigned int z = 0); 00056 void add(unsigned int x, unsigned int y, unsigned int z, unsigned int value); 00057 void sub(unsigned int x, unsigned int y, unsigned int z, unsigned int value); 00058 void reset(); 00059 unsigned int get_median(); 00060 unsigned int get_average(); 00061 00062 unsigned int get_sum() const; 00063 00064 void reset_undo(); 00065 void undo(); 00066 unsigned int switch_undo( unsigned int undo_id ); 00067 unsigned int get_num_undos(); 00068 00069 void print_to_stream(std::ostream &s); 00070 void save(const char * filename, bool formatted_output = false); 00071 bool load(const char * filename); 00072 00073 private: 00074 unsigned int width; 00075 unsigned int height; 00076 unsigned int depth; 00077 unsigned int dimension; 00078 unsigned int histogram_size; 00079 unsigned int* histogram; 00080 HistogramBlock *histogram_block; 00081 unsigned int number_of_values; 00082 00083 unsigned int **undo_overlay; 00084 unsigned int *undo_num_vals; 00085 unsigned int undo_num; 00086 unsigned int undo_current; 00087 }; 00088 00089 } // end namespace firevision 00090 00091 #endif