NVIDIA 2D Image And Signal Performance Primitives (NPP)  Version 11.2.1.*
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions

RGB to HLS color conversion. More...

Functions

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)
 

Detailed Description

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 nNormalizedR = (Npp32f)R * 0.003921569F; // / 255.0F
* Npp32f nNormalizedG = (Npp32f)G * 0.003921569F;
* Npp32f nNormalizedB = (Npp32f)B * 0.003921569F;
* Npp32f nS;
* Npp32f nH;
* // Lightness
* 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;
* // Saturation
* if (nDivisor == 0.0F) // achromatics case
* {
* nS = 0.0F;
* nH = 0.0F;
* }
* else // chromatics case
* {
* if (nL > 0.5F)
* nS = nDivisor / (1.0F - (nMax + nMin - 1.0F));
* else
* nS = nDivisor / (nMax + nMin);
* }
* // Hue
* 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; // / 6.0F
* if (nH < 0.0F)
* nH = nH + 1.0F;
* H = (Npp8u)(nH * 255.0F);
* L = (Npp8u)(nL * 255.0F);
* S = (Npp8u)(nS * 255.0F);
*

Function Documentation

NppStatus nppiRGBToHLS_8u_AC4R ( 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.

Parameters
pSrcSource-Image Pointer.
nSrcStepSource-Image Line Step.
pDstDestination-Image Pointer.
nDstStepDestination-Image Line Step.
oSizeROIRegion-of-Interest (ROI).
nppStreamCtxApplication Managed Stream Context.
Returns
Image Data Related Error Codes, ROI Related Error Codes
NppStatus nppiRGBToHLS_8u_C3R ( const Npp8u pSrc,
int  nSrcStep,
Npp8u pDst,
int  nDstStep,
NppiSize  oSizeROI 
)
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.

Parameters
pSrcSource-Image Pointer.
nSrcStepSource-Image Line Step.
pDstDestination-Image Pointer.
nDstStepDestination-Image Line Step.
oSizeROIRegion-of-Interest (ROI).
nppStreamCtxApplication Managed Stream Context.
Returns
Image Data Related Error Codes, ROI Related Error Codes

Copyright © 2009-2020 NVIDIA Corporation