Leptonica
1.54
|
#define DEBUG_HISTO 0 |
#define SLOW_CUBE_ROOT 0 |
l_int32 convertHSVToRGB | ( | l_int32 | hval, |
l_int32 | sval, | ||
l_int32 | vval, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
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.
l_int32 convertLABToRGB | ( | l_float32 | flval, |
l_float32 | faval, | ||
l_float32 | fbval, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
Input: flval, faval, fbval &rval, &gval, &bval (<return> rgb values) Return: 0 if OK, 1 on error
Notes: (1) For values of lab that are out of gamut for rgb, the rgb components are set to the closest valid color.
l_int32 convertLABToXYZ | ( | l_float32 | lval, |
l_float32 | aval, | ||
l_float32 | bval, | ||
l_float32 * | pxval, | ||
l_float32 * | pyval, | ||
l_float32 * | pzval | ||
) |
Input: lval, aval, bval &xval, &yval, &zval (<return> xyz values) Return: 0 if OK, 1 on error
l_int32 convertRGBToHSV | ( | l_int32 | rval, |
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | phval, | ||
l_int32 * | psval, | ||
l_int32 * | pvval | ||
) |
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
l_int32 convertRGBToLAB | ( | l_int32 | rval, |
l_int32 | gval, | ||
l_int32 | bval, | ||
l_float32 * | pflval, | ||
l_float32 * | pfaval, | ||
l_float32 * | pfbval | ||
) |
Input: rval, gval, bval (rgb input) &flval, &faval, &fbval (<return> lab values) Return: 0 if OK, 1 on error
Notes: (1) These conversions are for illuminant D65 acting on linear sRGB values.
l_int32 convertRGBToXYZ | ( | l_int32 | rval, |
l_int32 | gval, | ||
l_int32 | bval, | ||
l_float32 * | pfxval, | ||
l_float32 * | pfyval, | ||
l_float32 * | pfzval | ||
) |
Input: rval, gval, bval (rgb input) &fxval, &fyval, &fzval (<return> xyz values) Return: 0 if OK, 1 on error
Notes: (1) These conversions are for illuminant D65 acting on linear sRGB values.
l_int32 convertRGBToYUV | ( | l_int32 | rval, |
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pyval, | ||
l_int32 * | puval, | ||
l_int32 * | pvval | ||
) |
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]
l_int32 convertXYZToLAB | ( | l_float32 | xval, |
l_float32 | yval, | ||
l_float32 | zval, | ||
l_float32 * | plval, | ||
l_float32 * | paval, | ||
l_float32 * | pbval | ||
) |
Input: xval, yval, zval (xyz input) &lval, &aval, &bval (<return> lab values) Return: 0 if OK, 1 on error
l_int32 convertXYZToRGB | ( | l_float32 | fxval, |
l_float32 | fyval, | ||
l_float32 | fzval, | ||
l_int32 | blackout, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
Input: fxval, fyval, fzval blackout (0 to output nearest color if out of gamut; 1 to output black) &rval, &gval, &bval (<return> rgb values) Return: 0 if OK, 1 on error
Notes: (1) For values of xyz that are out of gamut for rgb, at least one of the r, g or b components will be either less than 0 or greater than 255. For that situation: * if blackout == 0, the individual component(s) that are out of gamut will be set to 0 or 255, respectively. * if blackout == 1, the output color will be set to black
l_int32 convertYUVToRGB | ( | l_int32 | yval, |
l_int32 | uval, | ||
l_int32 | vval, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
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.
PIX* displayHSVColorRange | ( | l_int32 | hval, |
l_int32 | sval, | ||
l_int32 | vval, | ||
l_int32 | huehw, | ||
l_int32 | sathw, | ||
l_int32 | nsamp, | ||
l_int32 | factor | ||
) |
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.
PIX* fpixaConvertLABToRGB | ( | FPIXA * | fpixa | ) |
Input: fpixa (three fpix: l,a,b) Return: pixd (rgb)
Notes: (1) The lab image is stored in three fpix.
FPIXA* fpixaConvertLABToXYZ | ( | FPIXA * | fpixas | ) |
Input: fpixa (lab) Return: fpixa (xyz)
Notes: (1) The input [l,a,b] and output [x,y,z] values are stored as float values, each set in three fpix.
FPIXA* fpixaConvertXYZToLAB | ( | FPIXA * | fpixas | ) |
Input: fpixa (xyz) Return: fpixa (lab)
Notes: (1) The input [x,y,z] and output [l,a,b] values are stored as float values, each set in three fpix. (2) The CIE LAB color space was invented in 1976, as an absolute reference for specifying colors that we can perceive, independently of the rendering device. It was invented to align color display and print images. For information, see: http://www.brucelindbloom.com/ http://en.wikipedia.org/wiki/Lab_color_space
PIX* fpixaConvertXYZToRGB | ( | FPIXA * | fpixa | ) |
Input: fpixa (three fpix: x,y,z) Return: pixd (rgb)
Notes: (1) The xyz image is stored in three fpix. (2) For values of xyz that are out of gamut for rgb, the rgb components are set to the closest valid color.
static l_float32 lab_forward | ( | l_float32 | v | ) | [static] |
static l_float32 lab_reverse | ( | l_float32 | v | ) | [static] |
l_int32 pixcmapConvertHSVToRGB | ( | PIXCMAP * | cmap | ) |
Input: colormap Return: 0 if OK; 1 on error
Notes:
l_int32 pixcmapConvertRGBToHSV | ( | PIXCMAP * | cmap | ) |
Input: colormap Return: 0 if OK; 1 on error
Notes:
l_int32 pixcmapConvertRGBToYUV | ( | PIXCMAP * | cmap | ) |
Input: colormap Return: 0 if OK; 1 on error
Notes:
l_int32 pixcmapConvertYUVToRGB | ( | PIXCMAP * | cmap | ) |
Input: colormap Return: 0 if OK; 1 on error
Notes:
PIX* pixConvertHSVToRGB | ( | PIX * | pixd, |
PIX * | pixs | ||
) |
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.
PIX* pixConvertRGBToHSV | ( | PIX * | pixd, |
PIX * | pixs | ||
) |
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:
PIX* pixConvertRGBToHue | ( | PIX * | pixs | ) |
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()
FPIXA* pixConvertRGBToLAB | ( | PIX * | pixs | ) |
Input: pixs (rgb) Return: fpixa (lab)
Notes: (1) The [l,a,b] values are stored as float values in three fpix that are returned in a fpixa.
PIX* pixConvertRGBToSaturation | ( | PIX * | pixs | ) |
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.
PIX* pixConvertRGBToValue | ( | PIX * | pixs | ) |
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.
FPIXA* pixConvertRGBToXYZ | ( | PIX * | pixs | ) |
Input: pixs (rgb) Return: fpixa (xyz)
Notes: (1) The [x,y,z] values are stored as float values in three fpix that are returned in a fpixa. (2) The XYZ color space was defined in 1931 as a reference model that simulates human color perception. When Y is taken as luminance, the values of X and Z constitute a color plane representing all the hues that can be perceived. This gamut of colors is larger than the gamuts that can be displayed or printed. For example, although all rgb values map to XYZ, the converse is not true. (3) The value of the coefficients depends on the illuminant. We use coefficients for converting sRGB under D65 (the spectrum from a 6500 degree K black body; an approximation to daylight color). See, e.g., http://www.cs.rit.edu/~ncs/color/t_convert.html For more general information on color transforms, see: http://www.brucelindbloom.com/ http://user.engineering.uiowa.edu/~aip/Misc/ColorFAQ.html http://en.wikipedia.org/wiki/CIE_1931_color_space
PIX* pixConvertRGBToYUV | ( | PIX * | pixd, |
PIX * | pixs | ||
) |
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:
PIX* pixConvertYUVToRGB | ( | PIX * | pixd, |
PIX * | pixs | ||
) |
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.
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 | ||
) |
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 (<return> locations of max for each integrated peak area) &natot (<return> 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);
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.
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.
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.
PIX* pixMakeRangeMaskHS | ( | PIX * | pixs, |
l_int32 | huecenter, | ||
l_int32 | huehw, | ||
l_int32 | satcenter, | ||
l_int32 | sathw, | ||
l_int32 | regionflag | ||
) |
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.
PIX* pixMakeRangeMaskHV | ( | PIX * | pixs, |
l_int32 | huecenter, | ||
l_int32 | huehw, | ||
l_int32 | valcenter, | ||
l_int32 | valhw, | ||
l_int32 | regionflag | ||
) |
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.
PIX* pixMakeRangeMaskSV | ( | PIX * | pixs, |
l_int32 | satcenter, | ||
l_int32 | sathw, | ||
l_int32 | valcenter, | ||
l_int32 | valhw, | ||
l_int32 | regionflag | ||
) |
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.