Definition at line 284 of file Color64.h. References BYTE, ExtractCorrelogram50(), ExtractTextureMoment(), mode, NormalizeVector(), and QuantizeColorHSV44(). Referenced by ComputeGrid(), and Extract(). 00285 { 00286 if (pFeature == 0) 00287 { 00288 return -1; 00289 } 00290 memset(pFeature, 0, sizeof(float) * 64); 00291 00292 if (nWidth < 3 || nHeight < 3) 00293 { 00294 return -1; 00295 } 00296 00297 float* pfCorrelogram44 = (float*)pFeature; 00298 float* pfTextureMoment = pfCorrelogram44 + 44; 00299 float* pfColorMoment = pfTextureMoment + 14; 00300 00301 float* pfImage = new float[nWidth * nHeight]; 00302 BYTE* pbImage = new BYTE[nWidth * nHeight]; 00303 00304 if (pbImage != NULL && pfImage != NULL) 00305 { 00306 for (int y = 0; y < nHeight; y ++) 00307 { 00308 float* pf = pfImage + y * nWidth; 00309 BYTE* pb = pbImage + y * nWidth; 00310 00311 for (int x = 0; x < nWidth; x ++) 00312 { 00313 // Note: the order of the buffer is RGBRGB... 00314 BYTE r = pImage[(y*nWidth+x)*3+0]; 00315 BYTE g = pImage[(y*nWidth+x)*3+1]; 00316 BYTE b = pImage[(y*nWidth+x)*3+2]; 00317 00318 pf[x] =(float) r + g + b; 00319 pb[x] = QuantizeColorHSV44(r, g, b); 00320 00321 pfColorMoment[0] += r; 00322 pfColorMoment[1] += g; 00323 pfColorMoment[2] += b; 00324 00325 pfColorMoment[3] += r * r; 00326 pfColorMoment[4] += g * g; 00327 pfColorMoment[5] += b * b; 00328 } 00329 } 00330 00331 float fArea =(float) nWidth * nHeight; 00332 00333 switch (mode) 00334 { 00335 case 1: // 44-d color correlogram 00336 00337 ExtractCorrelogram50(pbImage, nWidth, nHeight, pfCorrelogram44); 00338 break; 00339 00340 case 2: // 14-d color texture moment 00341 00342 ExtractTextureMoment(pfImage, nWidth, nHeight, pfTextureMoment); 00343 break; 00344 00345 case 3: // 6-d RGB color moment 00346 00347 for (int i = 0; i < 3; i ++) 00348 { 00349 pfColorMoment[i] /= fArea; 00350 pfColorMoment[i + 3] = pfColorMoment[i + 3] / fArea - pfColorMoment[i] * pfColorMoment[i]; 00351 pfColorMoment[i + 3] = (float)sqrt(fabs(pfColorMoment[i + 3])); 00352 } 00353 NormalizeVector(pfColorMoment, 6); 00354 break; 00355 00356 default: // color64 = 44+14+6 00357 00358 ExtractCorrelogram50(pbImage, nWidth, nHeight, pfCorrelogram44); 00359 ExtractTextureMoment(pfImage, nWidth, nHeight, pfTextureMoment); 00360 00361 for (int i = 0; i < 3; i ++) 00362 { 00363 pfColorMoment[i] /= fArea; 00364 pfColorMoment[i + 3] = pfColorMoment[i + 3] / fArea - pfColorMoment[i] * pfColorMoment[i]; 00365 pfColorMoment[i + 3] = (float)sqrt(fabs(pfColorMoment[i + 3])); 00366 } 00367 NormalizeVector(pfColorMoment, 6); 00368 00369 break; 00370 } 00371 00372 } 00373 if (pbImage != NULL) 00374 { 00375 delete []pbImage; 00376 } 00377 if (pfImage != NULL) 00378 { 00379 delete []pfImage; 00380 } 00381 00382 return 0; 00383 }
Here is the call graph for this function:
|