Developer Reference

  • 2020
  • 10/21/2020
  • Public Content
Contents

RGBToHLS

Converts an RGB image to the HLS color model.

Syntax

IppStatus ippiRGBToHLS_<mod>(const Ipp<datatype>*
pSrc
, int
srcStep
, Ipp<datatype>*
pDst
, int
dstStep
, IppiSize
roiSize
);
Supported values for
mod
:
8u_C3R
16u_C3R
16s_C3R
32f_C3R
8u_AC4R
16u_AC4R
16s_AC4R
32f_AC4R
Include Files
ippcc.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
,
ipps.h
,
ippi.h
Libraries:
ippcore.lib
,
ippvm.lib
,
ipps.lib
,
ippi.lib
Parameters
pSrc
Pointer to the source image ROI.
srcStep
Distance in bytes between starts of consecutive lines in the source image.
pDst
Pointer to the destination image ROI.
dstStep
Distance in bytes between starts of consecutive lines in the destination image.
roiSize
Size of the source and destination ROI in pixels.
Description
This function operates with ROI (see Regions of Interest in Intel IPP).
This function converts the
R'B'G'
image
pSrc
to the
HLS
image
pDst
. For function flavors operating on the floating point data, source RGB values must be in the range [0..1].
The conversion algorithm from
RGB
to
HLS
can be represented in pseudocode as follows:
// Lightness: M1 = max(R,G,B); M2 = min(R,G,B); L = (M1+M2)/2 // Saturation: if M1 = M2 then // achromatics case S = 0 H = 0 else // chromatics case if L <= 0.5 then S = (M1-M2) / (M1+M2) else S = (M1-M2) / (2-M1-M2) // Hue: Cr = (M1-R) / (M1-M2) Cg = (M1-G) / (M1-M2) Cb = (M1-B) / (M1-M2) if R = M1 then H = Cb - Cg //change R=M2 to R=M1 if G = M1 then H = 2 + Cr - Cb //change G=M2 to G=M1 if B = M1 then H = 4 + Cg - Cr //change B=M2 to B=M1 H = 60*H if H < 0 then H = H + 360
For floating point function flavors, the computed
H, L, S
values are scaled to the range [0..1]. In case of integer function flavors, these values are scaled to the full range of the destination data type (Table
“Image Data Types and Ranges”
).
Return Values
ippStsNoErr
Indicates no error. Any other value indicates an error.
ippStsNullPtrErr
Indicates an error condition if
pSrc
or
pDst
is
NULL
.
ippStsSizeErr
Indicates an error condition if
roiSize
has a field with a zero or negative value.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.