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

virtual VectorReal64 Impala::Core::VideoSet::LabHistExtractor::ComputeHistogram ( Array::Array2dVec3UInt8 image  )  [inline, protected, virtual]

Implements Impala::Core::VideoSet::HistogramExtractor.

Definition at line 37 of file LabHistExtractor.h.

References BINS_PER_CHANNEL, Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CH(), Impala::Core::VideoSet::HistogramExtractor::ComputeBin(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CPB(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CW(), Impala::Core::Vector::DivAssign(), Impala::Core::VideoSet::HistogramExtractor::GetBinCount(), Impala::Core::Vector::VectorTem< ElemT >::GetData(), Impala::Core::Array::Element::RGB, Impala::Core::Array::Element::Color::ToLab(), Impala::Core::Array::Element::Color::Value(), Impala::Core::Array::Element::Vec3Real64::X(), Impala::Core::Array::Element::Vec3Real64::Y(), and Impala::Core::Array::Element::Vec3Real64::Z().

00038     {
00039         UInt8* data = image->CPB(0, 0);
00040         const int nPix = image->CW() * image->CH();
00041 
00042         VectorReal64 histogram(GetBinCount());
00043         Real64* histL = histogram.GetData();
00044         Real64* histA = histL + BINS_PER_CHANNEL;
00045         Real64* histB = histA + BINS_PER_CHANNEL;
00046 
00047         for (int i = 0; i < GetBinCount(); i++)
00048             histL[i] = 0;
00049 
00050         for (int j = 0; j < nPix; j++) 
00051         {
00052             const Array::Element::Vec3Real64 pixel = 
00053                 Array::Element::Vec3Real64(data[0], data[1], data[2]);
00054             const Array::Element::Color crgb(pixel, Array::Element::RGB);
00055 
00056             Array::Element::Color clab = crgb.ToLab();
00057             Array::Element::Vec3Real64 lab = clab.Value();
00058 
00059             // Assume L between 0 and 100
00060             int l = ComputeBin(lab.X(), 0.0, 100.0, BINS_PER_CHANNEL);
00061             histL[l] += 1;
00062 
00063             // Assume a between -90 and 90
00064             int a = ComputeBin(lab.Y(), -90.0, 90.0, BINS_PER_CHANNEL);
00065             histA[a] += 1;
00066 
00067             // Assume b between -90 and 90
00068             int b = ComputeBin(lab.Z(), -90.0, 90.0, BINS_PER_CHANNEL);
00069             histB[b] += 1;
00070 
00071             data += 3;
00072         }
00073 
00074         const Real64 factor = nPix;
00075         Vector::DivAssign(histogram, factor);
00076 
00077         return histogram;
00078     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:30:28 2010 for ImpalaSrc by  doxygen 1.5.1