Leptonica 1.68
C Image Processing Library
|
Implements PixColormap; colormap conversions, serialization, transforms. More...
Go to the source code of this file.
Implements PixColormap; colormap conversions, serialization, transforms.
Colormap creation, copy, destruction, addition PIXCMAP *pixcmapCreate() PIXCMAP *pixcmapCreateRandom() PIXCMAP *pixcmapCreateLinear() PIXCMAP *pixcmapCopy() void pixcmapDestroy() l_int32 pixcmapAddColor() 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 pixcmapResetColor() l_int32 pixcmapGetIndex() l_int32 pixcmapHasColor() l_int32 pixcmapCountGrayColors() l_int32 pixcmapGetRankIntensity() l_int32 pixcmapGetNearestIndex() l_int32 pixcmapGetNearestGrayIndex() l_int32 pixcmapGetComponentRange() l_int32 pixcmapGetExtremeValue() Colormap conversion PIXCMAP *pixcmapGrayToColor() PIXCMAP *pixcmapColorToGray() Colormap I/O l_int32 pixcmapReadStream() l_int32 pixcmapWriteStream() 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()
Definition in file colormap.c.
Input: depth (bpp, of pix) Return: cmap, or null on error
Definition at line 85 of file colormap.c.
References PixColormap::array, CALLOC, PixColormap::depth, ERROR_PTR, PixColormap::n, PixColormap::nalloc, NULL, and PROCNAME.
Referenced by boxaaDisplay(), jbDataRender(), makeGrayQuantColormapArb(), makeGrayQuantTableArb(), octreeGenerateAndPrune(), pixAddMinimalGrayColormap8(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapDeserializeFromMemory(), pixcmapGenerateFromHisto(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), pixcmapReadStream(), pixColorSegmentCluster(), pixConvert1To2Cmap(), pixConvert1To4Cmap(), pixConvert2To8(), pixConvert4To8(), pixConvertGrayToColormap8(), pixConvertGrayToFalseColor(), pixConvertTo8(), pixDisplayDiffBinary(), pixDisplayHitMissSel(), pixDisplayMatchedPattern(), pixFewColorsOctcubeQuant1(), pixFewColorsOctcubeQuant2(), pixFewColorsOctcubeQuantMixed(), pixFixedOctcubeQuant256(), pixGrayQuantFromHisto(), pixOctcubeQuantMixedWithGray(), pixOctreeQuantByPopulation(), pixOctreeQuantNumColors(), pixReadFromTiffStream(), pixReadStreamBmp(), pixReadStreamGif(), pixReadStreamJpeg(), pixReadStreamPng(), pixRemoveUnusedColors(), and pixWriteStreamGif().
Input: depth (bpp, of pix; 2, 4 or 8) hasblack (1 if the first color is black; 0 if no black) haswhite (1 if the last color is white; 0 if no white) Return: cmap, or null on error
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 133 of file colormap.c.
References ERROR_PTR, NULL, pixcmapAddColor(), pixcmapCreate(), and PROCNAME.
Referenced by main(), pixaDisplayRandomCmap(), pixBlendBoxaRandom(), pixDrawBoxaRandom(), pixPaintBoxaRandom(), and pixRenderRandomCmapPtaa().
Input: d (depth of pix for this colormap; 1, 2, 4 or 8) nlevels (valid in range [2, 2^d]) Return: cmap, or null on error
Notes: (1) Colormap has equally spaced gray color values from black (0, 0, 0) to white (255, 255, 255).
Definition at line 177 of file colormap.c.
References ERROR_PTR, nlevels, NULL, pixcmapAddColor(), pixcmapCreate(), and PROCNAME.
Referenced by pixAddGrayColormap8(), pixConvertGrayToColormap(), pixDitherTo2bppSpec(), pixThreshold8(), pixThresholdOn8bpp(), pixThresholdTo2bpp(), and pixThresholdTo4bpp().
Input: cmaps Return: cmapd, or null on error
Definition at line 207 of file colormap.c.
References PixColormap::array, CALLOC, PixColormap::depth, ERROR_PTR, PixColormap::n, PixColormap::nalloc, NULL, and PROCNAME.
Referenced by pixAddSingleTextblock(), pixBlendCmap(), pixcmapColorToGray(), pixColorGrayCmap(), pixCopyColormap(), pixGrayQuantFromCmap(), and pixOctcubeQuantFromCmapLUT().
void pixcmapDestroy | ( | PIXCMAP ** | pcmap | ) |
Input: &cmap (<set to="" null>="">) Return: void
Definition at line 238 of file colormap.c.
References PixColormap::array, FREE, L_WARNING, NULL, and PROCNAME.
Referenced by main(), pixBlendBoxaRandom(), pixBlendCmap(), pixColorGrayCmap(), pixColorizeGray(), pixDestroyColormap(), pixDrawBoxaRandom(), pixPaintBoxaRandom(), pixReadStreamGif(), and pixThresholdGrayArb().
Input: cmap rval, gval, bval (colormap entry to be added; each number is in range [0, ... 255]) Return: 0 if OK, 1 on error
Note: always adds the color if there is room.
Definition at line 271 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, ERROR_INT, RGBA_Quad::green, PixColormap::n, PixColormap::nalloc, PROCNAME, and RGBA_Quad::red.
Referenced by boxaaDisplay(), jbDataRender(), makeGrayQuantColormapArb(), makeGrayQuantTableArb(), numaFillCmapFromHisto(), octreeGenerateAndPrune(), pixAddMinimalGrayColormap8(), pixBlendCmap(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapCreateLinear(), pixcmapCreateRandom(), pixcmapDeserializeFromMemory(), pixcmapGenerateFromHisto(), pixcmapGenerateFromMedianCuts(), pixcmapGrayToColor(), pixcmapReadStream(), pixConvert1To2Cmap(), pixConvert1To4Cmap(), pixConvert2To8(), pixConvert4To8(), pixConvertGrayToColormap8(), pixConvertGrayToFalseColor(), pixConvertTo8(), pixDisplayDiffBinary(), pixDisplayHitMissSel(), pixDisplayMatchedPattern(), pixFewColorsOctcubeQuant1(), pixFewColorsOctcubeQuant2(), pixFewColorsOctcubeQuantMixed(), pixFixedOctcubeQuant256(), pixGetEdgeProfile(), pixMedianCutQuantMixed(), pixOctcubeQuantMixedWithGray(), pixOctreeQuantByPopulation(), pixOctreeQuantNumColors(), pixReadFromTiffStream(), pixReadStreamGif(), pixReadStreamJpeg(), pixReadStreamPng(), pixRemoveUnusedColors(), pixSetMaskedCmap(), pixSetSelectCmap(), pixSetSelectMaskedCmap(), pixSnapColorCmap(), and pixWriteStreamGif().
l_int32 pixcmapAddNewColor | ( | PIXCMAP * | cmap, |
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pindex | ||
) |
Input: cmap rval, gval, bval (colormap entry to be added; each number is in range [0, ... 255]) &index (<return> index of color) Return: 0 if OK, 1 on error; 2 if unable to add color
Notes: (1) This only adds color if not already there. (2) This returns the index of the new (or existing) color. (3) Returns 2 with a warning if unable to add this color; the caller should check the return value.
Definition at line 311 of file colormap.c.
References ERROR_INT, L_WARNING, PixColormap::n, PixColormap::nalloc, pixcmapAddColor(), pixcmapGetCount(), pixcmapGetIndex(), and PROCNAME.
Referenced by addColorizedGrayToCmap(), pixcmapAddBlackOrWhite(), pixColorSegmentTryCluster(), pixDrawBoxa(), pixPaintBoxa(), and pixRenderPtaArb().
l_int32 pixcmapAddNearestColor | ( | PIXCMAP * | cmap, |
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pindex | ||
) |
Input: cmap rval, gval, bval (colormap entry to be added; each number is in range [0, ... 255]) &index (<return> index of color) Return: 0 if OK, 1 on error
Notes: (1) This only adds color if not already there. (2) 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 357 of file colormap.c.
References ERROR_INT, PixColormap::n, PixColormap::nalloc, pixcmapAddColor(), pixcmapGetCount(), pixcmapGetIndex(), pixcmapGetNearestIndex(), and PROCNAME.
Referenced by pixAddSingleTextblock(), and pixSetTextline().
l_int32 pixcmapUsableColor | ( | PIXCMAP * | cmap, |
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pusable | ||
) |
Input: cmap rval, gval, bval (colormap entry to be added; each number is in range [0, ... 255]) usable (<return> 1 if usable; 0 if not) Return: 0 if OK, 1 on error
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 402 of file colormap.c.
References ERROR_INT, PixColormap::n, PixColormap::nalloc, pixcmapGetIndex(), and PROCNAME.
Input: cmap color (0 for black, 1 for white) &index (<optional return>=""> index of color; can be null) Return: 0 if OK, 1 on error
Notes: (1) This only adds color if not already there. (2) This sets index to the requested color. (3) If there is no room in the colormap, returns the index of the closest color.
Definition at line 446 of file colormap.c.
References ERROR_INT, pixcmapAddNewColor(), pixcmapGetFreeCount(), pixcmapGetRankIntensity(), and PROCNAME.
Referenced by pixAffineSampled(), pixBilinearSampled(), pixProjectiveSampled(), pixRotate(), pixSetBlackOrWhite(), and pixSetBlackOrWhiteBoxa().
Input: cmap setblack (0 for no operation; 1 to set darkest color to black) setwhite (0 for no operation; 1 to set lightest color to white) Return: 0 if OK, 1 on error
Definition at line 486 of file colormap.c.
References ERROR_INT, pixcmapGetRankIntensity(), pixcmapResetColor(), and PROCNAME.
Referenced by pixThresholdGrayArb().
Input: cmap Return: count, or 0 on error
Definition at line 517 of file colormap.c.
References ERROR_INT, PixColormap::n, and PROCNAME.
Referenced by addColorizedGrayToCmap(), main(), numaFillCmapFromHisto(), pixAddMinimalGrayColormap8(), pixBlendCmap(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertYUVToRGB(), pixcmapCountGrayColors(), pixcmapGammaTRC(), pixcmapGetExtremeValue(), pixcmapGetIndex(), pixcmapGetMinDepth(), pixcmapGetNearestGrayIndex(), pixcmapGetNearestIndex(), pixcmapGetRankIntensity(), pixcmapHasColor(), pixcmapSerializeToMemory(), pixcmapShiftIntensity(), pixcmapToArrays(), pixcmapToOctcubeLUT(), pixcmapToRGBTable(), pixColorSegmentClean(), pixColorSegmentCluster(), pixColorSegmentRemoveColors(), pixColorSegmentTryCluster(), pixColorsForQuantization(), pixConvert2To8(), pixConvert4To8(), pixDrawBoxa(), pixEqualWithCmap(), pixFewColorsOctcubeQuantMixed(), pixGetEdgeProfile(), pixGlobalNormRGB(), pixGrayQuantFromHisto(), pixMedianCutQuantGeneral(), pixMedianCutQuantMixed(), pixMultConstantColor(), pixMultMatrixColor(), pixNumColors(), pixOctreeQuantNumColors(), pixPaintBoxa(), pixRemoveColormap(), pixRemoveUnusedColors(), pixSetAll(), pixSetAllArbitrary(), pixSetInRect(), pixSetInRectArbitrary(), pixSetMaskedCmap(), pixSetSelectCmap(), pixSetSelectMaskedCmap(), pixSnapColorCmap(), pixUsesCmapColor(), pixWriteStreamBmp(), pixWriteStreamGif(), pixWriteStreamPng(), and pixWriteToTiffStream().
Input: cmap Return: free entries, or 0 on error
Definition at line 535 of file colormap.c.
References ERROR_INT, PixColormap::n, PixColormap::nalloc, and PROCNAME.
Referenced by pixcmapAddBlackOrWhite(), and pixSnapColorCmap().
Input: cmap Return: depth, or 0 on error
Definition at line 553 of file colormap.c.
References PixColormap::depth, ERROR_INT, and PROCNAME.
Input: cmap &mindepth (<return> minimum depth to support the colormap) Return: 0 if OK, 1 on error
Notes: (1) On error, &mindepth is returned as 0.
Definition at line 575 of file colormap.c.
References ERROR_INT, pixcmapGetCount(), and PROCNAME.
Referenced by pixGrayQuantFromCmap(), and pixOctcubeQuantFromCmapLUT().
Input: cmap Return: 0 if OK, 1 on error
Note: this removes the colors by setting the count to 0.
Definition at line 609 of file colormap.c.
References ERROR_INT, PixColormap::n, and PROCNAME.
Referenced by pixColorSegmentTryCluster().
l_int32 pixcmapGetColor | ( | PIXCMAP * | cmap, |
l_int32 | index, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
Input: cmap index &rval, &gval, &bval (<return> each color value in l_int32) Return: 0 if OK, 1 if not accessable (caller should check)
Definition at line 632 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, ERROR_INT, RGBA_Quad::green, PixColormap::n, PROCNAME, and RGBA_Quad::red.
Referenced by addColorizedGrayToCmap(), main(), octreeGenerateAndPrune(), pixAddSingleTextblock(), pixBlendBoxaRandom(), pixBlendCmap(), pixClipMasked(), pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertYUVToRGB(), pixcmapCountGrayColors(), pixcmapGammaTRC(), pixcmapGetColor32(), pixcmapGetExtremeValue(), pixcmapGetRankIntensity(), pixcmapSerializeToMemory(), pixcmapShiftIntensity(), pixcmapToOctcubeLUT(), pixcmapToRGBTable(), pixConvert2To8(), pixConvert4To8(), pixConvertTo1(), pixDitherOctindexWithCmap(), pixDrawBoxaRandom(), pixEqualWithCmap(), pixFewColorsOctcubeQuantMixed(), pixGetColorHistogram(), pixGetColorHistogramMasked(), pixGetRandomPixel(), pixGlobalNormRGB(), pixMedianCutQuantGeneral(), pixMultConstantColor(), pixMultMatrixColor(), pixOctreeColorQuantGeneral(), pixPaintBoxaRandom(), pixQuantizeWithColormap(), pixRemoveColormap(), pixRemoveUnusedColors(), pixRenderRandomCmapPtaa(), pixSetTextline(), pixSnapColorCmap(), pixUsesCmapColor(), pixWriteStreamGif(), and selCreateFromColorPix().
Input: cmap index &val32 (<return> 32-bit rgba color value) Return: 0 if OK, 1 if not accessable (caller should check)
Notes: (1) The returned alpha channel value is zero, because it is not used in leptonica colormaps.
Definition at line 672 of file colormap.c.
References composeRGBPixel(), ERROR_INT, pixcmapGetColor(), and PROCNAME.
Referenced by pixColorSegmentClean(), and pixColorSegmentRemoveColors().
l_int32 pixcmapResetColor | ( | PIXCMAP * | cmap, |
l_int32 | index, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: cmap index rval, gval, bval (colormap entry to be reset; each number is in range [0, ... 255]) Return: 0 if OK, 1 if not accessable (caller should check)
Notes: (1) This resets sets the color of an entry that has already been set and included in the count of colors.
Definition at line 705 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, ERROR_INT, RGBA_Quad::green, PixColormap::n, PROCNAME, and RGBA_Quad::red.
Referenced by DoPageSegmentation(), main(), pixcmapColorToGray(), pixcmapContrastTRC(), pixcmapConvertHSVToRGB(), pixcmapConvertRGBToHSV(), pixcmapConvertRGBToYUV(), pixcmapConvertYUVToRGB(), pixcmapGammaTRC(), pixcmapSetBlackAndWhite(), pixcmapShiftIntensity(), pixColorSegmentTryCluster(), pixGetRegionsBinary(), pixGlobalNormRGB(), pixMedianCutQuantGeneral(), pixMultConstantColor(), pixMultMatrixColor(), pixOctcubeQuantMixedWithGray(), pixOctreeColorQuantGeneral(), and pixSnapColorCmap().
l_int32 pixcmapGetIndex | ( | PIXCMAP * | cmap, |
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pindex | ||
) |
Input: cmap rval, gval, bval (colormap colors to search for; each number is in range [0, ... 255]) &index (<return>) Return: 0 if found, 1 if not found (caller must check)
Definition at line 739 of file colormap.c.
References PixColormap::array, ERROR_INT, CCBorda::n, pixcmapGetCount(), and PROCNAME.
Referenced by main(), pixBlendCmap(), pixcmapAddNearestColor(), pixcmapAddNewColor(), pixcmapUsableColor(), pixSetMaskedCmap(), pixSetSelectCmap(), and pixSetSelectMaskedCmap().
Input: cmap &color (<return> TRUE if cmap has color; FALSE otherwise) Return: 0 if OK, 1 on error
Definition at line 777 of file colormap.c.
References ERROR_INT, FALSE, FREE, CCBorda::n, pixcmapGetCount(), pixcmapToArrays(), PROCNAME, and TRUE.
Referenced by main(), pixColorsForQuantization(), pixGrayQuantFromCmap(), pixRemoveColormap(), pixUsesCmapColor(), and selCreateFromColorPix().
Input: cmap &ngray (<return> number of gray colors) Return: 0 if OK, 1 on error
Notes: (1) This counts the unique gray colors, including black and white.
Definition at line 819 of file colormap.c.
References CALLOC, ERROR_INT, FREE, CCBorda::n, pixcmapGetColor(), pixcmapGetCount(), and PROCNAME.
Input: cmap rankval (0.0 for darkest, 1.0 for lightest color) &index (<return> the index into the colormap that corresponds to the rank intensity color) Return: 0 if OK, 1 on error
Definition at line 860 of file colormap.c.
References ERROR_INT, L_SORT_INCREASING, CCBorda::n, numaAddNumber(), numaCreate(), numaDestroy(), numaGetIValue(), numaGetSortIndex(), pixcmapGetColor(), pixcmapGetCount(), and PROCNAME.
Referenced by pixAddBlackBorder(), pixcmapAddBlackOrWhite(), pixcmapSetBlackAndWhite(), pixMedianCutQuantGeneral(), pixOctreeColorQuantGeneral(), pixRasteropHip(), and pixRasteropVip().
l_int32 pixcmapGetNearestIndex | ( | PIXCMAP * | cmap, |
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_int32 * | pindex | ||
) |
Input: cmap rval, gval, bval (colormap colors to search for; each number is in range [0, ... 255]) &index (<return> the index of the nearest color) Return: 0 if OK, 1 on error (caller must check)
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 909 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, ERROR_INT, RGBA_Quad::green, CCBorda::n, NULL, pixcmapGetCount(), PROCNAME, RGBA_Quad::red, and UNDEF.
Referenced by octreeGenerateAndPrune(), pixClipMasked(), pixcmapAddNearestColor(), and pixcmapToOctcubeLUT().
Input: cmap val (gray value to search for; in range [0, ... 255]) &index (<return> the index of the nearest color) Return: 0 if OK, 1 on error (caller must check)
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 965 of file colormap.c.
References PixColormap::array, ERROR_INT, RGBA_Quad::green, L_ABS, CCBorda::n, NULL, pixcmapGetCount(), and PROCNAME.
Referenced by pixGrayQuantFromCmap().
l_int32 pixcmapGetComponentRange | ( | PIXCMAP * | cmap, |
l_int32 | color, | ||
l_int32 * | pminval, | ||
l_int32 * | pmaxval | ||
) |
Input: cmap color (L_SELECT_RED, L_SELECT_GREEN or L_SELECT_BLUE) &minval (<optional return>=""> minimum value of component) &maxval (<optional return>=""> minimum value of component) Return: 0 if OK, 1 on error
Notes: (1) Returns for selected components the extreme value (either min or max) of the color component that is found in the colormap.
Definition at line 1017 of file colormap.c.
References ERROR_INT, L_SELECT_BLUE, L_SELECT_GREEN, L_SELECT_MAX, L_SELECT_MIN, L_SELECT_RED, NULL, pixcmapGetExtremeValue(), and PROCNAME.
Referenced by pixGetComponentRange().
l_int32 pixcmapGetExtremeValue | ( | PIXCMAP * | cmap, |
l_int32 | type, | ||
l_int32 * | prval, | ||
l_int32 * | pgval, | ||
l_int32 * | pbval | ||
) |
Input: cmap type (L_SELECT_MIN or L_SELECT_MAX) &rval (<optional return>=""> red component) &gval (<optional return>=""> green component) &bval (<optional return>=""> blue component) Return: 0 if OK, 1 on error
Notes: (1) Returns for selected components the extreme value (either min or max) of the color component that is found in the colormap.
Definition at line 1064 of file colormap.c.
References ERROR_INT, L_SELECT_MAX, L_SELECT_MIN, CCBorda::n, pixcmapGetColor(), pixcmapGetCount(), and PROCNAME.
Referenced by pixcmapGetComponentRange(), and pixGetExtremeValue().
Input: color Return: cmap, or null on error
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 1132 of file colormap.c.
References extractRGBValues(), pixcmapAddColor(), and pixcmapCreate().
Referenced by main(), and pixColorizeGray().
Input: cmap rwt, gwt, bwt (non-negative; these should add to 1.0) Return: cmap (gray), or null on error
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 1162 of file colormap.c.
References ERROR_PTR, L_ABS, L_WARNING, CCBorda::n, NULL, pixcmapCopy(), pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.
Referenced by main(), and pixGrayQuantFromCmap().
PIXCMAP* pixcmapReadStream | ( | FILE * | fp | ) |
Input: stream Return: cmap, or null on error
Definition at line 1215 of file colormap.c.
References ERROR_PTR, NULL, pixcmapAddColor(), pixcmapCreate(), and PROCNAME.
Referenced by main().
Input: stream, cmap Return: 0 if OK, 1 on error
Definition at line 1255 of file colormap.c.
References PixColormap::depth, ERROR_INT, FREE, PixColormap::n, pixcmapToArrays(), and PROCNAME.
Referenced by main(), and pixPrintStreamInfo().
Input: colormap &rmap, &gmap, &bmap (<return> colormap arrays) Return: 0 if OK; 1 on error
Definition at line 1297 of file colormap.c.
References PixColormap::array, RGBA_Quad::blue, CALLOC, ERROR_INT, RGBA_Quad::green, NULL, pixcmapGetCount(), PROCNAME, and RGBA_Quad::red.
Referenced by pixcmapHasColor(), pixcmapToOctcubeLUT(), pixcmapWriteStream(), pixRemoveColormap(), pixWriteStreamJpeg(), pixWriteStreamPng(), and pixWriteToTiffStream().
Input: colormap &tab (<return> table of rgba values for the colormap) &ncolors (<optional return>=""> size of table) Return: 0 if OK; 1 on error
Definition at line 1343 of file colormap.c.
References CALLOC, composeRGBPixel(), ERROR_INT, NULL, pixcmapGetColor(), pixcmapGetCount(), and PROCNAME.
Referenced by pixColorizeGray().
l_int32 pixcmapSerializeToMemory | ( | PIXCMAP * | cmap, |
l_int32 | cpc, | ||
l_int32 * | pncolors, | ||
l_uint8 ** | pdata, | ||
l_int32 * | pnbytes | ||
) |
Input: colormap cpc (components/color: 3 for rgb, 4 for rgba) &ncolors (<return> number of colors in table) &data (<return> binary string, 3 or 4 bytes per color) &nbytes (<return> size of data) Return: 0 if OK; 1 on error
Notes: (1) If == 4, we leave room for the alpha channel value in each color entry, but it is set to 0.
Definition at line 1392 of file colormap.c.
References CALLOC, ERROR_INT, NULL, pixcmapGetColor(), pixcmapGetCount(), and PROCNAME.
Referenced by pixGenerateFlateData(), and pixSerializeToMemory().
pixcmapDeserializeFromMemory()
Input: data (binary string, 3 or 4 bytes per color) ncolors nbytes (size of returned data) Return: cmap, or null on error
Definition at line 1440 of file colormap.c.
References ERROR_PTR, NULL, pixcmapAddColor(), pixcmapCreate(), and PROCNAME.
Referenced by pixDeserializeFromMemory().
Input: data (binary serialized data) nbytes (size of data) ncolors (in colormap) Return: hexdata (bracketed, space-separated ascii hex string), or null on error.
Notes: (1) If rgb, there are 3 colors/component; if rgba, there are 4. (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 1500 of file colormap.c.
References buf, CALLOC, ERROR_PTR, NULL, and PROCNAME.
Referenced by pixGenerateFlateData().
Input: colormap gamma (gamma correction; must be > 0.0) minval (input value that gives 0 for output; can be < 0) maxval (input value that gives 255 for output; can be > 255) Return: 0 if OK; 1 on error
Notes:
Definition at line 1562 of file colormap.c.
References ERROR_INT, L_WARNING, NULL, numaDestroy(), numaGammaTRC(), numaGetIValue(), pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.
Referenced by pixGammaTRC().
Input: colormap factor (generally between 0.0 (no enhancement) and 1.0, but can be larger than 1.0) Return: 0 if OK; 1 on error
Notes:
Definition at line 1615 of file colormap.c.
References ERROR_INT, L_WARNING, NULL, numaContrastTRC(), numaDestroy(), numaGetIValue(), pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.
Referenced by pixContrastTRC().
Input: colormap fraction (between -1.0 and +1.0) Return: 0 if OK; 1 on error
Notes:
Definition at line 1665 of file colormap.c.
References ERROR_INT, pixcmapGetColor(), pixcmapGetCount(), pixcmapResetColor(), and PROCNAME.
Referenced by main().