![]() |
Leptonica
1.83.1
Image processing and image analysis suite
|
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 (const PIXCMAP *cmaps) |
void | pixcmapDestroy (PIXCMAP **pcmap) |
l_ok | pixcmapIsValid (const PIXCMAP *cmap, PIX *pix, 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 (const 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 | pixcmapNonOpaqueColorsInfo (PIXCMAP *cmap, l_int32 *pntrans, l_int32 *pmax_trans, l_int32 *pmin_opaque) |
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 * | pixcmapGrayToFalseColor (l_float32 gamma) |
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, const PIXCMAP *cmap) |
l_ok | pixcmapWriteStream (FILE *fp, const PIXCMAP *cmap) |
l_ok | pixcmapWriteMem (l_uint8 **pdata, size_t *psize, const PIXCMAP *cmap) |
l_ok | pixcmapToArrays (const 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 pixcmapNonOpaqueColorsInfo() l_int32 pixcmapIsBlackAndWhite() l_int32 pixcmapCountGrayColors() l_int32 pixcmapGetRankIntensity() l_int32 pixcmapGetNearestIndex() l_int32 pixcmapGetNearestGrayIndex() l_int32 pixcmapGetDistanceToColor() l_int32 pixcmapGetRangeValues() Colormap conversion PIXCMAP *pixcmapGrayToFalseColor() 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() Note: (1) colormaps in leptonica have a maximum of 256 entries. (2) nalloc, the allocated size of the palette array, is related to the depth d of the pixels by: nalloc = 2^(d)
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 618 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 403 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(), makeColorfillTestData(), makeGrayQuantTableArb(), numaFillCmapFromHisto(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), pixcmapGrayToFalseColor(), pixCreateWithCmap(), 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 528 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 481 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 439 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 768 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 1641 of file colormap.c.
References 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 2286 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 1696 of file colormap.c.
References 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 1729 of file colormap.c.
References 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 2177 of file colormap.c.
[in] | cmaps |
Definition at line 243 of file colormap.c.
References PixColormap::array, PixColormap::depth, PixColormap::n, 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 1204 of file colormap.c.
References pixcmapGetColor(), and pixcmapGetCount().
PIXCMAP* pixcmapCreate | ( | l_int32 | depth | ) |
[in] | depth | of pix, in bpp |
Definition at line 126 of file colormap.c.
References PixColormap::array, PixColormap::depth, PixColormap::n, and PixColormap::nalloc.
Referenced by fpixRenderContours(), makeColorfillTestData(), makeGrayQuantTableArb(), pixcmapConvertTo4(), pixcmapConvertTo8(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapDeserializeFromMemory(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), pixcmapGrayToFalseColor(), pixcmapReadStream(), pixCreateWithCmap(), 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 215 of file colormap.c.
References pixcmapAddColor(), and pixcmapCreate().
PIXCMAP* pixcmapCreateRandom | ( | l_int32 | depth, |
l_int32 | hasblack, | ||
l_int32 | haswhite | ||
) |
[in] | depth | of pix, in bpp: 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 171 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 | > 0 |
Definition at line 2118 of file colormap.c.
References pixcmapAddRGBA(), and pixcmapCreate().
void pixcmapDestroy | ( | PIXCMAP ** | pcmap | ) |
[in,out] | pcmap | set to null on return |
Definition at line 272 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 2233 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 789 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 827 of file colormap.c.
References composeRGBAPixel(), and pixcmapGetColor().
l_int32 pixcmapGetCount | ( | const PIXCMAP * | cmap | ) |
[in] | cmap |
Definition at line 683 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(), pixcmapNonOpaqueColorsInfo(), pixcmapSerializeToMemory(), pixcmapShiftByComponent(), pixcmapShiftIntensity(), pixcmapToArrays(), pixcmapToOctcubeLUT(), and pixcmapToRGBTable().
l_int32 pixcmapGetDepth | ( | PIXCMAP * | cmap | ) |
[in] | cmap |
Definition at line 713 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 1399 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, pixcmapGetCount(), and RGBA_Quad::red.
l_int32 pixcmapGetFreeCount | ( | PIXCMAP * | cmap | ) |
[in] | cmap |
Definition at line 698 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 | value of index found |
Definition at line 989 of file colormap.c.
References PixColormap::array, 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 734 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 1348 of file colormap.c.
References PixColormap::array, RGBA_Quad::green, 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 1292 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, RGBA_Quad::green, 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 1453 of file colormap.c.
References L_SELECT_AVERAGE, L_SELECT_BLUE, L_SELECT_GREEN, L_SELECT_RED, 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 1243 of file colormap.c.
References L_SORT_INCREASING, 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 853 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 889 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 1609 of file colormap.c.
References extractRGBValues(), pixcmapAddColor(), and pixcmapCreate().
PIXCMAP* pixcmapGrayToFalseColor | ( | l_float32 | gamma | ) |
[in] | gamma | (factor) 0.0 or 1.0 for default; > 1.0 for brighter; 2.0 is quite nice |
Notes: (1) This creates a colormap that maps from gray to false colors. The colormap is modeled after the Matlap "jet" configuration.
Definition at line 1545 of file colormap.c.
References 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 1026 of file colormap.c.
References 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 1165 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 1063 of file colormap.c.
References PixColormap::array, and pixcmapGetCount().
[in] | cmap | |
[in] | pix | optional; can be NULL |
[out] | pvalid | return 1 if valid; 0 if not |
Notes: (1) If pix is input, this will verify that pixel values cannot overflow the colormap. This is a relatively expensive operation that may need to check all the pixel values. (2) If pix is input, there must be at least one color in the colormap if it is to be valid with any pix, even if the pixels are all 0.
Definition at line 308 of file colormap.c.
References PixColormap::array, PixColormap::depth, PixColormap::n, and PixColormap::nalloc.
Referenced by pixcmapCopy(), and pixSetColormap().
l_ok pixcmapNonOpaqueColorsInfo | ( | PIXCMAP * | cmap, |
l_int32 * | pntrans, | ||
l_int32 * | pmax_trans, | ||
l_int32 * | pmin_opaque | ||
) |
[in] | cmap | |
[out] | pntrans | [optional] number of transparent alpha entries; <= 256 |
[out] | pmax_trans | [optional] max index of transparent alpha |
[out] | pmin_opaque | [optional] min index of opaque < 256 |
Notes: (1) This is used, for clarity, when writing the png tRNS palette. According to the spec, http://www.w3.org/TR/PNG/#11tRNS, if the tRNS palette is of size ntrans, the palette uses the first ntrans alpha entries in the cmap, and the remaining alpha values are assumed to be 255 (opaque), regardless of cmap alpha value. (2) Ordinarily, the non-opaque colors come first in the cmap, so min_opaque > max_trans and ntrans = max_trans + 1 = min_opaque. But this does not happen in general. In trans-2bpp-palette.png, for example, only the third of four entries is not opaque, so ntrans = 1 max_trans = 2 (index is 0-based) min_opaque = 0 The tRNS palette must extend to the third entry to cover the color with transparency: use 3 as the fourth arg to png_set_tRNS(). (3) If all entries are opaque, max_trans = -1. If all entries are transparent, min_opaque = size of cmap.
Definition at line 1120 of file colormap.c.
References PixColormap::array, and pixcmapGetCount().
PIXCMAP* pixcmapRead | ( | const char * | filename | ) |
[in] | filename |
Definition at line 1761 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 1826 of file colormap.c.
References fopenReadFromMemory(), and pixcmapReadStream().
PIXCMAP* pixcmapReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Definition at line 1786 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 923 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 2073 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 962 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 655 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 2384 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 2336 of file colormap.c.
References pixcmapGetColor(), pixcmapGetCount(), and pixcmapResetColor().
l_ok pixcmapToArrays | ( | const PIXCMAP * | cmap, |
l_int32 ** | prmap, | ||
l_int32 ** | pgmap, | ||
l_int32 ** | pbmap, | ||
l_int32 ** | pamap | ||
) |
[in] | cmap | colormap |
[out] | prmap | array of red values |
[out] | pgmap | array of green values |
[out] | pbmap | array of blue values |
[out] | pamap | [optional] array of alpha (transparency) values |
Definition at line 1981 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 2032 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 573 of file colormap.c.
References PixColormap::n, PixColormap::nalloc, and pixcmapGetIndex().
l_ok pixcmapWrite | ( | const char * | filename, |
const PIXCMAP * | cmap | ||
) |
[in] | filename | |
[in] | cmap |
Definition at line 1852 of file colormap.c.
References fopenWriteStream(), and pixcmapWriteStream().
l_ok pixcmapWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
const 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 1926 of file colormap.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and pixcmapWriteStream().
l_ok pixcmapWriteStream | ( | FILE * | fp, |
const PIXCMAP * | cmap | ||
) |
[in] | fp | file stream |
[in] | cmap |
Definition at line 1882 of file colormap.c.
References PixColormap::depth, PixColormap::n, and pixcmapToArrays().
Referenced by pixcmapWrite(), and pixcmapWriteMem().