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

int Impala::Core::Feature::Color64::QuantizeColorHSV44 ( BYTE  bRed,
BYTE  bGreen,
BYTE  bBlue 
) [inline]

Definition at line 502 of file Color64.h.

References BYTE, max, and min.

Referenced by ExtractCorrelogramTextureMoment().

00503     {
00504         static BYTE RGB2HSV[16][16][16];
00505         static bool bInit = false;
00506         if (!bInit)
00507         {
00508             for (int r = 0; r < 16; r ++)
00509             {
00510                 for (int g = 0; g < 16; g ++)
00511                 {
00512                     for (int b = 0; b < 16; b ++)
00513                     {
00514                         int nMax = max(r, max(g, b));
00515                         int nMin = min(r, min(g, b));
00516 
00517                         float h, s, v;
00518                         if (nMax == nMin)
00519                         {
00520                             h = 0;
00521                         }
00522                         else if (r == nMin)
00523                         {
00524                             h = 3.0f + (float)(b - g) / (nMax - nMin);
00525                         }
00526                         else if (g == nMin)
00527                         {
00528                             h = 5.0f + (float)(r - b) / (nMax - nMin);
00529                         }
00530                         else //if (b == nMin)
00531                         {
00532                             h = 1.0f + (float)(g - r) / (nMax - nMin);
00533                         }
00534                         if (nMax > 0)
00535                         {
00536                             s = (float)(nMax - nMin) / nMax;
00537                         }
00538                         else
00539                         {
00540                             s = 0;
00541                         }
00542                         v = (float)nMax / 15.0f;
00543 
00544                         int H = (int)(h * 60);
00545                         int S = (int)(s * 10);
00546                         int V = (int)(v * 10);
00547                         int nIndex;
00548 
00549                         if (V < 2)     // black area
00550                         {
00551                             nIndex = 0;
00552                         }
00553                         else if (S < 2) // Gray area
00554                         {
00555                             if (V < 8)
00556                             {
00557                                 nIndex = V - 1; // 1~6, gray area
00558                             }
00559                             else
00560                             {
00561                                 nIndex = 7 + (V >= 9);   // 7~8, white area
00562                             }
00563                         }
00564                         else // Color area
00565                         {
00566                             int nColor;
00567                             if (H < 22)
00568                             {
00569                                 nColor = 0; // red
00570                             }
00571                             else if (H < 45)
00572                             {
00573                                 nColor = 1; // orance
00574                             }
00575                             else if (H < 70)
00576                             {
00577                                 nColor = 2; // yellow
00578                             }
00579                             else if (H < 155)
00580                             {
00581                                 nColor = 3; // green
00582                             }
00583                             else if (H < 186)
00584                             {
00585                                 nColor = 4; // cyan
00586                             }
00587                             else if (H < 278)
00588                             {
00589                                 nColor = 5; // blue
00590                             }
00591                             else if (H < 330)
00592                             {
00593                                 nColor = 6; // purple
00594                             }
00595                             else
00596                             {
00597                                 nColor = 0; // red
00598                             }
00599                             
00600                             if (V >= 7) // SV plane is segmented into 5 regions
00601                             {
00602                                 nIndex = 2 + (S >= 5) + (S >= 8);
00603                             }
00604                             else
00605                             {
00606                                 nIndex = (S >= 7);
00607                             }
00608                             nIndex += 9 + 5 * nColor; // 9~43
00609                         }
00610                         RGB2HSV[r][g][b] = nIndex;
00611                     }
00612                 }
00613             }
00614             bInit = true;
00615         }
00616         return RGB2HSV[bRed / 16][bGreen / 16][bBlue / 16];
00617     }
00618 


Generated on Thu Jan 13 09:19:07 2011 for ImpalaSrc by  doxygen 1.5.1