本文整理汇总了C++中CDib::Allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ CDib::Allocate方法的具体用法?C++ CDib::Allocate怎么用?C++ CDib::Allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDib
的用法示例。
在下文中一共展示了CDib::Allocate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ColorBoxRecog
///////////// Vision Class Implementation //////////////
CDib* CVisionTab::ColorBoxRecog(CDib* pImg)
{
// ------------------------------------------------------
// ------------------- Color Slicing &-------------------
// ------------- Kernel density estimation --------------
// ------------------------------------------------------
//CalcTime();
// input image 영상 처리 및 복사
CDib* src = pImg->GetSingleScaleRetinexImage(1.5);
//CDib* src = pImg->CopyCDib();
int width = src->Width();
int height = src->Height();
//int bitcount = src->BitCount();
int bitcount = 8;
CDib* pRed = new CDib;
pRed->Allocate(width, height, bitcount);
pRed->SetGrayPalette();
CDib* pGreen = new CDib;
pGreen->Allocate(width, height, bitcount);
pGreen->SetGrayPalette();
CDib* pBlue = new CDib;
pBlue->Allocate(width, height, bitcount);
pBlue->SetGrayPalette();
CDib* pYellow = new CDib;
pYellow->Allocate(width, height, bitcount);
pYellow->SetGrayPalette();
register int i, j;
double h, s, v;
int step = (int)src->BitCount()/8;
RGBQUAD quad;
CKde* kdemat[NUMBOX];
for(i=0; i<NUMBOX; i++) {
kdemat[i] = new CKde;
kdemat[i]->initKDEmask(width, height, 4); // initialize KDE function
}
for(j=0; j<src->Height(); j++)
{
unsigned char *ptr = src->GetPointer(0,j);
for(i=0; i<src->Width(); i++, ptr+=step)
{
quad.rgbBlue = *(ptr+0); quad.rgbGreen = *(ptr+1); quad.rgbRed = *(ptr+2);
src->RGBtoHSV(quad, &h, &s, &v);
// normalize Hue
h /= 360;
// Red Box: 0.93, 0.97
if(h > 0.91 && h < 0.99 && s > TS && v > Ti) {
unsigned char *pr = pRed->GetPointer(i,j);
*(pr+0) = 255;
kdemat[RED]->setSumKDEmask(i,j);
}
// Green Box: 0.25, 0.37
if(h > 0.24 && h < 0.38 && s > TS && v > Ti) { // default: 0.27, 0.36
unsigned char *pg = pGreen->GetPointer(i,j);
*(pg+0) = 255;
kdemat[GREEN]->setSumKDEmask(i,j);
}
// Blue: 0.59, 0.65
if(h > 0.59 && h < 0.65 && s > TS && v > Ti) {
unsigned char *pb = pBlue->GetPointer(i,j);
*(pb+0) = 255;
kdemat[BLUE]->setSumKDEmask(i,j);
}
// Yellow: 0.12, 0.14
if(h > 0.11 && h < 0.15 && s > TS && v > Ti) {
unsigned char *py = pYellow->GetPointer(i,j);
*(py+0) = 255;
kdemat[YELLOW]->setSumKDEmask(i,j);
}
}
}
// *****************************************************************
//
// 본 프로그램의 좌표는 크게 아래 3가지로 나뉜다.
//.........这里部分代码省略.........