![]() |
Leptonica
1.77.0
Image processing and image analysis suite
|
#include <string.h>#include "allheaders.h"Go to the source code of this file.
Functions | |
| PIXCMAP * | pixcmapCreate (l_int32 depth) |
| PIXCMAP * | pixcmapCreateRandom (l_int32 depth, l_int32 hasblack, l_int32 haswhite) |
| PIXCMAP * | pixcmapCreateLinear (l_int32 d, l_int32 nlevels) |
| PIXCMAP * | pixcmapCopy (PIXCMAP *cmaps) |
| void | pixcmapDestroy (PIXCMAP **pcmap) |
| l_ok | pixcmapIsValid (PIXCMAP *cmap, l_int32 *pvalid) |
| l_ok | pixcmapAddColor (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval) |
| l_ok | pixcmapAddRGBA (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 aval) |
| l_ok | pixcmapAddNewColor (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex) |
| l_ok | pixcmapAddNearestColor (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex) |
| l_ok | pixcmapUsableColor (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pusable) |
| l_ok | pixcmapAddBlackOrWhite (PIXCMAP *cmap, l_int32 color, l_int32 *pindex) |
| l_ok | pixcmapSetBlackAndWhite (PIXCMAP *cmap, l_int32 setblack, l_int32 setwhite) |
| l_int32 | pixcmapGetCount (PIXCMAP *cmap) |
| l_int32 | pixcmapGetFreeCount (PIXCMAP *cmap) |
| l_int32 | pixcmapGetDepth (PIXCMAP *cmap) |
| l_ok | pixcmapGetMinDepth (PIXCMAP *cmap, l_int32 *pmindepth) |
| l_ok | pixcmapClear (PIXCMAP *cmap) |
| l_ok | pixcmapGetColor (PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval) |
| l_ok | pixcmapGetColor32 (PIXCMAP *cmap, l_int32 index, l_uint32 *pval32) |
| l_ok | pixcmapGetRGBA (PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *paval) |
| l_ok | pixcmapGetRGBA32 (PIXCMAP *cmap, l_int32 index, l_uint32 *pval32) |
| l_ok | pixcmapResetColor (PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval) |
| l_ok | pixcmapSetAlpha (PIXCMAP *cmap, l_int32 index, l_int32 aval) |
| l_int32 | pixcmapGetIndex (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex) |
| l_ok | pixcmapHasColor (PIXCMAP *cmap, l_int32 *pcolor) |
| l_ok | pixcmapIsOpaque (PIXCMAP *cmap, l_int32 *popaque) |
| l_ok | pixcmapIsBlackAndWhite (PIXCMAP *cmap, l_int32 *pblackwhite) |
| l_ok | pixcmapCountGrayColors (PIXCMAP *cmap, l_int32 *pngray) |
| l_ok | pixcmapGetRankIntensity (PIXCMAP *cmap, l_float32 rankval, l_int32 *pindex) |
| l_ok | pixcmapGetNearestIndex (PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex) |
| l_ok | pixcmapGetNearestGrayIndex (PIXCMAP *cmap, l_int32 val, l_int32 *pindex) |
| l_ok | pixcmapGetDistanceToColor (PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pdist) |
| l_ok | pixcmapGetRangeValues (PIXCMAP *cmap, l_int32 select, l_int32 *pminval, l_int32 *pmaxval, l_int32 *pminindex, l_int32 *pmaxindex) |
| PIXCMAP * | pixcmapGrayToColor (l_uint32 color) |
| PIXCMAP * | pixcmapColorToGray (PIXCMAP *cmaps, l_float32 rwt, l_float32 gwt, l_float32 bwt) |
| PIXCMAP * | pixcmapConvertTo4 (PIXCMAP *cmaps) |
| PIXCMAP * | pixcmapConvertTo8 (PIXCMAP *cmaps) |
| PIXCMAP * | pixcmapRead (const char *filename) |
| PIXCMAP * | pixcmapReadStream (FILE *fp) |
| PIXCMAP * | pixcmapReadMem (const l_uint8 *data, size_t size) |
| l_ok | pixcmapWrite (const char *filename, PIXCMAP *cmap) |
| l_ok | pixcmapWriteStream (FILE *fp, PIXCMAP *cmap) |
| l_ok | pixcmapWriteMem (l_uint8 **pdata, size_t *psize, PIXCMAP *cmap) |
| l_ok | pixcmapToArrays (PIXCMAP *cmap, l_int32 **prmap, l_int32 **pgmap, l_int32 **pbmap, l_int32 **pamap) |
| l_ok | pixcmapToRGBTable (PIXCMAP *cmap, l_uint32 **ptab, l_int32 *pncolors) |
| l_ok | pixcmapSerializeToMemory (PIXCMAP *cmap, l_int32 cpc, l_int32 *pncolors, l_uint8 **pdata) |
| PIXCMAP * | pixcmapDeserializeFromMemory (l_uint8 *data, l_int32 cpc, l_int32 ncolors) |
| char * | pixcmapConvertToHex (l_uint8 *data, l_int32 ncolors) |
| l_ok | pixcmapGammaTRC (PIXCMAP *cmap, l_float32 gamma, l_int32 minval, l_int32 maxval) |
| l_ok | pixcmapContrastTRC (PIXCMAP *cmap, l_float32 factor) |
| l_ok | pixcmapShiftIntensity (PIXCMAP *cmap, l_float32 fraction) |
| l_ok | pixcmapShiftByComponent (PIXCMAP *cmap, l_uint32 srcval, l_uint32 dstval) |
Colormap creation, copy, destruction, addition
PIXCMAP *pixcmapCreate()
PIXCMAP *pixcmapCreateRandom()
PIXCMAP *pixcmapCreateLinear()
PIXCMAP *pixcmapCopy()
void pixcmapDestroy()
l_int32 pixcmapIsValid()
l_int32 pixcmapAddColor()
l_int32 pixcmapAddRGBA()
l_int32 pixcmapAddNewColor()
l_int32 pixcmapAddNearestColor()
l_int32 pixcmapUsableColor()
l_int32 pixcmapAddBlackOrWhite()
l_int32 pixcmapSetBlackAndWhite()
l_int32 pixcmapGetCount()
l_int32 pixcmapGetDepth()
l_int32 pixcmapGetMinDepth()
l_int32 pixcmapGetFreeCount()
l_int32 pixcmapClear()
Colormap random access and test
l_int32 pixcmapGetColor()
l_int32 pixcmapGetColor32()
l_int32 pixcmapGetRGBA()
l_int32 pixcmapGetRGBA32()
l_int32 pixcmapResetColor()
l_int32 pixcmapSetAlpha()
l_int32 pixcmapGetIndex()
l_int32 pixcmapHasColor()
l_int32 pixcmapIsOpaque()
l_int32 pixcmapIsBlackAndWhite()
l_int32 pixcmapCountGrayColors()
l_int32 pixcmapGetRankIntensity()
l_int32 pixcmapGetNearestIndex()
l_int32 pixcmapGetNearestGrayIndex()
l_int32 pixcmapGetDistanceToColor()
l_int32 pixcmapGetRangeValues()
Colormap conversion
PIXCMAP *pixcmapGrayToColor()
PIXCMAP *pixcmapColorToGray()
PIXCMAP *pixcmapConvertTo4()
PIXCMAP *pixcmapConvertTo8()
Colormap I/O
l_int32 pixcmapRead()
l_int32 pixcmapReadStream()
l_int32 pixcmapReadMem()
l_int32 pixcmapWrite()
l_int32 pixcmapWriteStream()
l_int32 pixcmapWriteMem()
Extract colormap arrays and serialization
l_int32 pixcmapToArrays()
l_int32 pixcmapToRGBTable()
l_int32 pixcmapSerializeToMemory()
PIXCMAP *pixcmapDeserializeFromMemory()
char *pixcmapConvertToHex()
Colormap transforms
l_int32 pixcmapGammaTRC()
l_int32 pixcmapContrastTRC()
l_int32 pixcmapShiftIntensity()
l_int32 pixcmapShiftByComponent()
Definition in file colormap.c.
| l_ok pixcmapAddBlackOrWhite | ( | PIXCMAP * | cmap, |
| l_int32 | color, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | color | 0 for black, 1 for white |
| [out] | pindex | [optional] index of color; can be null |
Notes:
(1) This only adds color if not already there.
(2) The alpha component is 255 (opaque)
(3) This sets index to the requested color.
(4) If there is no room in the colormap, returns the index
of the closest color.
Definition at line 566 of file colormap.c.
References pixcmapAddNewColor(), pixcmapGetFreeCount(), and pixcmapGetRankIntensity().
| l_ok pixcmapAddColor | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap entry to be added; each number is in range [0, ... 255] |
Notes:
(1) This always adds the color if there is room.
(2) The alpha component is 255 (opaque)
Definition at line 341 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, PixColormap::n, PixColormap::nalloc, and RGBA_Quad::red.
Referenced by fpixRenderContours(), makeGrayQuantTableArb(), numaFillCmapFromHisto(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), and pixDisplayDiffBinary().
| l_ok pixcmapAddNearestColor | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap entry to be added; each number is in range [0, ... 255] |
| [out] | pindex | index of color |
Notes:
(1) This only adds color if not already there.
(2) The alpha component is 255 (opaque)
(3) If it's not in the colormap and there is no room to add
another color, this returns the index of the nearest color.
Definition at line 472 of file colormap.c.
References PixColormap::n, PixColormap::nalloc, pixcmapAddColor(), pixcmapGetCount(), pixcmapGetIndex(), and pixcmapGetNearestIndex().
| l_ok pixcmapAddNewColor | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap entry to be added; each number is in range [0, ... 255] |
| [out] | pindex | index of color |
Notes:
(1) This only adds color if not already there.
(2) The alpha component is 255 (opaque)
(3) This returns the index of the new (or existing) color.
(4) Returns 2 with a warning if unable to add this color;
the caller should check the return value.
Definition at line 423 of file colormap.c.
References PixColormap::n, PixColormap::nalloc, pixcmapAddColor(), pixcmapGetCount(), and pixcmapGetIndex().
Referenced by addColorizedGrayToCmap(), and pixcmapAddBlackOrWhite().
| l_ok pixcmapAddRGBA | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 | aval | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval,aval | colormap entry to be added; each number is in range [0, ... 255] |
Notes:
(1) This always adds the color if there is room.
Definition at line 379 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, PixColormap::n, PixColormap::nalloc, and RGBA_Quad::red.
Referenced by pixcmapDeserializeFromMemory(), and pixcmapReadStream().
| l_ok pixcmapClear | ( | PIXCMAP * | cmap | ) |
| [in] | cmap |
Notes:
(1) This removes the colors by setting the count to 0.
Definition at line 728 of file colormap.c.
References PixColormap::n.
| [in] | cmaps | |
| [in] | rwt,gwt,bwt | non-negative; these should add to 1.0 |
Notes:
(1) This creates a gray colormap from an arbitrary colormap.
(2) In use, attach the output gray colormap to the pix
(or a copy of it) that provided the input colormap.
Definition at line 1504 of file colormap.c.
References CCBorda::n, pixcmapCopy(), pixcmapGetColor(), pixcmapGetCount(), and pixcmapResetColor().
| l_ok pixcmapContrastTRC | ( | PIXCMAP * | cmap, |
| l_float32 | factor | ||
| ) |
| [in] | cmap | colormap |
| [in] | factor | generally between 0.0 [no enhancement] and 1.0, but can be larger than 1.0 |
Notes:
(1) This is an in-place transform
(2) See pixContrastTRC() and numaContrastTRC() in enhance.c
for description and use of transform
Definition at line 2178 of file colormap.c.
References numaContrastTRC(), numaDestroy(), numaGetIValue(), pixcmapGetColor(), pixcmapGetCount(), and pixcmapResetColor().
| [in] | cmaps | colormap for 2 bpp pix |
Notes:
(1) This converts a 2 bpp colormap to 4 bpp. The colors
are the same; the output colormap entry array has size 16.
Definition at line 1561 of file colormap.c.
References CCBorda::n, pixcmapAddColor(), pixcmapCreate(), pixcmapGetColor(), pixcmapGetCount(), and pixcmapGetDepth().
| [in] | cmaps | colormap for 2 bpp or 4 bpp pix |
Notes:
(1) This converts a 2 bpp or 4 bpp colormap to 8 bpp. The colors
are the same; the output colormap entry array has size 256.
Definition at line 1596 of file colormap.c.
References CCBorda::n, pixcmapAddColor(), pixcmapCopy(), pixcmapCreate(), pixcmapGetColor(), pixcmapGetCount(), and pixcmapGetDepth().
| char* pixcmapConvertToHex | ( | l_uint8 * | data, |
| l_int32 | ncolors | ||
| ) |
| [in] | data | binary serialized data |
| [in] | ncolors | in colormap |
Notes:
(1) The number of bytes in data is 3 * ncolors.
(2) Output is in form:
< r0g0b0 r1g1b1 ... rngnbn >
where r0, g0, b0 ... are each 2 bytes of hex ascii
(3) This is used in pdf files to express the colormap as an
array in ascii (human-readable) format.
Definition at line 2065 of file colormap.c.
| [in] | cmaps |
Definition at line 234 of file colormap.c.
References PixColormap::nalloc, and pixcmapIsValid().
Referenced by pixcmapColorToGray(), and pixcmapConvertTo8().
| l_ok pixcmapCountGrayColors | ( | PIXCMAP * | cmap, |
| l_int32 * | pngray | ||
| ) |
| [in] | cmap | |
| [out] | pngray | number of gray colors |
Notes:
(1) This counts the unique gray colors, including black and white.
Definition at line 1117 of file colormap.c.
References CCBorda::n, pixcmapGetColor(), and pixcmapGetCount().
| PIXCMAP* pixcmapCreate | ( | l_int32 | depth | ) |
| [in] | depth | bpp, of pix |
Definition at line 111 of file colormap.c.
References PixColormap::array, PixColormap::depth, PixColormap::n, and PixColormap::nalloc.
Referenced by fpixRenderContours(), makeGrayQuantTableArb(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapDeserializeFromMemory(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), pixcmapReadStream(), and pixDisplayDiffBinary().
| PIXCMAP* pixcmapCreateLinear | ( | l_int32 | d, |
| l_int32 | nlevels | ||
| ) |
| [in] | d | depth of pix for this colormap; 1, 2, 4 or 8 |
| [in] | nlevels | valid in range [2, 2^d] |
Notes:
(1) Colormap has equally spaced gray color values
from black (0, 0, 0) to white (255, 255, 255).
Definition at line 204 of file colormap.c.
References pixcmapAddColor(), and pixcmapCreate().
| PIXCMAP* pixcmapCreateRandom | ( | l_int32 | depth, |
| l_int32 | hasblack, | ||
| l_int32 | haswhite | ||
| ) |
| [in] | depth | bpp, of pix; 2, 4 or 8 |
| [in] | hasblack | 1 if the first color is black; 0 if no black |
| [in] | haswhite | 1 if the last color is white; 0 if no white |
Notes:
(1) This sets up a colormap with random colors,
where the first color is optionally black, the last color
is optionally white, and the remaining colors are
chosen randomly.
(2) The number of randomly chosen colors is:
2^(depth) - haswhite - hasblack
(3) Because rand() is seeded, it might disrupt otherwise
deterministic results if also used elsewhere in a program.
(4) rand() is not threadsafe, and will generate garbage if run
on multiple threads at once – though garbage is generally
what you want from a random number generator!
(5) Modern rand()s have equal randomness in low and high order
bits, but older ones don't. Here, we're just using rand()
to choose colors for output.
Definition at line 158 of file colormap.c.
References pixcmapAddColor(), and pixcmapCreate().
Referenced by pixaDisplayRandomCmap(), pixBlendBoxaRandom(), and pixRenderRandomCmapPtaa().
| PIXCMAP* pixcmapDeserializeFromMemory | ( | l_uint8 * | data, |
| l_int32 | cpc, | ||
| l_int32 | ncolors | ||
| ) |
pixcmapDeserializeFromMemory()
| [in] | data | binary string, 3 or 4 bytes per color |
| [in] | cpc | components/color: 3 for rgb, 4 for rgba |
| [in] | ncolors |
Definition at line 2004 of file colormap.c.
References pixcmapAddRGBA(), and pixcmapCreate().
| void pixcmapDestroy | ( | PIXCMAP ** | pcmap | ) |
| [in,out] | pcmap | set to null |
Definition at line 265 of file colormap.c.
References PixColormap::array.
Referenced by pixBlendBoxaRandom(), pixcmapReadStream(), pixDestroyColormap(), and pixThresholdGrayArb().
| l_ok pixcmapGammaTRC | ( | PIXCMAP * | cmap, |
| l_float32 | gamma, | ||
| l_int32 | minval, | ||
| l_int32 | maxval | ||
| ) |
| [in] | cmap | colormap |
| [in] | gamma | gamma correction; must be > 0.0 |
| [in] | minval | input value that gives 0 for output; can be < 0 |
| [in] | maxval | input value that gives 255 for output; can be > 255 |
Notes:
(1) This is an in-place transform
(2) See pixGammaTRC() and numaGammaTRC() in enhance.c
for description and use of transform
Definition at line 2123 of file colormap.c.
References numaDestroy(), numaGammaTRC(), numaGetIValue(), pixcmapGetColor(), pixcmapGetCount(), and pixcmapResetColor().
| l_ok pixcmapGetColor | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_int32 * | prval, | ||
| l_int32 * | pgval, | ||
| l_int32 * | pbval | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [out] | prval,pgval,pbval | each color value |
Definition at line 751 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, PixColormap::n, and RGBA_Quad::red.
Referenced by addColorizedGrayToCmap(), pixBlendBoxaRandom(), pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapConvertYUVToRGB(), pixcmapCountGrayColors(), pixcmapGammaTRC(), pixcmapGetColor32(), pixcmapGetRangeValues(), pixcmapGetRankIntensity(), pixcmapShiftByComponent(), pixcmapShiftIntensity(), pixcmapToOctcubeLUT(), and pixRenderRandomCmapPtaa().
| l_ok pixcmapGetColor32 | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_uint32 * | pval32 | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [out] | pval32 | 32-bit rgb color value |
Notes:
(1) The returned alpha channel value is 255.
Definition at line 791 of file colormap.c.
References composeRGBAPixel(), and pixcmapGetColor().
| l_int32 pixcmapGetCount | ( | PIXCMAP * | cmap | ) |
| [in] | cmap |
Definition at line 635 of file colormap.c.
References PixColormap::n.
Referenced by addColorizedGrayToCmap(), cmapEqual(), numaFillCmapFromHisto(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapConvertYUVToRGB(), pixcmapCountGrayColors(), pixcmapGammaTRC(), pixcmapGetDistanceToColor(), pixcmapGetIndex(), pixcmapGetMinDepth(), pixcmapGetNearestGrayIndex(), pixcmapGetNearestIndex(), pixcmapGetRangeValues(), pixcmapGetRankIntensity(), pixcmapHasColor(), pixcmapIsBlackAndWhite(), pixcmapIsOpaque(), pixcmapSerializeToMemory(), pixcmapShiftByComponent(), pixcmapShiftIntensity(), pixcmapToArrays(), pixcmapToOctcubeLUT(), and pixcmapToRGBTable().
| l_int32 pixcmapGetDepth | ( | PIXCMAP * | cmap | ) |
| [in] | cmap |
Definition at line 669 of file colormap.c.
References PixColormap::depth.
Referenced by pixcmapConvertTo4(), and pixcmapConvertTo8().
| l_ok pixcmapGetDistanceToColor | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pdist | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [in] | rval,gval,bval | target color |
| [out] | pdist | the distance from the cmap entry to target |
Notes:
(1) Returns the L2 distance (squared) between the color at index i
and the target color.
Definition at line 1320 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, CCBorda::n, pixcmapGetCount(), and RGBA_Quad::red.
| l_int32 pixcmapGetFreeCount | ( | PIXCMAP * | cmap | ) |
| [in] | cmap |
Definition at line 652 of file colormap.c.
References PixColormap::n, and PixColormap::nalloc.
Referenced by pixcmapAddBlackOrWhite().
| l_int32 pixcmapGetIndex | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap colors to search for; each number is in range [0, ... 255] |
| [out] | pindex | found index |
Definition at line 963 of file colormap.c.
References PixColormap::array, CCBorda::n, and pixcmapGetCount().
Referenced by pixcmapAddNearestColor(), pixcmapAddNewColor(), and pixcmapUsableColor().
| l_ok pixcmapGetMinDepth | ( | PIXCMAP * | cmap, |
| l_int32 * | pmindepth | ||
| ) |
| [in] | cmap | |
| [out] | pmindepth | minimum depth to support the colormap |
Notes:
(1) On error, &mindepth is returned as 0.
Definition at line 692 of file colormap.c.
References pixcmapGetCount().
| l_ok pixcmapGetNearestGrayIndex | ( | PIXCMAP * | cmap, |
| l_int32 | val, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | val | gray value to search for; in range [0, ... 255] |
| [out] | pindex | the index of the nearest color |
Notes:
(1) This should be used on gray colormaps. It uses only the
green value of the colormap.
(2) Returns the index of the exact color if possible, otherwise the
index of the color closest to the target color.
Definition at line 1267 of file colormap.c.
References PixColormap::array, RGBA_Quad::green, CCBorda::n, and pixcmapGetCount().
| l_ok pixcmapGetNearestIndex | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap colors to search for; each number is in range [0, ... 255] |
| [out] | pindex | the index of the nearest color |
Notes:
(1) Returns the index of the exact color if possible, otherwise the
index of the color closest to the target color.
(2) Nearest color is that which is the least sum-of-squares distance
from the target color.
Definition at line 1209 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, CCBorda::n, pixcmapGetCount(), and RGBA_Quad::red.
Referenced by pixcmapAddNearestColor(), and pixcmapToOctcubeLUT().
| l_ok pixcmapGetRangeValues | ( | PIXCMAP * | cmap, |
| l_int32 | select, | ||
| l_int32 * | pminval, | ||
| l_int32 * | pmaxval, | ||
| l_int32 * | pminindex, | ||
| l_int32 * | pmaxindex | ||
| ) |
| [in] | cmap | |
| [in] | select | L_SELECT_RED, L_SELECT_GREEN, L_SELECT_BLUE or L_SELECT_AVERAGE |
| [out] | pminval | [optional] minimum value of component |
| [out] | pmaxval | [optional] maximum value of component |
| [out] | pminindex | [optional] index of minimum value |
| [out] | pmaxindex | [optional] index of maximum value |
Notes:
(1) Returns, for selected components (or the average), the
the extreme values (min and/or max) and their indices
that are found in the cmap.
Definition at line 1376 of file colormap.c.
References L_SELECT_AVERAGE, L_SELECT_BLUE, L_SELECT_GREEN, L_SELECT_RED, CCBorda::n, pixcmapGetColor(), and pixcmapGetCount().
| l_ok pixcmapGetRankIntensity | ( | PIXCMAP * | cmap, |
| l_float32 | rankval, | ||
| l_int32 * | pindex | ||
| ) |
| [in] | cmap | |
| [in] | rankval | 0.0 for darkest, 1.0 for lightest color |
| [out] | pindex | the index into the colormap that corresponds to the rank intensity color |
Definition at line 1158 of file colormap.c.
References L_SORT_INCREASING, CCBorda::n, numaAddNumber(), numaCreate(), numaDestroy(), numaGetIValue(), numaGetSortIndex(), pixcmapGetColor(), and pixcmapGetCount().
Referenced by pixcmapAddBlackOrWhite(), and pixcmapSetBlackAndWhite().
| l_ok pixcmapGetRGBA | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_int32 * | prval, | ||
| l_int32 * | pgval, | ||
| l_int32 * | pbval, | ||
| l_int32 * | paval | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [out] | prval,pgval,pbval,paval | each color value |
Definition at line 819 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, PixColormap::n, and RGBA_Quad::red.
Referenced by cmapEqual(), pixcmapGetRGBA32(), pixcmapSerializeToMemory(), and pixcmapToRGBTable().
| l_ok pixcmapGetRGBA32 | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_uint32 * | pval32 | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [out] | pval32 | 32-bit rgba color value |
Definition at line 857 of file colormap.c.
References composeRGBAPixel(), and pixcmapGetRGBA().
| PIXCMAP* pixcmapGrayToColor | ( | l_uint32 | color | ) |
| [in] | color |
Notes:
(1) This creates a colormap that maps from gray to
a specific color. In the mapping, each component
is faded to white, depending on the gray value.
(2) In use, this is simply attached to a grayscale pix
to give it the input color.
Definition at line 1472 of file colormap.c.
References extractRGBValues(), pixcmapAddColor(), and pixcmapCreate().
| l_ok pixcmapHasColor | ( | PIXCMAP * | cmap, |
| l_int32 * | pcolor | ||
| ) |
| [in] | cmap | |
| [out] | pcolor | TRUE if cmap has color; FALSE otherwise |
Definition at line 1002 of file colormap.c.
References CCBorda::n, pixcmapGetCount(), and pixcmapToArrays().
Referenced by pixcmapIsBlackAndWhite().
| l_ok pixcmapIsBlackAndWhite | ( | PIXCMAP * | cmap, |
| l_int32 * | pblackwhite | ||
| ) |
| [in] | cmap | |
| [out] | pblackwhite | TRUE if the cmap has only two colors: black (0,0,0) and white (255,255,255) |
Definition at line 1076 of file colormap.c.
References PixColormap::array, pixcmapGetCount(), pixcmapHasColor(), and RGBA_Quad::red.
| l_ok pixcmapIsOpaque | ( | PIXCMAP * | cmap, |
| l_int32 * | popaque | ||
| ) |
| [in] | cmap | |
| [out] | popaque | TRUE if fully opaque: all entries are 255 |
Definition at line 1041 of file colormap.c.
References PixColormap::array, CCBorda::n, and pixcmapGetCount().
| l_ok pixcmapIsValid | ( | PIXCMAP * | cmap, |
| l_int32 * | pvalid | ||
| ) |
| [in] | cmap | |
| [out] | pvalid | return 1 if valid; 0 if not |
Definition at line 293 of file colormap.c.
References PixColormap::array, PixColormap::depth, PixColormap::n, and PixColormap::nalloc.
Referenced by pixcmapCopy().
| PIXCMAP* pixcmapRead | ( | const char * | filename | ) |
| [in] | filename |
Definition at line 1630 of file colormap.c.
References fopenReadStream(), and pixcmapReadStream().
| PIXCMAP* pixcmapReadMem | ( | const l_uint8 * | data, |
| size_t | size | ||
| ) |
| [in] | data | serialization of pixcmap; in ascii |
| [in] | size | of data in bytes; can use strlen to get it |
Definition at line 1698 of file colormap.c.
References fopenReadFromMemory(), and pixcmapReadStream().
| PIXCMAP* pixcmapReadStream | ( | FILE * | fp | ) |
| [in] | fp | file stream |
Definition at line 1657 of file colormap.c.
References pixcmapAddRGBA(), pixcmapCreate(), and pixcmapDestroy().
Referenced by pixcmapRead(), and pixcmapReadMem().
| l_ok pixcmapResetColor | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [in] | rval,gval,bval | colormap entry to be reset; each number is in range [0, ... 255] |
Notes:
(1) This resets sets the color of an entry that has already
been set and included in the count of colors.
(2) The alpha component is 255 (opaque)
Definition at line 893 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, PixColormap::n, and RGBA_Quad::red.
Referenced by pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertYUVToRGB(), pixcmapGammaTRC(), pixcmapSetBlackAndWhite(), pixcmapShiftByComponent(), and pixcmapShiftIntensity().
| l_ok pixcmapSerializeToMemory | ( | PIXCMAP * | cmap, |
| l_int32 | cpc, | ||
| l_int32 * | pncolors, | ||
| l_uint8 ** | pdata | ||
| ) |
| [in] | cmap | colormap |
| [in] | cpc | components/color: 3 for rgb, 4 for rgba |
| [out] | pncolors | number of colors in table |
| [out] | pdata | binary string, cpc bytes per color |
Notes:
(1) When serializing to store in a pdf, use cpc = 3.
Definition at line 1955 of file colormap.c.
References pixcmapGetCount(), and pixcmapGetRGBA().
| l_ok pixcmapSetAlpha | ( | PIXCMAP * | cmap, |
| l_int32 | index, | ||
| l_int32 | aval | ||
| ) |
| [in] | cmap | |
| [in] | index | |
| [in] | aval | in range [0, ... 255] |
Notes:
(1) This modifies the transparency of one entry in a colormap.
The alpha component by default is 255 (opaque).
This is used when extracting the colormap from a PNG file
without decoding the image.
Definition at line 934 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, and PixColormap::n.
| l_ok pixcmapSetBlackAndWhite | ( | PIXCMAP * | cmap, |
| l_int32 | setblack, | ||
| l_int32 | setwhite | ||
| ) |
| [in] | cmap | |
| [in] | setblack | 0 for no operation; 1 to set darkest color to black |
| [in] | setwhite | 0 for no operation; 1 to set lightest color to white |
Definition at line 605 of file colormap.c.
References pixcmapGetRankIntensity(), and pixcmapResetColor().
Referenced by pixThresholdGrayArb().
| l_ok pixcmapShiftByComponent | ( | PIXCMAP * | cmap, |
| l_uint32 | srcval, | ||
| l_uint32 | dstval | ||
| ) |
| [in] | cmap | colormap |
| [in] | srcval | source color: 0xrrggbb00 |
| [in] | dstval | target color: 0xrrggbb00 |
Notes:
(1) This is an in-place transform
(2) It implements pixelShiftByComponent() for each color.
The mapping is specified by srcval and dstval.
(3) If a component decreases, the component in the colormap
decreases by the same ratio. Likewise for increasing, except
all ratios are taken with respect to the distance from 255.
Definition at line 2280 of file colormap.c.
References extractRGBValues(), pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and pixelShiftByComponent().
| l_ok pixcmapShiftIntensity | ( | PIXCMAP * | cmap, |
| l_float32 | fraction | ||
| ) |
| [in] | cmap | colormap |
| [in] | fraction | between -1.0 and +1.0 |
Notes:
(1) This is an in-place transform
(2) It does a proportional shift of the intensity for each color.
(3) If fraction < 0.0, it moves all colors towards (0,0,0).
This darkens the image.
If fraction > 0.0, it moves all colors towards (255,255,255)
This fades the image.
(4) The equivalent transform can be accomplished with pixcmapGammaTRC(),
but it is considerably more difficult (see numaGammaTRC()).
Definition at line 2230 of file colormap.c.
References pixcmapGetColor(), pixcmapGetCount(), and pixcmapResetColor().
| l_ok pixcmapToArrays | ( | PIXCMAP * | cmap, |
| l_int32 ** | prmap, | ||
| l_int32 ** | pgmap, | ||
| l_int32 ** | pbmap, | ||
| l_int32 ** | pamap | ||
| ) |
| [in] | cmap | colormap |
| [out] | prmap,pgmap,pbmap | colormap arrays |
| [out] | pamap | [optional] alpha array |
Definition at line 1856 of file colormap.c.
References RGBA_Quad::alpha, PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, pixcmapGetCount(), and RGBA_Quad::red.
Referenced by pixcmapHasColor(), pixcmapToOctcubeLUT(), and pixcmapWriteStream().
| l_ok pixcmapToRGBTable | ( | PIXCMAP * | cmap, |
| l_uint32 ** | ptab, | ||
| l_int32 * | pncolors | ||
| ) |
| [in] | cmap | colormap |
| [out] | ptab | table of rgba values for the colormap |
| [out] | pncolors | [optional] size of table |
Definition at line 1910 of file colormap.c.
References composeRGBAPixel(), pixcmapGetCount(), and pixcmapGetRGBA().
| l_ok pixcmapUsableColor | ( | PIXCMAP * | cmap, |
| l_int32 | rval, | ||
| l_int32 | gval, | ||
| l_int32 | bval, | ||
| l_int32 * | pusable | ||
| ) |
| [in] | cmap | |
| [in] | rval,gval,bval | colormap entry to be added; each number is in range [0, ... 255] |
| [out] | pusable | 1 if usable; 0 if not |
Notes:
(1) This checks if the color already exists or if there is
room to add it. It makes no change in the colormap.
Definition at line 519 of file colormap.c.
References PixColormap::n, PixColormap::nalloc, and pixcmapGetIndex().
| l_ok pixcmapWrite | ( | const char * | filename, |
| PIXCMAP * | cmap | ||
| ) |
| [in] | filename | |
| [in] | cmap |
Definition at line 1726 of file colormap.c.
References fopenWriteStream(), and pixcmapWriteStream().
| l_ok pixcmapWriteMem | ( | l_uint8 ** | pdata, |
| size_t * | psize, | ||
| PIXCMAP * | cmap | ||
| ) |
| [out] | pdata | data of serialized pixcmap; ascii |
| [out] | psize | size of returned data |
| [in] | cmap |
Notes:
(1) Serializes a pixcmap in memory and puts the result in a buffer.
Definition at line 1804 of file colormap.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and pixcmapWriteStream().
| l_ok pixcmapWriteStream | ( | FILE * | fp, |
| PIXCMAP * | cmap | ||
| ) |
| [in] | fp | file stream |
| [in] | cmap |
Definition at line 1758 of file colormap.c.
References PixColormap::depth, PixColormap::n, and pixcmapToArrays().
Referenced by pixcmapWrite(), and pixcmapWriteMem().