Leptonica
1.54
|
Функции | |
l_int32 | pixSetSelectCmap (PIX *pixs, BOX *box, l_int32 sindex, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 | pixColorGrayRegionsCmap (PIX *pixs, BOXA *boxa, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 | pixColorGrayCmap (PIX *pixs, BOX *box, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 | pixColorGrayMaskedCmap (PIX *pixs, PIX *pixm, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 | addColorizedGrayToCmap (PIXCMAP *cmap, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval, NUMA **pna) |
l_int32 | pixSetSelectMaskedCmap (PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 sindex, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 | pixSetMaskedCmap (PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 rval, l_int32 gval, l_int32 bval) |
l_int32 addColorizedGrayToCmap | ( | PIXCMAP * | cmap, |
l_int32 | type, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
NUMA ** | pna | ||
) |
Input: cmap (from 2 or 4 bpp pix) type (L_PAINT_LIGHT, L_PAINT_DARK) rval, gval, bval (target color) &na (<optional return>=""> table for mapping new cmap entries) Return: 0 if OK; 1 on error; 2 if new colors will not fit in cmap.
Notes: (1) If type == L_PAINT_LIGHT, it colorizes non-black pixels, preserving antialiasing. If type == L_PAINT_DARK, it colorizes non-white pixels, preserving antialiasing. (2) This increases the colormap size by the number of different gray (non-black or non-white) colors in the input colormap. If there is not enough room in the colormap for this expansion, it returns 1 (treated as a warning); the caller should check the return value. (3) This can be used to determine if the new colors will fit in the cmap, using null for &na. Returns 0 if they fit; 2 if they don't fit. (4) The mapping table contains, for each gray color found, the index of the corresponding colorized pixel. Non-gray pixels are assigned the invalid index 256. (5) See pixColorGrayCmap() for usage.
l_int32 pixColorGrayCmap | ( | PIX * | pixs, |
BOX * | box, | ||
l_int32 | type, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (2, 4 or 8 bpp, with colormap) box (<optional> region to set color; can be NULL) type (L_PAINT_LIGHT, L_PAINT_DARK) rval, gval, bval (target color) Return: 0 if OK, 1 on error
Notes: (1) This is an in-place operation. (2) If type == L_PAINT_LIGHT, it colorizes non-black pixels, preserving antialiasing. If type == L_PAINT_DARK, it colorizes non-white pixels, preserving antialiasing. (3) box gives the region to apply color; if NULL, this colorizes the entire image. (4) If the cmap is only 2 or 4 bpp, pixs is converted in-place to an 8 bpp cmap. A 1 bpp cmap is not a valid input pix. (5) This can also be called through pixColorGray(). (6) This operation increases the colormap size by the number of different gray (non-black or non-white) colors in the input colormap. If there is not enough room in the colormap for this expansion, it returns 1 (error), and the caller should check the return value. (7) Using the darkness of each original pixel in the rect, it generates a new color (based on the input rgb values). If type == L_PAINT_LIGHT, the new color is a (generally) darken-to-black version of the input rgb color, where the amount of darkening increases with the darkness of the original pixel color. If type == L_PAINT_DARK, the new color is a (generally) faded-to-white version of the input rgb color, where the amount of fading increases with the brightness of the original pixel color.
l_int32 pixColorGrayMaskedCmap | ( | PIX * | pixs, |
PIX * | pixm, | ||
l_int32 | type, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (8 bpp, with colormap) pixm (1 bpp mask, through which to apply color) type (L_PAINT_LIGHT, L_PAINT_DARK) rval, gval, bval (target color) Return: 0 if OK, 1 on error
Notes: (1) This is an in-place operation. (2) If type == L_PAINT_LIGHT, it colorizes non-black pixels, preserving antialiasing. If type == L_PAINT_DARK, it colorizes non-white pixels, preserving antialiasing. See pixColorGrayCmap() for details. (3) This increases the colormap size by the number of different gray (non-black or non-white) colors in the input colormap. If there is not enough room in the colormap for this expansion, it returns 1 (error).
l_int32 pixColorGrayRegionsCmap | ( | PIX * | pixs, |
BOXA * | boxa, | ||
l_int32 | type, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (8 bpp, with colormap) boxa (of regions in which to apply color) type (L_PAINT_LIGHT, L_PAINT_DARK) rval, gval, bval (target color) Return: 0 if OK, 1 on error
Notes: (1) This is an in-place operation. (2) If type == L_PAINT_LIGHT, it colorizes non-black pixels, preserving antialiasing. If type == L_PAINT_DARK, it colorizes non-white pixels, preserving antialiasing. See pixColorGrayCmap() for details. (3) This can also be called through pixColorGrayRegions(). (4) This increases the colormap size by the number of different gray (non-black or non-white) colors in the selected regions of pixs. If there is not enough room in the colormap for this expansion, it returns 1 (error), and the caller should check the return value. (5) Because two boxes in the boxa can overlap, pixels that are colorized in the first box must be excluded in the second because their value exceeds the size of the map.
l_int32 pixSetMaskedCmap | ( | PIX * | pixs, |
PIX * | pixm, | ||
l_int32 | x, | ||
l_int32 | y, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (2, 4 or 8 bpp, colormapped) pixm (<optional> 1 bpp mask; no-op if NULL) x, y (origin of pixm relative to pixs; can be negative) rval, gval, bval (new color to set at each masked pixel) Return: 0 if OK; 1 on error
Notes: (1) This is an in-place operation. (2) It paints a single color through the mask (as a stencil). (3) The mask origin is placed at (x,y) on pixs, and the operation is clipped to the intersection of the mask and pixs. (4) If pixm == NULL, a warning is given. (5) Typically, pixm is a small binary mask located somewhere on the larger pixs. (6) If the color is in the colormap, it is used. Otherwise, it is added if possible; an error is returned if the colormap is already full.
l_int32 pixSetSelectCmap | ( | PIX * | pixs, |
BOX * | box, | ||
l_int32 | sindex, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (1, 2, 4 or 8 bpp, with colormap) box (<optional> region to set color; can be NULL) sindex (colormap index of pixels to be changed) rval, gval, bval (new color to paint) Return: 0 if OK, 1 on error
Note: (1) This is an in-place operation. (2) It sets all pixels in region that have the color specified by the colormap index 'sindex' to the new color. (3) sindex must be in the existing colormap; otherwise an error is returned. (4) If the new color exists in the colormap, it is used; otherwise, it is added to the colormap. If it cannot be added because the colormap is full, an error is returned. (5) If box is NULL, applies function to the entire image; otherwise, clips the operation to the intersection of the box and pix. (6) An example of use would be to set to a specific color all the light (background) pixels within a certain region of a 3-level 2 bpp image, while leaving light pixels outside this region unchanged.
l_int32 pixSetSelectMaskedCmap | ( | PIX * | pixs, |
PIX * | pixm, | ||
l_int32 | x, | ||
l_int32 | y, | ||
l_int32 | sindex, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pixs (2, 4 or 8 bpp, with colormap) pixm (<optional> 1 bpp mask; no-op if NULL) x, y (UL corner of mask relative to pixs) sindex (colormap index of pixels in pixs to be changed) rval, gval, bval (new color to substitute) Return: 0 if OK, 1 on error
Note: (1) This is an in-place operation. (2) This paints through the fg of pixm and replaces all pixels in pixs that have a particular value (sindex) with the new color. (3) If pixm == NULL, a warning is given. (4) sindex must be in the existing colormap; otherwise an error is returned. (5) If the new color exists in the colormap, it is used; otherwise, it is added to the colormap. If the colormap is full, an error is returned.