RGB to HLS color conversion.
More...
|
NppStatus |
nppiRGBToHLS_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 HLS color conversion. More...
|
|
NppStatus |
nppiRGBToHLS_8u_C3R (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI) |
|
NppStatus |
nppiRGBToHLS_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 HLS with alpha color conversion. More...
|
|
NppStatus |
nppiRGBToHLS_8u_AC4R (const Npp8u *pSrc, int nSrcStep, Npp8u *pDst, int nDstStep, NppiSize oSizeROI) |
|
RGB to HLS color conversion.
This is how NPP converts gamma corrected RGB or BGR to HLS. This code uses the fmaxf() and fminf() 32 bit floating point math functions.
*
*
Npp32f nMax = fmaxf(nNormalizedR, nNormalizedG);
* nMax = fmaxf(nMax, nNormalizedB);
*
Npp32f nMin = fminf(nNormalizedR, nNormalizedG);
* nMin = fminf(nMin, nNormalizedB);
*
Npp32f nL = (nMax + nMin) * 0.5F;
*
Npp32f nDivisor = nMax - nMin;
*
* if (nDivisor == 0.0F)
* {
* nS = 0.0F;
* nH = 0.0F;
* }
* else
* {
* if (nL > 0.5F)
* nS = nDivisor / (1.0F - (nMax + nMin - 1.0F));
* else
* nS = nDivisor / (nMax + nMin);
* }
*
*
Npp32f nCr = (nMax - nNormalizedR) / nDivisor;
*
Npp32f nCg = (nMax - nNormalizedG) / nDivisor;
*
Npp32f nCb = (nMax - nNormalizedB) / nDivisor;
* if (nNormalizedR == nMax)
* nH = nCb - nCg;
* else if (nNormalizedG == nMax)
* nH = 2.0F + nCr - nCb;
* else if (nNormalizedB == nMax)
* nH = 4.0F + nCg - nCr;
* nH = nH * 0.166667F;
* if (nH < 0.0F)
* nH = nH + 1.0F;
* H = (
Npp8u)(nH * 255.0F);
* L = (
Npp8u)(nL * 255.0F);
* S = (
Npp8u)(nS * 255.0F);
*