|
degate 0.1.1
|
#include <ImageHistogram.h>

Public Member Functions | |
| ImageHistogram (double _from, double _to, double _class_width) | |
| virtual | ~ImageHistogram () |
| virtual void | add (KeyType k) |
| virtual ValueType | get (KeyType k) const |
| virtual ValueType | get_for_rgb (rgba_pixel_t) const =0 |
| virtual void | save_histogram (std::string const &path) const |
Protected Member Functions | |
| void | check_bounding_box (BoundingBox const &bb, ImageBase_shptr img) const |
| KeyType | to_class (ValueType v, ValueType from, ValueType to, ValueType class_width) const |
Private Types | |
| typedef std::map< KeyType, ValueType > | map_type |
Private Attributes | |
| map_type | histogram |
| unsigned int | counts |
| double | from |
| double | to |
| double | class_width |
Definition at line 37 of file ImageHistogram.h.
typedef std::map<KeyType, ValueType> degate::ImageHistogram< KeyType, ValueType >::map_type [private] |
Definition at line 40 of file ImageHistogram.h.
| degate::ImageHistogram< KeyType, ValueType >::ImageHistogram | ( | double | _from, |
| double | _to, | ||
| double | _class_width | ||
| ) | [inline] |
Definition at line 78 of file ImageHistogram.h.
:
counts(0),
from(_from),
to(_to),
class_width(_class_width) {}
| virtual degate::ImageHistogram< KeyType, ValueType >::~ImageHistogram | ( | ) | [inline, virtual] |
Definition at line 84 of file ImageHistogram.h.
{}
| virtual void degate::ImageHistogram< KeyType, ValueType >::add | ( | KeyType | k | ) | [inline, virtual] |
Definition at line 86 of file ImageHistogram.h.
| void degate::ImageHistogram< KeyType, ValueType >::check_bounding_box | ( | BoundingBox const & | bb, |
| ImageBase_shptr | img | ||
| ) | const [inline, protected] |
Definition at line 48 of file ImageHistogram.h.
{
if(std::max(bb.get_min_x(), bb.get_max_x()) >= (int)img->get_width() ||
std::max(bb.get_min_y(), bb.get_max_y()) >= (int)img->get_height() ||
std::min(bb.get_min_x(), bb.get_max_x()) < 0 ||
std::min(bb.get_min_y(), bb.get_max_y()) < 0) {
boost::format f("Error in add_area(). Defined region %1% is beyond image boundary.");
f % bb.to_string();
throw DegateRuntimeException(f.str());
}
if(bb.get_height() == 0 && bb.get_width() == 0)
throw DegateRuntimeException("Bounding box has zero size");
}
| virtual ValueType degate::ImageHistogram< KeyType, ValueType >::get | ( | KeyType | k | ) | const [inline, virtual] |
Definition at line 91 of file ImageHistogram.h.
| virtual ValueType degate::ImageHistogram< KeyType, ValueType >::get_for_rgb | ( | rgba_pixel_t | ) | const [pure virtual] |
| virtual void degate::ImageHistogram< KeyType, ValueType >::save_histogram | ( | std::string const & | path | ) | const [inline, virtual] |
Definition at line 103 of file ImageHistogram.h.
{
std::ofstream histogram_file;
histogram_file.open(path.c_str());
if(counts > 0)
for(typename map_type::const_iterator iter = histogram.begin(); iter != histogram.end(); ++iter) {
double frequency = (*iter).second / (double)counts;
histogram_file << (*iter).first << " " << frequency << std::endl;
}
histogram_file.close();
}
| KeyType degate::ImageHistogram< KeyType, ValueType >::to_class | ( | ValueType | v, |
| ValueType | from, | ||
| ValueType | to, | ||
| ValueType | class_width | ||
| ) | const [inline, protected] |
Definition at line 63 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), and degate::ImageHistogram< double, double >::get().
{
//unsigned int classes = (to - from) / class_width;
//unsigned int class_num = v / class_width;
//KeyType cl = v * class_width;
unsigned int c = 0;
for(ValueType i = from; i < to; i+= class_width, c++) {
if(v >= (ValueType)c*class_width && v < (ValueType)(c+1)*class_width)
return (ValueType)c*class_width;
}
}

double degate::ImageHistogram< KeyType, ValueType >::class_width [private] |
Definition at line 44 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), degate::ImageHistogram< double, double >::get(), and degate::ImageHistogram< double, double >::to_class().
unsigned int degate::ImageHistogram< KeyType, ValueType >::counts [private] |
Definition at line 42 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), degate::ImageHistogram< double, double >::get(), and degate::ImageHistogram< double, double >::save_histogram().
double degate::ImageHistogram< KeyType, ValueType >::from [private] |
Definition at line 44 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), and degate::ImageHistogram< double, double >::get().
map_type degate::ImageHistogram< KeyType, ValueType >::histogram [private] |
Definition at line 41 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), degate::ImageHistogram< double, double >::get(), and degate::ImageHistogram< double, double >::save_histogram().
double degate::ImageHistogram< KeyType, ValueType >::to [private] |
Definition at line 44 of file ImageHistogram.h.
Referenced by degate::ImageHistogram< double, double >::add(), degate::ImageHistogram< double, double >::get(), and degate::ImageHistogram< double, double >::to_class().
1.7.4