Leptonica
1.54
|
Функции | |
static PIX * | pixFindMinRunsOrthogonal (PIX *pixs, l_float32 angle, l_int32 depth) |
PIX * | pixStrokeWidthTransform (PIX *pixs, l_int32 color, l_int32 depth, l_int32 nangles) |
PIX * | pixRunlengthTransform (PIX *pixs, l_int32 color, l_int32 direction, l_int32 depth) |
l_int32 | pixFindHorizontalRuns (PIX *pix, l_int32 y, l_int32 *xstart, l_int32 *xend, l_int32 *pn) |
l_int32 | pixFindVerticalRuns (PIX *pix, l_int32 x, l_int32 *ystart, l_int32 *yend, l_int32 *pn) |
NUMA * | pixFindMaxRuns (PIX *pix, l_int32 direction, NUMA **pnastart) |
l_int32 | pixFindMaxHorizontalRunOnLine (PIX *pix, l_int32 y, l_int32 *pxstart, l_int32 *psize) |
l_int32 | pixFindMaxVerticalRunOnLine (PIX *pix, l_int32 x, l_int32 *pystart, l_int32 *psize) |
l_int32 | runlengthMembershipOnLine (l_int32 *buffer, l_int32 size, l_int32 depth, l_int32 *start, l_int32 *end, l_int32 n) |
l_int32 * | makeMSBitLocTab (l_int32 bitval) |
l_int32* makeMSBitLocTab | ( | l_int32 | bitval | ) |
Input: bitval (either 0 or 1) Return: table (giving, for an input byte, the MS bit location, starting at 0 with the MSBit in the byte), or null on error.
Notes: (1) If bitval == 1, it finds the leftmost ON pixel in a byte; otherwise if bitval == 0, it finds the leftmost OFF pixel. (2) If there are no pixels of the indicated color in the byte, this returns 8.
l_int32 pixFindHorizontalRuns | ( | PIX * | pix, |
l_int32 | y, | ||
l_int32 * | xstart, | ||
l_int32 * | xend, | ||
l_int32 * | pn | ||
) |
Input: pix (1 bpp) y (line to traverse) xstart (returns array of start positions for fg runs) xend (returns array of end positions for fg runs) &n (<return> the number of runs found) Return: 0 if OK; 1 on error
Notes: (1) This finds foreground horizontal runs on a single scanline. (2) To find background runs, use pixInvert() before applying this function. (3) The xstart and xend arrays are input. They should be of size w/2 + 1 to insure that they can hold the maximum number of runs in the raster line.
pixFindMaxHorizontalRunOnLine()
Input: pix (1 bpp) y (line to traverse) &xstart (<optional return>=""> start position) &size (<return> the size of the run) Return: 0 if OK; 1 on error
Notes: (1) This finds the longest foreground horizontal run on a scanline. (2) To find background runs, use pixInvert() before applying this function.
NUMA* pixFindMaxRuns | ( | PIX * | pix, |
l_int32 | direction, | ||
NUMA ** | pnastart | ||
) |
Input: pix (1 bpp) direction (L_HORIZONTAL_RUNS or L_VERTICAL_RUNS) &nastart (<optional return>=""> start locations of longest runs) Return: na (of lengths of runs), or null on error
Notes: (1) This finds the longest foreground runs by row or column (2) To find background runs, use pixInvert() before applying this function.
Input: pix (1 bpp) x (column to traverse) &ystart (<optional return>=""> start position) &size (<return> the size of the run) Return: 0 if OK; 1 on error
Notes: (1) This finds the longest foreground vertical run on a scanline. (2) To find background runs, use pixInvert() before applying this function.
static PIX * pixFindMinRunsOrthogonal | ( | PIX * | pixs, |
l_float32 | angle, | ||
l_int32 | depth | ||
) | [static] |
Input: pixs (1 bpp) angle (in radians) depth (of pixd: 8 or 16 bpp) Return: pixd (8 or 16 bpp), or null on error
Notes: (1) This computes, for each fg pixel in pixs, the minimum of the runlengths going through that pixel in two orthogonal directions: at and at (90 + ). (2) We use rotation by shear because the forward and backward rotations by the same angle are exact inverse operations. As a result, the nonzero pixels in pixd correspond exactly to the fg pixels in pixs. This is not the case with sampled rotation, due to spatial quantization. Nevertheless, the result suffers from lack of exact correspondence between original and rotated pixels, also due to spatial quantization, causing some boundary pixels to be shifted from bg to fg or v.v.
l_int32 pixFindVerticalRuns | ( | PIX * | pix, |
l_int32 | x, | ||
l_int32 * | ystart, | ||
l_int32 * | yend, | ||
l_int32 * | pn | ||
) |
Input: pix (1 bpp) x (line to traverse) ystart (returns array of start positions for fg runs) yend (returns array of end positions for fg runs) &n (<return> the number of runs found) Return: 0 if OK; 1 on error
Notes: (1) This finds foreground vertical runs on a single scanline. (2) To find background runs, use pixInvert() before applying this function. (3) The ystart and yend arrays are input. They should be of size h/2 + 1 to insure that they can hold the maximum number of runs in the raster line.
Input: pixs (1 bpp) color (0 for white runs, 1 for black runs) direction (L_HORIZONTAL_RUNS, L_VERTICAL_RUNS) depth (8 or 16 bpp) Return: pixd (8 or 16 bpp), or null on error
Notes: (1) The dest Pix is 8 or 16 bpp, with the pixel values equal to the runlength in which it is a member. The length is clipped to the max pixel value if necessary. (2) The color determines if we're labelling white or black runs. (3) A pixel that is not a member of the chosen color gets value 0; it belongs to a run of length 0 of the chosen color. (4) To convert for maximum dynamic range, either linear or log, use pixMaxDynamicRange().
Input: pixs (1 bpp) color (0 for white runs, 1 for black runs) depth (of pixd: 8 or 16 bpp) nangles (2, 4, 6 or 8) Return: pixd (8 or 16 bpp), or null on error
Notes: (1) The dest Pix is 8 or 16 bpp, with the pixel values equal to the stroke width in which it is a member. The values are clipped to the max pixel value if necessary. (2) The color determines if we're labelling white or black strokes. (3) A pixel that is not a member of the chosen color gets value 0; it belongs to a width of length 0 of the chosen color. (4) This chooses, for each dest pixel, the minimum of sets of runlengths through each pixel. Here are the sets: nangles increment set ------- --------- -------------------------------- 2 90 {0, 90} 4 45 {0, 45, 90, 135} 6 30 {0, 30, 60, 90, 120, 150} 8 22.5 {0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5} (5) Runtime scales linearly with (nangles - 2).
l_int32 runlengthMembershipOnLine | ( | l_int32 * | buffer, |
l_int32 | size, | ||
l_int32 | depth, | ||
l_int32 * | start, | ||
l_int32 * | end, | ||
l_int32 | n | ||
) |
Input: buffer (into which full line of data is placed) size (full size of line; w or h) depth (8 or 16 bpp) start (array of start positions for fg runs) end (array of end positions for fg runs) n (the number of runs) Return: 0 if OK; 1 on error
Notes: (1) Converts a set of runlengths into a buffer of runlength membership values. (2) Initialization of the array gives pixels that are not within a run the value 0.