![]() |
Leptonica 1.85.0
Image processing and image analysis suite
|
#include <string.h>#include <math.h>#include "allheaders.h"Go to the source code of this file.
Functions | |
| 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_ok | pixFindHorizontalRuns (PIX *pix, l_int32 y, l_int32 *xstart, l_int32 *xend, l_int32 *pn) |
| l_ok | 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_ok | pixFindMaxHorizontalRunOnLine (PIX *pix, l_int32 y, l_int32 *pxstart, l_int32 *psize) |
| l_ok | pixFindMaxVerticalRunOnLine (PIX *pix, l_int32 x, l_int32 *pystart, l_int32 *psize) |
| l_ok | 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) |
Label pixels by membership in runs
PIX *pixStrokeWidthTransform()
static PIX *pixFindMinRunsOrthogonal()
PIX *pixRunlengthTransform()
Find runs along horizontal and vertical lines
l_int32 pixFindHorizontalRuns()
l_int32 pixFindVerticalRuns()
Find max runs along horizontal and vertical lines
l_int32 pixFindMaxRuns()
l_int32 pixFindMaxHorizontalRunOnLine()
l_int32 pixFindMaxVerticalRunOnLine()
Compute runlength-to-membership transform on a line
l_int32 runlengthMembershipOnLine()
Make byte position LUT
l_int32 makeMSBitLocTab()
Here we're handling runs of either black or white pixels on 1 bpp
images. The directions of the runs in the stroke width transform
are selectable from given sets of angles. Most of the other runs
are oriented either horizontally along the raster lines or
vertically along pixel columns.
Definition in file runlength.c.
| l_int32 * makeMSBitLocTab | ( | l_int32 | bitval | ) |
| [in] | bitval | either 0 or 1 |
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.
Definition at line 774 of file runlength.c.
| l_ok pixFindHorizontalRuns | ( | PIX * | pix, |
| l_int32 | y, | ||
| l_int32 * | xstart, | ||
| l_int32 * | xend, | ||
| l_int32 * | pn ) |
| [in] | pix | 1 bpp |
| [in] | y | line to traverse |
| [in] | xstart | returns array of start positions for fg runs |
| [in] | xend | returns array of end positions for fg runs |
| [out] | pn | the number of runs found |
Notes:
(1) This finds foreground horizontal runs on a single scanline.
(2) To find background runs, use pixInvert() before applying
this function.
(3) 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.
Definition at line 369 of file runlength.c.
References GET_DATA_BIT.
Referenced by pixRunlengthTransform().
| l_ok pixFindMaxHorizontalRunOnLine | ( | PIX * | pix, |
| l_int32 | y, | ||
| l_int32 * | pxstart, | ||
| l_int32 * | psize ) |
pixFindMaxHorizontalRunOnLine()
| [in] | pix | 1 bpp |
| [in] | y | line to traverse |
| [out] | pxstart | [optional] start position |
| [out] | psize | the size of the run |
Notes:
(1) This finds the longest foreground horizontal run on a scanline.
(2) To find background runs, use pixInvert() before applying
this function.
Definition at line 569 of file runlength.c.
References GET_DATA_BIT.
Referenced by pixFindMaxRuns().
| [in] | pix | 1 bpp |
| [in] | direction | L_HORIZONTAL_RUNS or L_VERTICAL_RUNS |
| [out] | pnastart | [optional] start locations of longest runs |
Notes:
(1) This finds the longest foreground runs by row or column
(2) To find background runs, use pixInvert() before applying
this function.
Definition at line 518 of file runlength.c.
References L_HORIZONTAL_RUNS, L_VERTICAL_RUNS, pixFindMaxHorizontalRunOnLine(), and pixFindMaxVerticalRunOnLine().
| l_ok pixFindMaxVerticalRunOnLine | ( | PIX * | pix, |
| l_int32 | x, | ||
| l_int32 * | pystart, | ||
| l_int32 * | psize ) |
| [in] | pix | 1 bpp |
| [in] | x | column to traverse |
| [out] | pystart | [optional] start position |
| [out] | psize | the size of the run |
Notes:
(1) This finds the longest foreground vertical run on a scanline.
(2) To find background runs, use pixInvert() before applying
this function.
Definition at line 641 of file runlength.c.
References GET_DATA_BIT.
Referenced by pixFindMaxRuns().
| [in] | pixs | 1 bpp |
| [in] | angle | in radians |
| [in] | depth | of pixd: 8 or 16 bpp |
Notes:
(1) This computes, for each fg pixel in pixs, the minimum of
the runlengths going through that pixel in two orthogonal
directions: at angle and at (90 + angle).
(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.
Definition at line 197 of file runlength.c.
References L_BRING_IN_WHITE, L_HORIZONTAL_RUNS, L_VERTICAL_RUNS, PIX_SRC, and pixRunlengthTransform().
Referenced by pixStrokeWidthTransform().
| l_ok pixFindVerticalRuns | ( | PIX * | pix, |
| l_int32 | x, | ||
| l_int32 * | ystart, | ||
| l_int32 * | yend, | ||
| l_int32 * | pn ) |
| [in] | pix | 1 bpp |
| [in] | x | line to traverse |
| [in] | ystart | returns array of start positions for fg runs |
| [in] | yend | returns array of end positions for fg runs |
| [out] | pn | the number of runs found |
Notes:
(1) This finds foreground vertical runs on a single scanline.
(2) To find background runs, use pixInvert() before applying
this function.
(3) 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.
Definition at line 444 of file runlength.c.
References GET_DATA_BIT.
Referenced by pixRunlengthTransform().
| [in] | pixs | 1 bpp |
| [in] | color | 0 for white runs, 1 for black runs |
| [in] | direction | L_HORIZONTAL_RUNS, L_VERTICAL_RUNS |
| [in] | depth | 8 or 16 bpp |
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) 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().
Definition at line 261 of file runlength.c.
References L_HORIZONTAL_RUNS, L_VERTICAL_RUNS, pixFindHorizontalRuns(), pixFindVerticalRuns(), runlengthMembershipOnLine(), SET_DATA_BYTE, and SET_DATA_TWO_BYTES.
Referenced by pixFindMinRunsOrthogonal(), and pixStrokeWidthTransform().
| [in] | pixs | 1 bpp |
| [in] | color | 0 for white runs, 1 for black runs |
| [in] | depth | of pixd: 8 or 16 bpp |
| [in] | nangles | 2, 4, 6 or 8 |
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) 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).
Definition at line 102 of file runlength.c.
References L_HORIZONTAL_RUNS, L_VERTICAL_RUNS, pixFindMinRunsOrthogonal(), and pixRunlengthTransform().
| l_ok runlengthMembershipOnLine | ( | l_int32 * | buffer, |
| l_int32 | size, | ||
| l_int32 | depth, | ||
| l_int32 * | start, | ||
| l_int32 * | end, | ||
| l_int32 | n ) |
| [in] | buffer | into which full line of data is placed |
| [in] | size | full size of line; w or h |
| [in] | depth | 8 or 16 bpp |
| [in] | start | array of start positions for fg runs |
| [in] | end | array of end positions for fg runs |
| [in] | n | the number of runs |
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.
Definition at line 720 of file runlength.c.
Referenced by pixRunlengthTransform().