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

RGB to HSV color conversion. More...

Functions

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)
 

Detailed Description

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 nNormalizedR = (Npp32f)R * 0.003921569F; // / 255.0F
* Npp32f nNormalizedG = (Npp32f)G * 0.003921569F;
* Npp32f nNormalizedB = (Npp32f)B * 0.003921569F;
* Npp32f nS;
* Npp32f nH;
* // Value
* Npp32f nV = fmaxf(nNormalizedR, nNormalizedG);
* nV = fmaxf(nV, nNormalizedB);
* // Saturation
* Npp32f nTemp = fminf(nNormalizedR, nNormalizedG);
* nTemp = fminf(nTemp, nNormalizedB);
* Npp32f nDivisor = nV - nTemp;
* if (nV == 0.0F) // achromatics case
* {
* nS = 0.0F;
* nH = 0.0F;
* }
* else // chromatics case
* nS = nDivisor / nV;
* // Hue:
* 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; // / 6.0F
* if (nH < 0.0F)
* nH = nH + 1.0F;
* H = (Npp8u)(nH * 255.0F);
* S = (Npp8u)(nS * 255.0F);
* V = (Npp8u)(nV * 255.0F);
*

Function Documentation

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

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 nppiRGBToHSV_8u_C3R ( const Npp8u pSrc,
int  nSrcStep,
Npp8u pDst,
int  nDstStep,
NppiSize  oSizeROI 
)
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.

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-2022 NVIDIA CORPORATION AND AFFILIATES