Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

RgbHistExtractor.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_RgbHistExtractor_h
00002 #define Impala_Core_VideoSet_RgbHistExtractor_h
00003 
00004 #include "Core/VideoSet/HistogramExtractor.h"
00005 #include "Core/Vector/DivAssign.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace VideoSet
00012 {
00013 
00014 class RgbHistExtractor : public HistogramExtractor
00015 {
00016 
00017 public:
00018 
00019     RgbHistExtractor(Reporter* reporter, CmdOptions& options) :
00020       HistogramExtractor(reporter, options, "rgbhistogram", 3 * BINS_PER_CHANNEL)
00021     {
00022     }
00023 
00024     virtual 
00025     ~RgbHistExtractor()
00026     {
00027     }
00028 
00029 protected:
00030 
00031     virtual VectorReal64
00032     ComputeHistogram(Array::Array2dVec3UInt8* image)
00033     {
00034         UInt8* data = image->CPB(0, 0);
00035         const int nPix = image->CW() * image->CH();
00036 
00037         VectorReal64 histogram(GetBinCount());
00038         Real64* histR = histogram.GetData();
00039         Real64* histG = histR + BINS_PER_CHANNEL;
00040         Real64* histB = histG + BINS_PER_CHANNEL;
00041 
00042         for (int i = 0; i < GetBinCount(); i++)
00043             histR[i] = 0;
00044 
00045         for (int j = 0; j < nPix; j++) 
00046         {
00047             const int r = ComputeBin((int) data[0], 0, 255, BINS_PER_CHANNEL);
00048             histR[r] += 1;
00049 
00050             const int g = ComputeBin((int) data[1], 0, 255, BINS_PER_CHANNEL);
00051             histG[g] += 1;
00052 
00053             const int b = ComputeBin((int) data[2], 0, 255, BINS_PER_CHANNEL);
00054             histB[b] += 1;
00055 
00056             data += 3;
00057         }
00058 
00059         const Real64 factor = nPix;
00060         Vector::DivAssign(histogram, factor);
00061 
00062         return histogram;
00063     }
00064 
00065 
00066 private:
00067 
00068     static const int BINS_PER_CHANNEL = 32;
00069 
00070     ILOG_VAR_DECL;
00071 };
00072 
00073 ILOG_VAR_INIT(RgbHistExtractor, Impala.Core.VideoSet);
00074 
00075 } // namespace VideoSet
00076 } // namespace Core
00077 } // namespace Impala
00078 
00079 #endif

Generated on Fri Mar 19 09:31:31 2010 for ImpalaSrc by  doxygen 1.5.1