Leptonica 1.68
C Image Processing Library

colorspace.c File Reference

Colorspace conversions between RGB, HSV, and YUV. More...

#include <string.h>
#include <math.h>
#include "allheaders.h"

Go to the source code of this file.

Defines

#define DEBUG_HISTO   1

Functions

PIXpixConvertRGBToHSV (PIX *pixd, PIX *pixs)
PIXpixConvertHSVToRGB (PIX *pixd, PIX *pixs)
l_int32 convertRGBToHSV (l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *phval, l_int32 *psval, l_int32 *pvval)
l_int32 convertHSVToRGB (l_int32 hval, l_int32 sval, l_int32 vval, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
l_int32 pixcmapConvertRGBToHSV (PIXCMAP *cmap)
l_int32 pixcmapConvertHSVToRGB (PIXCMAP *cmap)
PIXpixConvertRGBToHue (PIX *pixs)
PIXpixConvertRGBToSaturation (PIX *pixs)
PIXpixConvertRGBToValue (PIX *pixs)
PIXpixMakeRangeMaskHS (PIX *pixs, l_int32 huecenter, l_int32 huehw, l_int32 satcenter, l_int32 sathw, l_int32 regionflag)
PIXpixMakeRangeMaskHV (PIX *pixs, l_int32 huecenter, l_int32 huehw, l_int32 valcenter, l_int32 valhw, l_int32 regionflag)
PIXpixMakeRangeMaskSV (PIX *pixs, l_int32 satcenter, l_int32 sathw, l_int32 valcenter, l_int32 valhw, l_int32 regionflag)
PIXpixMakeHistoHS (PIX *pixs, l_int32 factor, NUMA **pnahue, NUMA **pnasat)
PIXpixMakeHistoHV (PIX *pixs, l_int32 factor, NUMA **pnahue, NUMA **pnaval)
PIXpixMakeHistoSV (PIX *pixs, l_int32 factor, NUMA **pnasat, NUMA **pnaval)
l_int32 pixFindHistoPeaksHSV (PIX *pixs, l_int32 type, l_int32 width, l_int32 height, l_int32 npeaks, l_float32 erasefactor, PTA **ppta, NUMA **pnatot, PIXA **ppixa)
PIXdisplayHSVColorRange (l_int32 hval, l_int32 sval, l_int32 vval, l_int32 huehw, l_int32 sathw, l_int32 nsamp, l_int32 factor)
PIXpixConvertRGBToYUV (PIX *pixd, PIX *pixs)
PIXpixConvertYUVToRGB (PIX *pixd, PIX *pixs)
l_int32 convertRGBToYUV (l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pyval, l_int32 *puval, l_int32 *pvval)
l_int32 convertYUVToRGB (l_int32 yval, l_int32 uval, l_int32 vval, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
l_int32 pixcmapConvertRGBToYUV (PIXCMAP *cmap)
l_int32 pixcmapConvertYUVToRGB (PIXCMAP *cmap)

Detailed Description


Define Documentation

#define DEBUG_HISTO   1

Definition at line 54 of file colorspace.c.


Function Documentation

PIX* pixConvertRGBToHSV ( PIX pixd,
PIX pixs 
)

pixConvertRGBToHSV()

Input: pixd (can be NULL; if not NULL, must == pixs) pixs Return: pixd always

Notes: (1) For pixs = pixd, this is in-place; otherwise pixd must be NULL. (2) The definition of our HSV space is given in convertRGBToHSV(). (3) The h, s and v values are stored in the same places as the r, g and b values, respectively. Here, they are explicitly placed in the 3 MS bytes in the pixel. (4) Normalizing to 1 and considering the r,g,b components, a simple way to understand the HSV space is:

  • v = max(r,g,b)
  • s = (max - min) / max
  • h ~ (mid - min) / (max - min) [apart from signs and constants] (5) Normalizing to 1, some properties of the HSV space are:
  • For gray values (r = g = b) along the continuum between black and white: s = 0 (becoming undefined as you approach black) h is undefined everywhere
  • Where one component is saturated and the others are zero: v = 1 s = 1 h = 0 (r = max), 1/3 (g = max), 2/3 (b = max)
  • Where two components are saturated and the other is zero: v = 1 s = 1 h = 1/2 (if r = 0), 5/6 (if g = 0), 1/6 (if b = 0)

Definition at line 94 of file colorspace.c.

References convertRGBToHSV(), ERROR_PTR, extractRGBValues(), NULL, pixcmapConvertRGBToHSV(), pixCopy(), pixGetColormap(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), and PROCNAME.

Referenced by main(), pixMakeRangeMaskHS(), pixMakeRangeMaskHV(), and pixMakeRangeMaskSV().

PIX* pixConvertHSVToRGB ( PIX pixd,
PIX pixs 
)

pixConvertHSVToRGB()

Input: pixd (can be NULL; if not NULL, must == pixs) pixs Return: pixd always

Notes: (1) For pixs = pixd, this is in-place; otherwise pixd must be NULL. (2) The user takes responsibility for making sure that pixs is in our HSV space. The definition of our HSV space is given in convertRGBToHSV(). (3) The h, s and v values are stored in the same places as the r, g and b values, respectively. Here, they are explicitly placed in the 3 MS bytes in the pixel.

Definition at line 156 of file colorspace.c.

References composeRGBPixel(), convertHSVToRGB(), ERROR_PTR, NULL, pixcmapConvertHSVToRGB(), pixCopy(), pixGetColormap(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), and PROCNAME.

Referenced by main().

l_int32 convertRGBToHSV ( l_int32  rval,
l_int32  gval,
l_int32  bval,
l_int32 phval,
l_int32 psval,
l_int32 pvval 
)

convertRGBToHSV()

Input: rval, gval, bval (RGB input) &hval, &sval, &vval (<return> HSV values) Return: 0 if OK, 1 on error

Notes: (1) The range of returned values is: h [0 ... 239] s [0 ... 255] v [0 ... 255] (2) If r = g = b, the pixel is gray (s = 0), and we define h = 0. (3) h wraps around, so that h = 0 and h = 240 are equivalent in hue space. (4) h has the following correspondence to color: h = 0 magenta h = 40 red h = 80 yellow h = 120 green h = 160 cyan h = 200 blue

Definition at line 229 of file colorspace.c.

References ERROR_INT, L_MAX, L_MIN, and PROCNAME.

Referenced by pixcmapConvertRGBToHSV(), pixConvertRGBToHSV(), pixMeasureSaturation(), pixModifyHue(), and pixModifySaturation().

l_int32 convertHSVToRGB ( l_int32  hval,
l_int32  sval,
l_int32  vval,
l_int32 prval,
l_int32 pgval,
l_int32 pbval 
)

convertHSVToRGB()

Input: hval, sval, vval &rval, &gval, &bval (<return> RGB values) Return: 0 if OK, 1 on error

Notes: (1) See convertRGBToHSV() for valid input range of HSV values and their interpretation in color space.

Definition at line 287 of file colorspace.c.

References ERROR_INT, and PROCNAME.

Referenced by displayHSVColorRange(), pixcmapConvertHSVToRGB(), pixConvertHSVToRGB(), pixModifyHue(), and pixModifySaturation().

l_int32 pixcmapConvertRGBToHSV ( PIXCMAP cmap)

pixcmapConvertRGBToHSV()

Input: colormap Return: 0 if OK; 1 on error

Notes:

  • in-place transform
  • See convertRGBToHSV() for def'n of HSV space.
  • replaces: r --> h, g --> s, b --> v

Definition at line 372 of file colorspace.c.

References convertRGBToHSV(), ERROR_INT, pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.

Referenced by main(), and pixConvertRGBToHSV().

l_int32 pixcmapConvertHSVToRGB ( PIXCMAP cmap)

pixcmapConvertHSVToRGB()

Input: colormap Return: 0 if OK; 1 on error

Notes:

  • in-place transform
  • See convertRGBToHSV() for def'n of HSV space.
  • replaces: h --> r, s --> g, v --> b

Definition at line 403 of file colorspace.c.

References convertHSVToRGB(), ERROR_INT, pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.

Referenced by main(), and pixConvertHSVToRGB().

PIX* pixConvertRGBToHue ( PIX pixs)

pixConvertRGBToHue()

Input: pixs (32 bpp RGB or 8 bpp with colormap) Return: pixd (8 bpp hue of HSV), or null on error

Notes: (1) The conversion to HSV hue is in-lined here. (2) If there is a colormap, it is removed. (3) If you just want the hue component, this does it at about 10 Mpixels/sec/GHz, which is about 2x faster than using pixConvertRGBToHSV()

Definition at line 436 of file colorspace.c.

References ERROR_PTR, extractRGBValues(), L_MAX, L_MIN, NULL, pixCopyResolution(), pixCreate(), pixDestroy(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetWpl(), pixRemoveColormap(), PROCNAME, REMOVE_CMAP_TO_FULL_COLOR, and SET_DATA_BYTE.

PIX* pixConvertRGBToSaturation ( PIX pixs)

pixConvertRGBToSaturation()

Input: pixs (32 bpp RGB or 8 bpp with colormap) Return: pixd (8 bpp sat of HSV), or null on error

Notes: (1) The conversion to HSV sat is in-lined here. (2) If there is a colormap, it is removed. (3) If you just want the saturation component, this does it at about 12 Mpixels/sec/GHz.

Definition at line 510 of file colorspace.c.

References ERROR_PTR, extractRGBValues(), L_MAX, L_MIN, NULL, pixCopyResolution(), pixCreate(), pixDestroy(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetWpl(), pixRemoveColormap(), PROCNAME, REMOVE_CMAP_TO_FULL_COLOR, and SET_DATA_BYTE.

PIX* pixConvertRGBToValue ( PIX pixs)

pixConvertRGBToValue()

Input: pixs (32 bpp RGB or 8 bpp with colormap) Return: pixd (8 bpp max component intensity of HSV), or null on error

Notes: (1) The conversion to HSV sat is in-lined here. (2) If there is a colormap, it is removed. (3) If you just want the value component, this does it at about 35 Mpixels/sec/GHz.

Definition at line 573 of file colorspace.c.

References ERROR_PTR, extractRGBValues(), L_MAX, NULL, pixCopyResolution(), pixCreate(), pixDestroy(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetWpl(), pixRemoveColormap(), PROCNAME, REMOVE_CMAP_TO_FULL_COLOR, and SET_DATA_BYTE.

PIX* pixMakeRangeMaskHS ( PIX pixs,
l_int32  huecenter,
l_int32  huehw,
l_int32  satcenter,
l_int32  sathw,
l_int32  regionflag 
)

pixMakeRangeMaskHS()

Input: pixs (32 bpp rgb) huecenter (center value of hue range) huehw (half-width of hue range) satcenter (center value of saturation range) sathw (half-width of saturation range) regionflag (L_INCLUDE_REGION, L_EXCLUDE_REGION) Return: pixd (1 bpp mask over selected pixels), or null on error

Notes: (1) The pixels are selected based on the specified ranges of hue and saturation. For selection or exclusion, the pixel HS component values must be within both ranges. Care must be taken in finding the hue range because of wrap-around. (2) Use == L_INCLUDE_REGION to take only those pixels within the rectangular region specified in HS space. Use == L_EXCLUDE_REGION to take all pixels except those within the rectangular region specified in HS space.

Definition at line 640 of file colorspace.c.

References CALLOC, CLEAR_DATA_BIT, ERROR_PTR, FREE, L_EXCLUDE_REGION, L_GREEN_SHIFT, L_INCLUDE_REGION, L_MAX, L_MIN, L_RED_SHIFT, NULL, pixClearAll(), pixConvertRGBToHSV(), pixCreateNoInit(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), pixSetAll(), PROCNAME, and SET_DATA_BIT.

Referenced by main().

PIX* pixMakeRangeMaskHV ( PIX pixs,
l_int32  huecenter,
l_int32  huehw,
l_int32  valcenter,
l_int32  valhw,
l_int32  regionflag 
)

pixMakeRangeMaskHV()

Input: pixs (32 bpp rgb) huecenter (center value of hue range) huehw (half-width of hue range) valcenter (center value of max intensity range) valhw (half-width of max intensity range) regionflag (L_INCLUDE_REGION, L_EXCLUDE_REGION) Return: pixd (1 bpp mask over selected pixels), or null on error

Notes: (1) The pixels are selected based on the specified ranges of hue and max intensity values. For selection or exclusion, the pixel HV component values must be within both ranges. Care must be taken in finding the hue range because of wrap-around. (2) Use == L_INCLUDE_REGION to take only those pixels within the rectangular region specified in HV space. Use == L_EXCLUDE_REGION to take all pixels except those within the rectangular region specified in HV space.

Definition at line 738 of file colorspace.c.

References CALLOC, CLEAR_DATA_BIT, ERROR_PTR, FREE, L_BLUE_SHIFT, L_EXCLUDE_REGION, L_INCLUDE_REGION, L_MAX, L_MIN, L_RED_SHIFT, NULL, pixClearAll(), pixConvertRGBToHSV(), pixCreateNoInit(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), pixSetAll(), PROCNAME, and SET_DATA_BIT.

PIX* pixMakeRangeMaskSV ( PIX pixs,
l_int32  satcenter,
l_int32  sathw,
l_int32  valcenter,
l_int32  valhw,
l_int32  regionflag 
)

pixMakeRangeMaskSV()

Input: pixs (32 bpp rgb) satcenter (center value of saturation range) sathw (half-width of saturation range) valcenter (center value of max intensity range) valhw (half-width of max intensity range) regionflag (L_INCLUDE_REGION, L_EXCLUDE_REGION) Return: pixd (1 bpp mask over selected pixels), or null on error

Notes: (1) The pixels are selected based on the specified ranges of saturation and max intensity (val). For selection or exclusion, the pixel SV component values must be within both ranges. (2) Use == L_INCLUDE_REGION to take only those pixels within the rectangular region specified in SV space. Use == L_EXCLUDE_REGION to take all pixels except those within the rectangular region specified in SV space.

Definition at line 835 of file colorspace.c.

References CALLOC, CLEAR_DATA_BIT, ERROR_PTR, FREE, L_BLUE_SHIFT, L_EXCLUDE_REGION, L_GREEN_SHIFT, L_INCLUDE_REGION, L_MAX, L_MIN, NULL, pixClearAll(), pixConvertRGBToHSV(), pixCreateNoInit(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), pixSetAll(), PROCNAME, and SET_DATA_BIT.

PIX* pixMakeHistoHS ( PIX pixs,
l_int32  factor,
NUMA **  pnahue,
NUMA **  pnasat 
)

pixMakeHistoHS()

Input: pixs (HSV colorspace) factor (subsampling factor; integer) &nahue (<optional return>=""> hue histogram) &nasat (<optional return>=""> saturation histogram) Return: pixd (32 bpp histogram in hue and saturation), or null on error

Notes: (1) pixs is a 32 bpp image in HSV colorspace; hue is in the "red" byte, saturation is in the "green" byte. (2) In pixd, hue is displayed vertically; saturation horizontally. The dimensions of pixd are w = 256, h = 240, and the depth is 32 bpp. The value at each point is simply the number of pixels found at that value of hue and saturation.

Definition at line 922 of file colorspace.c.

References ERROR_PTR, FREE, GET_DATA_FOUR_BYTES, L_GREEN_SHIFT, L_RED_SHIFT, NULL, numaCreate(), numaSetCount(), numaShiftValue(), pixClone(), pixCreate(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetLinePtrs(), pixGetWpl(), pixScaleBySampling(), PROCNAME, and SET_DATA_FOUR_BYTES.

Referenced by main().

PIX* pixMakeHistoHV ( PIX pixs,
l_int32  factor,
NUMA **  pnahue,
NUMA **  pnaval 
)

pixMakeHistoHV()

Input: pixs (HSV colorspace) factor (subsampling factor; integer) &nahue (<optional return>=""> hue histogram) &naval (<optional return>=""> max intensity (value) histogram) Return: pixd (32 bpp histogram in hue and value), or null on error

Notes: (1) pixs is a 32 bpp image in HSV colorspace; hue is in the "red" byte, max intensity ("value") is in the "blue" byte. (2) In pixd, hue is displayed vertically; intensity horizontally. The dimensions of pixd are w = 256, h = 240, and the depth is 32 bpp. The value at each point is simply the number of pixels found at that value of hue and intensity.

Definition at line 1011 of file colorspace.c.

References ERROR_PTR, FREE, GET_DATA_FOUR_BYTES, L_BLUE_SHIFT, L_RED_SHIFT, NULL, numaCreate(), numaSetCount(), numaShiftValue(), pixClone(), pixCreate(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetLinePtrs(), pixGetWpl(), pixScaleBySampling(), PROCNAME, and SET_DATA_FOUR_BYTES.

PIX* pixMakeHistoSV ( PIX pixs,
l_int32  factor,
NUMA **  pnasat,
NUMA **  pnaval 
)

pixMakeHistoSV()

Input: pixs (HSV colorspace) factor (subsampling factor; integer) &nasat (<optional return>=""> sat histogram) &naval (<optional return>=""> max intensity (value) histogram) Return: pixd (32 bpp histogram in sat and value), or null on error

Notes: (1) pixs is a 32 bpp image in HSV colorspace; sat is in the "green" byte, max intensity ("value") is in the "blue" byte. (2) In pixd, sat is displayed vertically; intensity horizontally. The dimensions of pixd are w = 256, h = 256, and the depth is 32 bpp. The value at each point is simply the number of pixels found at that value of saturation and intensity.

Definition at line 1092 of file colorspace.c.

References ERROR_PTR, FREE, GET_DATA_FOUR_BYTES, L_BLUE_SHIFT, L_GREEN_SHIFT, NULL, numaCreate(), numaSetCount(), numaShiftValue(), pixClone(), pixCreate(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetLinePtrs(), pixGetWpl(), pixScaleBySampling(), PROCNAME, and SET_DATA_FOUR_BYTES.

l_int32 pixFindHistoPeaksHSV ( PIX pixs,
l_int32  type,
l_int32  width,
l_int32  height,
l_int32  npeaks,
l_float32  erasefactor,
PTA **  ppta,
NUMA **  pnatot,
PIXA **  ppixa 
)

pixFindHistoPeaksHSV()

Input: pixs (32 bpp; HS, HV or SV histogram; not changed) type (L_HS_HISTO, L_HV_HISTO or L_SV_HISTO) width (half width of sliding window) height (half height of sliding window) npeaks (number of peaks to look for) erasefactor (ratio of erase window size to sliding window size) &pta (locations of maximum for each integrated peak area) &natot (integrated peak areas) &pixa (<optional return>=""> pixa for debugging; NULL to skip) Return: 0 if OK, 1 on error

Notes: (1) pixs is a 32 bpp histogram in a pair of HSV colorspace. It should be thought of as a single sample with 32 bps (bits/sample). (2) After each peak is found, the peak is erased with a window that is centered on the peak and scaled from the sliding window by . Typically, is chosen to be > 1.0. (3) Data for a maximum of is returned in and . (4) For debugging, after the pixa is returned, display with: pixd = pixaDisplayTiledInRows(pixa, 32, 1000, 1.0, 0, 30, 2);

Definition at line 1181 of file colorspace.c.

References boxCreate(), boxDestroy(), ERROR_INT, L_HS_HISTO, L_HV_HISTO, L_INSERT, L_LINEAR_SCALE, L_LOG_SCALE, L_NEG_SLOPE_LINE, L_SV_HISTO, NULL, numaAddNumber(), numaCreate(), pixaAddPix(), pixaCreate(), pixAddMirroredBorder(), pixAddMixedBorder(), pixClearInRect(), pixConvertGrayToFalseColor(), pixConvertTo32(), pixDestroy(), pixGetDepth(), pixGetMaxValueInRect(), pixMaxDynamicRange(), pixRenderHashBoxArb(), pixWindowedMean(), PROCNAME, ptaAddPt(), and ptaCreate().

Referenced by main().

PIX* displayHSVColorRange ( l_int32  hval,
l_int32  sval,
l_int32  vval,
l_int32  huehw,
l_int32  sathw,
l_int32  nsamp,
l_int32  factor 
)

displayHSVColorRange()

Input: hval (hue center value; in range [0 ... 240] sval (saturation center value; in range [0 ... 255] vval (max intensity value; in range [0 ... 255] huehw (half-width of hue range; > 0) sathw (half-width of saturation range; > 0) nsamp (number of samplings in each half-width in hue and sat) factor (linear size of each color square, in pixels; > 3) Return: pixd (32 bpp set of color squares over input range), or null on error

Notes: (1) The total number of color samplings in each of the hue and saturation directions is 2 * nsamp + 1.

Definition at line 1302 of file colorspace.c.

References convertHSVToRGB(), ERROR_PTR, NULL, pixCreate(), pixDestroy(), pixExpandReplicate(), pixSetRGBPixel(), and PROCNAME.

PIX* pixConvertRGBToYUV ( PIX pixd,
PIX pixs 
)

pixConvertRGBToYUV()

Input: pixd (can be NULL; if not NULL, must == pixs) pixs Return: pixd always

Notes: (1) For pixs = pixd, this is in-place; otherwise pixd must be NULL. (2) The Y, U and V values are stored in the same places as the r, g and b values, respectively. Here, they are explicitly placed in the 3 MS bytes in the pixel. (3) Normalizing to 1 and considering the r,g,b components, a simple way to understand the YUV space is:

  • Y = weighted sum of (r,g,b)
  • U = weighted difference between Y and B
  • V = weighted difference between Y and R (4) Following video conventions, Y, U and V are in the range: Y: [16, 235] U: [16, 240] V: [16, 240] (5) For the coefficients in the transform matrices, see eq. 4 in "Frequently Asked Questions about Color" by Charles Poynton, http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

Definition at line 1376 of file colorspace.c.

References convertRGBToYUV(), ERROR_PTR, extractRGBValues(), NULL, pixcmapConvertRGBToYUV(), pixCopy(), pixGetColormap(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), and PROCNAME.

Referenced by AddTransformsRGB(), and AddTransformsYUV().

PIX* pixConvertYUVToRGB ( PIX pixd,
PIX pixs 
)

pixConvertYUVToRGB()

Input: pixd (can be NULL; if not NULL, must == pixs) pixs Return: pixd always

Notes: (1) For pixs = pixd, this is in-place; otherwise pixd must be NULL. (2) The user takes responsibility for making sure that pixs is in YUV space. (3) The Y, U and V values are stored in the same places as the r, g and b values, respectively. Here, they are explicitly placed in the 3 MS bytes in the pixel.

Definition at line 1437 of file colorspace.c.

References composeRGBPixel(), convertYUVToRGB(), ERROR_PTR, NULL, pixcmapConvertYUVToRGB(), pixCopy(), pixGetColormap(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), and PROCNAME.

Referenced by AddTransformsRGB(), and AddTransformsYUV().

l_int32 convertRGBToYUV ( l_int32  rval,
l_int32  gval,
l_int32  bval,
l_int32 pyval,
l_int32 puval,
l_int32 pvval 
)

convertRGBToYUV()

Input: rval, gval, bval (RGB input) &yval, &uval, &vval (<return> YUV values) Return: 0 if OK, 1 on error

Notes: (1) The range of returned values is: Y [16 ... 235] U [16 ... 240] V [16 ... 240]

Definition at line 1500 of file colorspace.c.

References ERROR_INT, and PROCNAME.

Referenced by main(), pixcmapConvertRGBToYUV(), and pixConvertRGBToYUV().

l_int32 convertYUVToRGB ( l_int32  yval,
l_int32  uval,
l_int32  vval,
l_int32 prval,
l_int32 pgval,
l_int32 pbval 
)

convertYUVToRGB()

Input: yval, uval, vval &rval, &gval, &bval (<return> RGB values) Return: 0 if OK, 1 on error

Notes: (1) The range of valid input values is: Y [16 ... 235] U [16 ... 240] V [16 ... 240] (2) Conversion of RGB --> YUV --> RGB leaves the image unchanged. (3) The YUV gamut is larger than the RBG gamut; many YUV values will result in an invalid RGB value. We clip individual r,g,b components to the range [0, 255], and do not test input.

Definition at line 1543 of file colorspace.c.

References ERROR_INT, L_MAX, L_MIN, and PROCNAME.

Referenced by main(), pixcmapConvertYUVToRGB(), and pixConvertYUVToRGB().

l_int32 pixcmapConvertRGBToYUV ( PIXCMAP cmap)

pixcmapConvertRGBToYUV()

Input: colormap Return: 0 if OK; 1 on error

Notes:

  • in-place transform
  • See convertRGBToYUV() for def'n of YUV space.
  • replaces: r --> y, g --> u, b --> v

Definition at line 1586 of file colorspace.c.

References convertRGBToYUV(), ERROR_INT, pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.

Referenced by pixConvertRGBToYUV().

l_int32 pixcmapConvertYUVToRGB ( PIXCMAP cmap)

pixcmapConvertYUVToRGB()

Input: colormap Return: 0 if OK; 1 on error

Notes:

  • in-place transform
  • See convertRGBToYUV() for def'n of YUV space.
  • replaces: y --> r, u --> g, v --> b

Definition at line 1617 of file colorspace.c.

References convertYUVToRGB(), ERROR_INT, pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.

Referenced by pixConvertYUVToRGB().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines