![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include "allheaders.h"
Go to the source code of this file.
Functions | |
l_ok | pixFindStrokeLength (PIX *pixs, l_int32 *tab8, l_int32 *plength) |
l_ok | pixFindStrokeWidth (PIX *pixs, l_float32 thresh, l_int32 *tab8, l_float32 *pwidth, NUMA **pnahisto) |
NUMA * | pixaFindStrokeWidth (PIXA *pixa, l_float32 thresh, l_int32 *tab8, l_int32 debug) |
PIXA * | pixaModifyStrokeWidth (PIXA *pixas, l_float32 targetw) |
PIX * | pixModifyStrokeWidth (PIX *pixs, l_float32 width, l_float32 targetw) |
PIXA * | pixaSetStrokeWidth (PIXA *pixas, l_int32 width, l_int32 thinfirst, l_int32 connectivity) |
PIX * | pixSetStrokeWidth (PIX *pixs, l_int32 width, l_int32 thinfirst, l_int32 connectivity) |
Operations on 1 bpp images to: (1) measure stroke parameters, such as length and average width (2) change the average stroke width to a given value by eroding or dilating the image. These operations are intended to operate on a single text character, to regularize the stroke width. It is expected that character matching by correlation, as used in the recog application, can often be improved by pre-processing both template and character images to a fixed stroke width. Stroke parameter measurement l_int32 pixFindStrokeLength() l_int32 pixFindStrokeWidth() NUMA *pixaFindStrokeWidth() Stroke width regulation PIXA *pixaModifyStrokeWidth() PIX *pixModifyStrokeWidth() PIXA *pixaSetStrokeWidth() PIX *pixSetStrokeWidth()
Definition in file strokes.c.
[in] | pixa | of 1 bpp images |
[in] | thresh | fractional count threshold relative to distance 1 |
[in] | tab8 | [optional] table for counting fg pixels; can be NULL |
[in] | debug | 1 for debug output; 0 to skip |
Notes: (1) See pixFindStrokeWidth() for details.
Definition at line 212 of file strokes.c.
References L_CLONE, makePixelSumTab8(), numaAddNumber(), numaCreate(), pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixDestroy(), and pixFindStrokeWidth().
Referenced by pixaModifyStrokeWidth().
[in] | pixas | of 1 bpp pix |
[out] | targetw | desired width for strokes in each pix |
Definition at line 258 of file strokes.c.
References L_CLONE, L_INSERT, numaDestroy(), numaGetFValue(), pixaAddPix(), pixaCreate(), pixaFindStrokeWidth(), pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixDestroy(), and pixModifyStrokeWidth().
[in] | pixas | of 1 bpp pix |
[in] | width | set stroke width to this value, in [1 ... 100]. |
[in] | thinfirst | 1 to thin all pix to a skeleton first; 0 to skip |
[in] | connectivity | 4 or 8, to be used if thinfirst == 1 |
Notes: (1) If thinfirst == 1, thin to a skeleton using the specified connectivity. Use thinfirst == 0 if all pix in pixas have already been thinned as far as possible. (2) The image is dilated to the required width. This dilation is not connectivity preserving, so this is typically used in a situation where merging of c.c. in the individual pix is not a problem; e.g., where each pix is a single c.c.
Definition at line 349 of file strokes.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixDestroy(), and pixSetStrokeWidth().
Referenced by recogTrainFromBoot().
l_ok pixFindStrokeLength | ( | PIX * | pixs, |
l_int32 * | tab8, | ||
l_int32 * | plength | ||
) |
[in] | pixs | 1 bpp |
[in] | tab8 | [optional] table for counting fg pixels; can be NULL |
[out] | plength | estimated length of the strokes |
Notes: (1) Returns half the number of fg boundary pixels.
Definition at line 79 of file strokes.c.
References makePixelSumTab8(), pixCountPixels(), pixDestroy(), and pixExtractBoundary().
Referenced by pixFindStrokeWidth().
l_ok pixFindStrokeWidth | ( | PIX * | pixs, |
l_float32 | thresh, | ||
l_int32 * | tab8, | ||
l_float32 * | pwidth, | ||
NUMA ** | pnahisto | ||
) |
[in] | pixs | 1 bpp |
[in] | thresh | fractional count threshold relative to distance 1 |
[in] | tab8 | [optional] table for counting fg pixels; can be NULL |
[out] | pwidth | estimated width of the strokes |
[out] | pnahisto | [optional] histo of pixel distances from bg |
Notes: (1) This uses two methods to estimate the stroke width: (a) half the fg boundary length (b) a value derived from the histogram of the fg distance transform (2) Distance is measured in 8-connected (3) thresh is the minimum fraction N(dist=d)/N(dist=1) of pixels required to determine if the pixels at distance d are above the noise. It is typically about 0.15.
Definition at line 127 of file strokes.c.
References makePixelSumTab8(), pixCountPixels(), pixDistanceFunction(), and pixFindStrokeLength().
Referenced by pixaFindStrokeWidth().
[in] | pixs | of 1 bpp pix |
[in] | width | measured average stroke width |
[in] | targetw | desired stroke width |
Definition at line 302 of file strokes.c.
Referenced by pixaModifyStrokeWidth().
[in] | pixs | 1 bpp |
[in] | width | set stroke width to this value, in [1 ... 100]. |
[in] | thinfirst | 1 to thin all pix to a skeleton first; 0 to skip |
[in] | connectivity | 4 or 8, to be used if thinfirst == 1 |
Notes: (1) See notes in pixaSetStrokeWidth(). (2) A white border of sufficient width to avoid boundary artifacts in the thickening step is added before thinning. (3) connectivity == 8 usually gives a slightly smoother result.
Definition at line 401 of file strokes.c.
Referenced by pixaSetStrokeWidth(), and recogModifyTemplate().