|
NUMA * | pixFindBaselines (PIX *pixs, PTA **ppta, PIXA *pixadb) |
|
PIX * | pixDeskewLocal (PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta) |
|
l_ok | pixGetLocalSkewTransform (PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, PTA **pptas, PTA **pptad) |
|
NUMA * | pixGetLocalSkewAngles (PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, l_float32 *pa, l_float32 *pb, l_int32 debug) |
|
Locate text baselines in an image
NUMA *pixFindBaselines()
Projective transform to remove local skew
PIX *pixDeskewLocal()
Determine local skew
l_int32 pixGetLocalSkewTransform()
NUMA *pixGetLocalSkewAngles()
We have two apparently different functions here:
~ finding baselines
~ finding a projective transform to remove keystone warping
The function pixGetLocalSkewAngles() returns an array of angles,
one for each raster line, and the baselines of the text lines
should intersect the left edge of the image with that angle.
Definition in file baseline.c.
PIX* pixDeskewLocal |
( |
PIX * |
pixs, |
|
|
l_int32 |
nslices, |
|
|
l_int32 |
redsweep, |
|
|
l_int32 |
redsearch, |
|
|
l_float32 |
sweeprange, |
|
|
l_float32 |
sweepdelta, |
|
|
l_float32 |
minbsdelta |
|
) |
| |
pixDeskewLocal()
- Parameters
-
[in] | pixs | 1 bpp |
[in] | nslices | the number of horizontal overlapping slices; must be larger than 1 and not exceed 20; use 0 for default |
[in] | redsweep | sweep reduction factor: 1, 2, 4 or 8; use 0 for default value |
[in] | redsearch | search reduction factor: 1, 2, 4 or 8, and not larger than redsweep; use 0 for default value |
[in] | sweeprange | half the full range, assumed about 0; in degrees; use 0.0 for default value |
[in] | sweepdelta | angle increment of sweep; in degrees; use 0.0 for default value |
[in] | minbsdelta | min binary search increment angle; in degrees; use 0.0 for default value |
- Returns
- pixd, or NULL on error
Notes:
(1) This function allows deskew of a page whose skew changes
approximately linearly with vertical position. It uses
a projective transform that in effect does a differential
shear about the LHS of the page, and makes all text lines
horizontal.
(2) The origin of the keystoning can be either a cheap document
feeder that rotates the page as it is passed through, or a
camera image taken from either the left or right side
of the vertical.
(3) The image transformation is a projective warping,
not a rotation. Apart from this function, the text lines
must be properly aligned vertically with respect to each
other. This can be done by pre-processing the page; e.g.,
by rotating or horizontally shearing it.
Typically, this can be achieved by vertically aligning
the page edge.
Definition at line 324 of file baseline.c.
pixFindBaselines()
- Parameters
-
[in] | pixs | 1 bpp, 300 ppi |
[out] | ppta | [optional] pairs of pts corresponding to approx. ends of each text line |
[in] | pixadb | for debug output; use NULL to skip |
- Returns
- na of baseline y values, or NULL on error
Notes:
(1) Input binary image must have text lines already aligned
horizontally. This can be done by either rotating the
image with pixDeskew(), or, if a projective transform
is required, by doing pixDeskewLocal() first.
(2) Input null for &pta if you don't want this returned.
The pta will come in pairs of points (left and right end
of each baseline).
(3) Caution: this will not work properly on text with multiple
columns, where the lines are not aligned between columns.
If there are multiple columns, they should be extracted
separately before finding the baselines.
(4) This function constructs different types of output
for baselines; namely, a set of raster line values and
a set of end points of each baseline.
(5) This function was designed to handle short and long text lines
without using dangerous thresholds on the peak heights. It does
this by combining the differential signal with a morphological
analysis of the locations of the text lines. One can also
combine this data to normalize the peak heights, by weighting
the differential signal in the region of each baseline
by the inverse of the width of the text line found there.
Definition at line 117 of file baseline.c.
l_ok pixGetLocalSkewTransform |
( |
PIX * |
pixs, |
|
|
l_int32 |
nslices, |
|
|
l_int32 |
redsweep, |
|
|
l_int32 |
redsearch, |
|
|
l_float32 |
sweeprange, |
|
|
l_float32 |
sweepdelta, |
|
|
l_float32 |
minbsdelta, |
|
|
PTA ** |
pptas, |
|
|
PTA ** |
pptad |
|
) |
| |
pixGetLocalSkewTransform()
- Parameters
-
[in] | pixs | |
[in] | nslices | the number of horizontal overlapping slices; must be larger than 1 and not exceed 20; use 0 for default |
[in] | redsweep | sweep reduction factor: 1, 2, 4 or 8; use 0 for default value |
[in] | redsearch | search reduction factor: 1, 2, 4 or 8, and not larger than redsweep; use 0 for default value |
[in] | sweeprange | half the full range, assumed about 0; in degrees; use 0.0 for default value |
[in] | sweepdelta | angle increment of sweep; in degrees; use 0.0 for default value |
[in] | minbsdelta | min binary search increment angle; in degrees; use 0.0 for default value |
[out] | pptas | 4 points in the source |
[out] | pptad | the corresponding 4 pts in the dest |
- Returns
- 0 if OK, 1 on error
Notes:
(1) This generates two pairs of points in the src, each pair
corresponding to a pair of points that would lie along
the same raster line in a transformed (dewarped) image.
(2) The sets of 4 src and 4 dest points returned by this function
can then be used, in a projective or bilinear transform,
to remove keystoning in the src.
Definition at line 393 of file baseline.c.