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

int Impala::Core::Feature::Color64::ExtractCorrelogramTextureMoment ( BYTE *  pImage,
int  nWidth,
int  nHeight,
void *  pFeature,
int  mode = 0 
) [inline]

Definition at line 254 of file Color64.h.

References BYTE, ExtractCorrelogram50(), ExtractTextureMoment(), mode, NormalizeVector(), and QuantizeColorHSV44().

Referenced by ComputeGrid(), and Extract().

00255     {
00256             if (pFeature == 0)
00257             {
00258                     return -1;
00259             }
00260         memset(pFeature, 0, sizeof(float) * 64);
00261 
00262         if (nWidth < 3 || nHeight < 3)
00263         {
00264             return -1;
00265         }
00266 
00267         float* pfCorrelogram44 = (float*)pFeature;
00268         float* pfTextureMoment = pfCorrelogram44 + 44;
00269         float* pfColorMoment = pfTextureMoment + 14;
00270 
00271         float* pfImage = new float[nWidth * nHeight];
00272         BYTE* pbImage = new BYTE[nWidth * nHeight];
00273 
00274         if (pbImage != NULL && pfImage != NULL)
00275         {
00276             for (int y = 0; y < nHeight; y ++)
00277             {
00278                 float* pf = pfImage + y * nWidth;
00279                 BYTE* pb = pbImage + y * nWidth;
00280 
00281                 for (int x = 0; x < nWidth; x ++)
00282                 {
00283                     // Note: the order of the buffer is RGBRGB...
00284                     BYTE r = pImage[(y*nWidth+x)*3+0];
00285                     BYTE g = pImage[(y*nWidth+x)*3+1];
00286                     BYTE b = pImage[(y*nWidth+x)*3+2];
00287 
00288                     pf[x] =(float) r + g + b;
00289                     pb[x] = QuantizeColorHSV44(r, g, b);
00290 
00291                     pfColorMoment[0] += r;
00292                     pfColorMoment[1] += g;
00293                     pfColorMoment[2] += b;
00294 
00295                     pfColorMoment[3] += r * r;
00296                     pfColorMoment[4] += g * g;
00297                     pfColorMoment[5] += b * b;
00298                 }
00299             }
00300 
00301             float fArea =(float) nWidth * nHeight;
00302 
00303             switch (mode)
00304             {
00305              case 1: // 44-d color correlogram
00306 
00307                 ExtractCorrelogram50(pbImage, nWidth, nHeight, pfCorrelogram44);
00308                 break;
00309 
00310              case 2: // 14-d color texture moment
00311 
00312                 ExtractTextureMoment(pfImage, nWidth, nHeight, pfTextureMoment);
00313                 break;
00314 
00315              case 3: // 6-d RGB color moment
00316                 
00317                 for (int i = 0; i < 3; i ++)
00318                 {
00319                     pfColorMoment[i] /= fArea;
00320                     pfColorMoment[i + 3] = pfColorMoment[i + 3] / fArea - pfColorMoment[i] * pfColorMoment[i];
00321                     pfColorMoment[i + 3] = (float)sqrt(fabs(pfColorMoment[i + 3]));
00322                 }
00323                 NormalizeVector(pfColorMoment, 6);
00324                 break;
00325 
00326              default: // color64 = 44+14+6
00327 
00328                 ExtractCorrelogram50(pbImage, nWidth, nHeight, pfCorrelogram44);
00329                 ExtractTextureMoment(pfImage, nWidth, nHeight, pfTextureMoment);
00330 
00331                 for (int i = 0; i < 3; i ++)
00332                 {
00333                     pfColorMoment[i] /= fArea;
00334                     pfColorMoment[i + 3] = pfColorMoment[i + 3] / fArea - pfColorMoment[i] * pfColorMoment[i];
00335                     pfColorMoment[i + 3] = (float)sqrt(fabs(pfColorMoment[i + 3]));
00336                 }
00337                 NormalizeVector(pfColorMoment, 6);
00338 
00339                 break;
00340             }
00341 
00342         }
00343         if (pbImage != NULL)
00344         {
00345             delete []pbImage;
00346         }
00347         if (pfImage != NULL)
00348         {
00349             delete []pfImage;
00350         }
00351 
00352             return 0;
00353     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:08:44 2010 for ImpalaSrc by  doxygen 1.5.1