histogram_block.h

00001
00002 /***************************************************************************
00003  *  histogram_block.h - Histogram block
00004  *
00005  *  Created: Sat Mar 29 21:01:49 2008
00006  *  Copyright  2008  Daniel Beck
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 __FIREVISIONE_FVUTILS_STATISTICAL_HISTOGRAM_BLOCK_H_
00025 #define __FIREVISIONE_FVUTILS_STATISTICAL_HISTOGRAM_BLOCK_H_
00026 
00027 #include <fvutils/fileformat/fvfile_block.h>
00028 #include <fvutils/base/roi.h>
00029 #include <stdint.h>
00030
00031 
00032 /** Header for a histogram block. */
00033 typedef struct _histogram_block_header_t
00034 {
00035   uint16_t width;          /**< the width of the histogram */
00036   uint16_t height;         /**< the height of the histogram */
00037   uint16_t depth;          /**< the depth of the histogram */
00038   uint8_t  object_type;    /**< the type of object the histogram is associated with */
00039 } histogram_block_header_t;
00040
00041 
00042 /** The blocktype of a histogram block. */
00043 typedef enum _histogram_block_type_t
00044 {
00045   FIREVISION_HISTOGRAM_TYPE_16 = 0,    /**< histogram uses 16 bits per cell */
00046   FIREVISION_HISTOGRAM_TYPE_32 = 1     /**< histogram uses 32 bits per cell */
00047 } histogram_block_type_t;
00048
00049
00050 class HistogramBlock : public FireVisionDataFileBlock
00051 {
00052  public:
00053   HistogramBlock(histogram_block_type_t type, hint_t object_type,
00054                  uint16_t width, uint16_t height, uint16_t depth = 0);
00055   HistogramBlock(FireVisionDataFileBlock* block);
00056
00057   virtual ~HistogramBlock();
00058
00059   uint16_t width() const;
00060   uint16_t height() const;
00061   uint16_t depth() const;
00062
00063   hint_t object_type() const;
00064   void set_object_type(hint_t object_type);
00065
00066   void set_data(uint32_t* data);
00067
00068   void set_value(uint16_t x, uint16_t y, uint32_t val);
00069   void set_value(uint16_t x, uint16_t y, uint16_t z, uint32_t val);
00070
00071   uint32_t get_value(uint16_t x, uint16_t y);
00072   uint32_t get_value(uint16_t x, uint16_t y, uint16_t z);
00073
00074   void reset();
00075
00076  private:
00077   histogram_block_header_t* _block_header;
00078   uint32_t* _histogram_data;
00079 };
00080
00081 #endif /* __FIREVISIONE_FVUTILS_STATISTICAL_HISTOGRAM_BLOCK_H_ */