24 #include <fvutils/statistical/histogram_block.h> 25 #include <core/exceptions/software.h> 49 HistogramBlock::HistogramBlock(histogram_block_type_t type, hint_t object_type,
50 uint16_t width, uint16_t height, uint16_t depth)
60 _histogram_data = (uint32_t*)
_data;
70 _histogram_data = (uint32_t*)
_data;
84 return _block_header->
width;
93 return _block_header->
height;
102 return _block_header->
depth;
141 if (_block_header->
depth != 0)
142 {
throw Exception(
"Trying to acces a 3-dim histogram with a 2-dim access method"); }
144 if (x >= _block_header->
width)
147 float(x), 0.0f,
float(_block_header->
width));
150 if (y >= _block_header->
height)
153 float(y), 0.0f,
float(_block_header->
height));
156 _histogram_data[y * _block_header->
width + x] = val;
168 if ( x >= _block_header->
width)
171 float(x), 0.0f,
float(_block_header->
width));
174 if ( y >= _block_header->
height)
177 float(y), 0.0f,
float(_block_header->
height));
180 if ( z >= _block_header->
depth)
183 float(z), 0.0f,
float(_block_header->
depth));
186 _histogram_data[z * _block_header->
width * _block_header->
height + y * _block_header->
width + x] = val;
197 if (_block_header->
depth != 0)
198 {
throw Exception(
"Trying to acces a 3-dim histogram with a 2-dim access method"); }
200 if ( x >= _block_header->
width)
203 float(x), 0.0f,
float(_block_header->
width));
206 if ( y >= _block_header->
height)
209 float(y), 0.0f,
float(_block_header->
height));
212 return _histogram_data[y * _block_header->
width + x];
224 if ( x >= _block_header->
width)
227 float(x), 0.0f, _block_header->
width - 1);
230 if ( y >= _block_header->
height)
233 float(y), 0.0f, _block_header->
height - 1);
236 if ( z >= _block_header->
depth)
239 float(z), 0.0f, _block_header->
depth - 1);
242 return _histogram_data[z * _block_header->
width * _block_header->
height + y * _block_header->
width + x];
void set_object_type(hint_t object_type)
Set the type of the object the histogram is associated with.
uint16_t depth() const
Returns the the depth of the histogram.
Fawkes library namespace.
void * _data
Pointer to the internal data segment.
void set_value(uint16_t x, uint16_t y, uint32_t val)
Store a value in a certain cell of a 2-dimensional histogram.
hint_t object_type() const
Returns the type of the object the histogram is associated with.
uint16_t width() const
Returns the the width of the histogram.
FireVision File Format data block.
virtual ~HistogramBlock()
Destructor.
void * _spec_header
Pointer to the content specific block header.
Base class for exceptions in Fawkes.
void set_data(uint32_t *data)
Directly set the histogram data.
void reset()
Reset the histogram.
HistogramBlock(histogram_block_type_t type, hint_t object_type, uint16_t width, uint16_t height, uint16_t depth=0)
Constructor.
uint16_t height() const
Returns the the height of the histogram.
uint32_t get_value(uint16_t x, uint16_t y)
Obtain a certain value from a 2-dimensional histogram.
size_t _data_size
Size of _data in bytes.