www.pudn.com > several_kinds_Histogram.rar > CCVHistogram.CPP
#include"stdafx.h"
#include"CCVHistogram.h"
//only need to over write virtual function
bool CCVHistogram::ApplySpace()
{
HistSize=m_c1*m_c2*m_c3*2;
pHist=new double[HistSize]();
if(pHist==NULL)
return false;
for(WORD i=0;i!=HistSize;++i)
pHist[i]=0;
return true;
}
bool CCVHistogram::ExtractHistogram()
{
std::vector::iterator iter=feature.begin();
int imagewidth=pimagedata->width;
int imageheight=pimagedata->height;
for(;iter!=feature.end();++iter)
{
std::vector::size_type i=iter-feature.begin();
/*cout< DadjacenPixel;
DWORD count(1);
if(! (PIXEL_PROCESSED_MASK & *iter))
{
DadjacenPixel.push_back(currpixel);
*iter |= PIXEL_PROCESSED_MASK; //the highest bit is set to 1;
while(!DadjacenPixel.empty())
{
Point pixel=DadjacenPixel.front();
DadjacenPixel.pop_front();
//find the adjacent pixel of the point pixel
for(int j=pixel.y-1;j<=pixel.y+2;++j)
for(int k=pixel.x-1;k<=pixel.x+2;++k)
{
if(j>=0 && j < imageheight && k >= 0 && k(count)/(imagewidth*imageheight);
/* cout<=dRatiponTh) // exceeds the threshold
pHist[(featurevalue & PIXEL_DATA_MASK) << 1] += temp;
else
pHist[(featurevalue & PIXEL_DATA_MASK) << 1 | 1] += temp;
}
}
return true;
}