Leptonica 1.68
C Image Processing Library
|
Low-level implementation for some grayscale quantiziation functions. More...
Go to the source code of this file.
Low-level implementation for some grayscale quantiziation functions.
Thresholding from 8 bpp to 1 bpp Floyd-Steinberg dithering to binary void ditherToBinaryLow() void ditherToBinaryLineLow() Simple (pixelwise) binarization void thresholdToBinaryLow() void thresholdToBinaryLineLow() A slower version of Floyd-Steinberg dithering that uses LUTs void ditherToBinaryLUTLow() void ditherToBinaryLineLUTLow() l_int32 make8To1DitherTables() Thresholding from 8 bpp to 2 bpp Floyd-Steinberg-like dithering to 2 bpp void ditherTo2bppLow() void ditherTo2bppLineLow() l_int32 make8To2DitherTables() Simple thresholding to 2 bpp void thresholdTo2bppLow() Thresholding from 8 bpp to 4 bpp Simple thresholding to 4 bpp void thresholdTo4bppLow()
Definition in file grayquantlow.c.
#define DEBUG_UNROLLING 0 |
Definition at line 56 of file grayquantlow.c.
void ditherToBinaryLow | ( | l_uint32 * | datad, |
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | wpls, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 | lowerclip, | ||
l_int32 | upperclip | ||
) |
Definition at line 69 of file grayquantlow.c.
References ditherToBinaryLineLow().
Referenced by pixDitherToBinarySpec().
void ditherToBinaryLineLow | ( | l_uint32 * | lined, |
l_int32 | w, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 | lowerclip, | ||
l_int32 | upperclip, | ||
l_int32 | lastlineflag | ||
) |
Definition at line 126 of file grayquantlow.c.
References GET_DATA_BYTE, L_MAX, L_MIN, SET_DATA_BIT, and SET_DATA_BYTE.
Referenced by ditherToBinaryLow(), pixScaleGray2xLIDither(), and pixScaleGray4xLIDither().
void thresholdToBinaryLow | ( | l_uint32 * | datad, |
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | d, | ||
l_int32 | wpls, | ||
l_int32 | thresh | ||
) |
Definition at line 243 of file grayquantlow.c.
References thresholdToBinaryLineLow().
Referenced by pixThresholdToBinary().
void thresholdToBinaryLineLow | ( | l_uint32 * | lined, |
l_int32 | w, | ||
l_uint32 * | lines, | ||
l_int32 | d, | ||
l_int32 | thresh | ||
) |
Definition at line 269 of file grayquantlow.c.
References GET_DATA_BYTE, GET_DATA_QBIT, L_ERROR, and PROCNAME.
Referenced by pixScaleGray2xLIThresh(), pixScaleGray4xLIThresh(), and thresholdToBinaryLow().
void ditherToBinaryLUTLow | ( | l_uint32 * | datad, |
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | wpls, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 * | tabval, | ||
l_int32 * | tab38, | ||
l_int32 * | tab14 | ||
) |
Low-level function for doing Floyd-Steinberg error diffusion dithering from 8 bpp (datas) to 1 bpp (datad). Two source line buffers, bufs1 and bufs2, are provided, along with three 256-entry lookup tables: tabval gives the output pixel value, tab38 gives the extra (plus or minus) transferred to the pixels directly to the left and below, and tab14 gives the extra transferred to the diagonal below. The choice of 3/8 and 1/4 is traditional but arbitrary when you use a lookup table; the only constraint is that the sum is 1. See other comments below.
Definition at line 402 of file grayquantlow.c.
References ditherToBinaryLineLUTLow().
Referenced by pixDitherToBinaryLUT().
void ditherToBinaryLineLUTLow | ( | l_uint32 * | lined, |
l_int32 | w, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 * | tabval, | ||
l_int32 * | tab38, | ||
l_int32 * | tab14, | ||
l_int32 | lastlineflag | ||
) |
Input: lined (ptr to beginning of dest line w (width of image in pixels) bufs1 (buffer of current source line) bufs2 (buffer of next source line) tabval (value to assign for current pixel) tab38 (excess value to give to neighboring 3/8 pixels) tab14 (excess value to give to neighboring 1/4 pixel) lastlineflag (0 if not last dest line, 1 if last dest line) Return: void
Definition at line 449 of file grayquantlow.c.
References GET_DATA_BYTE, L_MAX, L_MIN, SET_DATA_BIT, and SET_DATA_BYTE.
Referenced by ditherToBinaryLUTLow().
l_int32 make8To1DitherTables | ( | l_int32 ** | ptabval, |
l_int32 ** | ptab38, | ||
l_int32 ** | ptab14, | ||
l_int32 | lowerclip, | ||
l_int32 | upperclip | ||
) |
Input: &tabval (value assigned to output pixel; 0 or 1) &tab38 (amount propagated to pixels left and below) &tab14 (amount propagated to pixel to left and down) lowerclip (values near 0 where the excess is not propagated) upperclip (values near 255 where the deficit is not propagated)
Return: 0 if OK, 1 on error
Definition at line 542 of file grayquantlow.c.
References CALLOC, ERROR_INT, NULL, and PROCNAME.
Referenced by pixDitherToBinaryLUT().
void ditherTo2bppLow | ( | l_uint32 * | datad, |
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | wpls, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 * | tabval, | ||
l_int32 * | tab38, | ||
l_int32 * | tab14 | ||
) |
Definition at line 612 of file grayquantlow.c.
References ditherTo2bppLineLow().
Referenced by pixDitherTo2bppSpec().
void ditherTo2bppLineLow | ( | l_uint32 * | lined, |
l_int32 | w, | ||
l_uint32 * | bufs1, | ||
l_uint32 * | bufs2, | ||
l_int32 * | tabval, | ||
l_int32 * | tab38, | ||
l_int32 * | tab14, | ||
l_int32 | lastlineflag | ||
) |
Definition at line 671 of file grayquantlow.c.
References GET_DATA_BYTE, L_MAX, L_MIN, SET_DATA_BYTE, and SET_DATA_DIBIT.
Referenced by ditherTo2bppLow().
l_int32 make8To2DitherTables | ( | l_int32 ** | ptabval, |
l_int32 ** | ptab38, | ||
l_int32 ** | ptab14, | ||
l_int32 | cliptoblack, | ||
l_int32 | cliptowhite | ||
) |
Input: &tabval (value assigned to output pixel; 0, 1, 2 or 3) &tab38 (amount propagated to pixels left and below) &tab14 (amount propagated to pixel to left and down) cliptoblack (values near 0 where the excess is not propagated) cliptowhite (values near 255 where the deficit is not propagated)
Return: 0 if OK, 1 on error
Definition at line 753 of file grayquantlow.c.
References CALLOC, ERROR_INT, NULL, and PROCNAME.
Referenced by pixDitherTo2bppSpec().
void thresholdTo2bppLow | ( | l_uint32 * | datad, |
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | wpls, | ||
l_int32 * | tab | ||
) |
Definition at line 844 of file grayquantlow.c.
References GET_DATA_BYTE, and SET_DATA_BYTE.
Referenced by pixThresholdGrayArb(), and pixThresholdTo2bpp().
void thresholdTo4bppLow | ( | l_uint32 * | datad, |
l_int32 | h, | ||
l_int32 | wpld, | ||
l_uint32 * | datas, | ||
l_int32 | wpls, | ||
l_int32 * | tab | ||
) |
Definition at line 889 of file grayquantlow.c.
References GET_DATA_BYTE, and SET_DATA_TWO_BYTES.
Referenced by pixThresholdGrayArb(), and pixThresholdTo4bpp().