RGB to HSV color conversion.
More...
|
NppStatus |
nppiRGBToHSV_8u_C3R_Ctx (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI, NppStreamContext nppStreamCtx) |
|
3 channel 8-bit unsigned packed RGB to 3 channel 8-bit unsigned packed HSV color conversion. More...
|
|
NppStatus |
nppiRGBToHSV_8u_C3R (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI) |
|
NppStatus |
nppiRGBToHSV_8u_AC4R_Ctx (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI, NppStreamContext nppStreamCtx) |
|
4 channel 8-bit unsigned packed RGB with alpha to 4 channel 8-bit unsigned packed HSV with alpha color conversion. More...
|
|
NppStatus |
nppiRGBToHSV_8u_AC4R (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI) |
|
RGB to HSV color conversion.
This is how NPP converts gamma corrected RGB or BGR to HSV. This code uses the fmaxf() and fminf() 32 bit floating point math functions.
*
*
Npp32f nV = fmaxf(nNormalizedR, nNormalizedG);
* nV = fmaxf(nV, nNormalizedB);
*
*
Npp32f nTemp = fminf(nNormalizedR, nNormalizedG);
* nTemp = fminf(nTemp, nNormalizedB);
*
Npp32f nDivisor = nV - nTemp;
* if (nV == 0.0F)
* {
* nS = 0.0F;
* nH = 0.0F;
* }
* else
* nS = nDivisor / nV;
*
*
Npp32f nCr = (nV - nNormalizedR) / nDivisor;
*
Npp32f nCg = (nV - nNormalizedG) / nDivisor;
*
Npp32f nCb = (nV - nNormalizedB) / nDivisor;
* if (nNormalizedR == nV)
* nH = nCb - nCg;
* else if (nNormalizedG == nV)
* nH = 2.0F + nCr - nCb;
* else if (nNormalizedB == nV)
* nH = 4.0F + nCg - nCr;
* nH = nH * 0.166667F;
* if (nH < 0.0F)
* nH = nH + 1.0F;
* H = (
Npp8u)(nH * 255.0F);
* S = (
Npp8u)(nS * 255.0F);
* V = (
Npp8u)(nV * 255.0F);
*