histogram.h

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 class HistogramBlock;
00031
00032 class Histogram
00033 {
00034  public:
00035   Histogram(unsigned int width, unsigned int height,
00036             unsigned int depth = 1, unsigned int num_undos = 1);
00037   Histogram(HistogramBlock* histogram_block);
00038   ~Histogram();
00039
00040   void           operator+=(fawkes::point_t *p);
00041   void           operator+=(fawkes::point_t  p);
00042
00043   unsigned int * get_histogram();
00044   HistogramBlock* get_histogram_block();
00045   void           get_dimensions(unsigned int& width, unsigned int& height, unsigned int& depth);
00046   unsigned int   get_value(unsigned int x, unsigned int y);
00047   unsigned int   get_value(unsigned int x, unsigned int y, unsigned int z);
00048   void           set_value(unsigned int x, unsigned int y, unsigned int value);
00049   void           set_value(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
00050   void           inc_value(unsigned int x, unsigned int y, unsigned int z = 0);
00051   void           add(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
00052   void           sub(unsigned int x, unsigned int y, unsigned int z, unsigned int value);
00053   void           reset();
00054   unsigned int   get_median();
00055   unsigned int   get_average();
00056
00057   unsigned int   get_sum() const;
00058
00059   void           reset_undo();
00060   void           undo();
00061   unsigned int   switch_undo( unsigned int undo_id );
00062   unsigned int   get_num_undos();
00063
00064   void           print_to_stream(std::ostream &s);
00065   void           save(const char * filename, bool formatted_output = false);
00066   bool           load(const char * filename);
00067
00068  private:
00069   unsigned int  width;
00070   unsigned int  height;
00071   unsigned int  depth;
00072   unsigned int  dimension;
00073   unsigned int  histogram_size;
00074   unsigned int* histogram;
00075   HistogramBlock *histogram_block;
00076   unsigned int  number_of_values;
00077
00078   unsigned int **undo_overlay;
00079   unsigned int  *undo_num_vals;
00080   unsigned int   undo_num;
00081   unsigned int   undo_current;
00082 };
00083
00084
00085
00086 #endif