• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

include/FCam/Histogram.h

Go to the documentation of this file.
00001 #ifndef FCAM_HISTOGRAM_H
00002 #define FCAM_HISTOGRAM_H
00003 
00004 #include <vector>
00005 
00010 namespace FCam {
00012     class HistogramConfig {         
00013       public:
00016         HistogramConfig() : buckets(64), enabled(false) {}
00017       
00020         Rect region;
00021 
00025         unsigned buckets;
00026 
00028         bool enabled;
00029 
00032         bool operator==(const HistogramConfig &other) const {
00033             if (enabled != other.enabled) return false;
00034             if (buckets != other.buckets) return false;
00035             if (region != other.region) return false;
00036             return true;
00037         }
00038 
00041         bool operator!=(const HistogramConfig &other) const {
00042             return !((*this) == other);
00043         }
00044     };
00045 
00046 
00051     class Histogram {
00052         unsigned _buckets, _channels;
00053         Rect _region;
00054         std::vector<unsigned> _data;
00055 
00056       public:
00057 
00060         Histogram(): _buckets(0), _channels(0), _region(0, 0, 0, 0) {
00061         }
00062 
00064         Histogram(unsigned buckets, unsigned channels, Rect region) :
00065             _buckets(buckets), _channels(channels), _region(region) {
00066             _data.resize(buckets*channels);
00067         }
00068 
00080         unsigned operator()(int b, int c) const {
00081             return _data[b*_channels + c];
00082         }
00083 
00086         unsigned &operator()(int b, int c) {
00087             return _data[b*_channels + c];
00088         }
00089 
00092         unsigned operator()(int b) const {
00093             unsigned result = 0;
00094             for (size_t c = 0; c < _channels; c++)
00095                 result += (*this)(b, c);
00096             return result;
00097         }
00098 
00100         bool valid() const {
00101             return _data.size() != 0;
00102         }
00103 
00106         unsigned *data() {return &_data[0];}  
00107 
00109         unsigned buckets() const {return _buckets;}
00110 
00112         unsigned channels() const {return _channels;}
00113 
00115         Rect region() const {return _region;}
00116     };
00117    
00118 }
00119 
00120 #endif

Generated on Mon Aug 16 2010 14:25:45 for FCam by  doxygen 1.7.1