![]() |
Leptonica 1.85.0
Image processing and image analysis suite
|
#include <math.h>#include "allheaders.h"Go to the source code of this file.
Functions | |
| static l_int32 | dewarpaApplyInit (L_DEWARPA *dewa, l_int32 pageno, PIX *pixs, l_int32 x, l_int32 y, L_DEWARP **pdew, const char *debugfile) |
| static PIX * | pixApplyVertDisparity (L_DEWARP *dew, PIX *pixs, l_int32 grayin) |
| static PIX * | pixApplyHorizDisparity (L_DEWARP *dew, PIX *pixs, l_int32 grayin) |
| static BOXA * | boxaApplyDisparity (L_DEWARP *dew, BOXA *boxa, l_int32 direction, l_int32 mapdir) |
| l_ok | dewarpaApplyDisparity (L_DEWARPA *dewa, l_int32 pageno, PIX *pixs, l_int32 grayin, l_int32 x, l_int32 y, PIX **ppixd, const char *debugfile) |
| l_ok | dewarpaApplyDisparityBoxa (L_DEWARPA *dewa, l_int32 pageno, PIX *pixs, BOXA *boxas, l_int32 mapdir, l_int32 x, l_int32 y, BOXA **pboxad, const char *debugfile) |
| l_ok | dewarpMinimize (L_DEWARP *dew) |
| l_ok | dewarpPopulateFullRes (L_DEWARP *dew, PIX *pix, l_int32 x, l_int32 y) |
Applying and stripping the page disparity model
Apply disparity array to pix
l_int32 dewarpaApplyDisparity()
static l_int32 dewarpaApplyInit()
static PIX *pixApplyVertDisparity()
static PIX *pixApplyHorizDisparity()
Apply disparity array to boxa
l_int32 dewarpaApplyDisparityBoxa()
static BOXA *boxaApplyDisparity()
Stripping out data and populating full res disparity
l_int32 dewarpMinimize()
l_int32 dewarpPopulateFullRes()
Static functions not presently in use
static FPIX *fpixSampledDisparity()
static FPIX *fpixExtraHorizDisparity()
Definition in file dewarp3.c.
|
static |
| [in] | dew | |
| [in] | boxa | |
| [in] | direction | L_HORIZ or L_VERT |
| [in] | mapdir | 1 if mapping forward from original to dewarped; 0 if backward |
Definition at line 635 of file dewarp3.c.
References L_Dewarp::fullhdispar, L_Dewarp::fullvdispar, L_COPY, and L_INSERT.
Referenced by dewarpaApplyDisparityBoxa().
| l_ok dewarpaApplyDisparity | ( | L_DEWARPA * | dewa, |
| l_int32 | pageno, | ||
| PIX * | pixs, | ||
| l_int32 | grayin, | ||
| l_int32 | x, | ||
| l_int32 | y, | ||
| PIX ** | ppixd, | ||
| const char * | debugfile ) |
| [in] | dewa | |
| [in] | pageno | of page model to be used; may be a ref model |
| [in] | pixs | image to be modified; can be 1, 8 or 32 bpp |
| [in] | grayin | gray value, from 0 to 255, for pixels brought in; use -1 to use pixels on the boundary of pixs |
| [in] | x,y | origin for generation of disparity arrays |
| [out] | ppixd | disparity corrected image |
| [in] | debugfile | use NULL to skip writing this |
Notes:
(1) This applies the disparity arrays to the specified image.
(2) Specify gray color for pixels brought in from the outside:
0 is black, 255 is white. Use -1 to select pixels from the
boundary of the source image.
(3) If the models and ref models have not been validated, this
will do so by calling dewarpaInsertRefModels().
(4) This works with both stripped and full resolution page models.
If the full res disparity array(s) are missing, they are remade.
(5) The caller must handle errors that are returned because there
are no valid models or ref models for the page -- typically
by using the input pixs.
(6) If there is no model for pageno, this will use the model for
'refpage' and put the result in the dew for pageno.
(7) This populates the full resolution disparity arrays if
necessary. If x and/or y are positive, they are used,
in conjunction with pixs, to determine the required
slope-based extension of the full resolution disparity
arrays in each direction. When (x,y) == (0,0), all
extension is to the right and down. Nonzero values of (x,y)
are useful for dewarping when pixs is deliberately undercropped.
(8) Important: when applying disparity to a number of images,
after calling this function and saving the resulting pixd,
you should call dewarpMinimize(dew) on the dew for pageno.
This will remove pixs and pixd (or their clones) stored in dew,
as well as the full resolution disparity arrays. Together,
these hold approximately 16 bytes for each pixel in pixs.
Definition at line 116 of file dewarp3.c.
References dewarpaApplyInit(), dewarpMinimize(), L_Dewarp::hsuccess, L_Dewarp::hvalid, pixApplyHorizDisparity(), pixApplyVertDisparity(), L_Dewarp::skip_horiz, and L_Dewarpa::useboth.
| l_ok dewarpaApplyDisparityBoxa | ( | L_DEWARPA * | dewa, |
| l_int32 | pageno, | ||
| PIX * | pixs, | ||
| BOXA * | boxas, | ||
| l_int32 | mapdir, | ||
| l_int32 | x, | ||
| l_int32 | y, | ||
| BOXA ** | pboxad, | ||
| const char * | debugfile ) |
| [in] | dewa | |
| [in] | pageno | of page model to be used; may be a ref model |
| [in] | pixs | initial pix reference; for alignment and debugging |
| [in] | boxas | boxa to be mapped |
| [in] | mapdir | 1 if mapping forward from original to dewarped; 0 if backward |
| [in] | x,y | origin for generation of disparity arrays with respect to the source region |
| [out] | pboxad | disparity corrected boxa |
| [in] | debugfile | use NULL to skip writing this |
Notes:
(1) This applies the disparity arrays in one of two mapping directions
to the specified boxa. It can be used in the backward direction
to locate a box in the original coordinates that would have
been dewarped to to the specified image.
(2) If there is no model for pageno, this will use the model for
'refpage' and put the result in the dew for pageno.
(3) This works with both stripped and full resolution page models.
If the full res disparity array(s) are missing, they are remade.
(4) If an error occurs, a copy of the input boxa is returned.
Definition at line 531 of file dewarp3.c.
References boxaApplyDisparity(), dewarpaApplyInit(), dewarpMinimize(), L_Dewarp::hsuccess, L_Dewarp::hvalid, L_CLONE, pixApplyHorizDisparity(), pixApplyVertDisparity(), L_Dewarp::skip_horiz, and L_Dewarpa::useboth.
|
static |
| [in] | dewa | |
| [in] | pageno | of page model to be used; may be a ref model |
| [in] | pixs | image to be modified; can be 1, 8 or 32 bpp |
| [in] | x,y | origin for generation of disparity arrays |
| [out] | pdew | dewarp to be used for this page |
| [in] | debugfile | use NULL to skip writing this |
Notes:
(1) This prepares pixs for being dewarped. It returns 1 if
no dewarping model exists.
(2) The returned dew contains the model to be used for this page
image. The dew is owned by dewa; do not destroy.
(3) If both the 'useboth' and 'check_columns' fields are true,
this checks for multiple text columns and if found, sets
the 'skip_horiz' field in the dew for this page.
Definition at line 214 of file dewarp3.c.
References L_Dewarpa::check_columns, dewarpPopulateFullRes(), L_Dewarp::hasref, L_Dewarpa::maxpage, L_Dewarpa::modelsready, L_Dewarp::refpage, L_Dewarp::skip_horiz, L_Dewarpa::useboth, and L_Dewarp::vvalid.
Referenced by dewarpaApplyDisparity(), and dewarpaApplyDisparityBoxa().
| l_ok dewarpMinimize | ( | L_DEWARP * | dew | ) |
| [in] | dew |
Notes:
(1) This removes all data that is not needed for serialization.
It keeps the subsampled disparity array(s), so the full
resolution arrays can be reconstructed.
Definition at line 719 of file dewarp3.c.
References L_Dewarp::dewa, L_Dewarp::fullhdispar, L_Dewarp::fullvdispar, L_Dewarp::hasref, L_Dewarp::nacurves, L_Dewarp::namidys, L_Dewarp::pixs, and L_Dewarp::refpage.
Referenced by dewarpaApplyDisparity(), and dewarpaApplyDisparityBoxa().
| [in] | dew | |
| [in] | pix | [optional], to give size of actual image |
| [in] | x,y | origin for generation of disparity arrays |
Notes:
(1) If the full resolution vertical and horizontal disparity
arrays do not exist, they are built from the subsampled ones.
(2) If pixs is not given, the size of the arrays is determined
by the original image from which the sampled version was
generated. Any values of (x,y) are ignored.
(3) If pixs is given, the full resolution disparity arrays must
be large enough to accommodate it.
(a) If the arrays do not exist, the value of (x,y) determines
the origin of the full resolution arrays without extension,
relative to pixs. Thus, (x,y) gives the amount of
slope extension in (left, top). The (right, bottom)
extension is then determined by the size of pixs and
(x,y); the values should never be < 0.
(b) If the arrays exist and pixs is too large, the existing
full res arrays are destroyed and new ones are made,
again using (x,y) to determine the extension in the
four directions.
Definition at line 773 of file dewarp3.c.
References L_Dewarp::fullhdispar, L_Dewarp::fullvdispar, L_Dewarp::h, L_Dewarp::nx, L_Dewarp::ny, L_Dewarp::redfactor, L_Dewarp::samphdispar, L_Dewarp::sampling, L_Dewarp::sampvdispar, L_Dewarp::skip_horiz, and L_Dewarp::w.
Referenced by dewarpaApplyInit().
| [in] | dew | |
| [in] | pixs | 1, 8 or 32 bpp |
| [in] | grayin | gray value, from 0 to 255, for pixels brought in; use -1 to use pixels on the boundary of pixs |
Notes:
(1) This applies the horizontal disparity array to the specified
image.
(2) Specify gray color for pixels brought in from the outside:
0 is black, 255 is white. Use -1 to select pixels from the
boundary of the source image.
(3) The input pixs has already been corrected for vertical disparity.
If the horizontal disparity array doesn't exist, this returns
a clone of pixs.
Definition at line 414 of file dewarp3.c.
References L_Dewarp::fullhdispar, GET_DATA_BIT, GET_DATA_BYTE, SET_DATA_BIT, and SET_DATA_BYTE.
Referenced by dewarpaApplyDisparity(), and dewarpaApplyDisparityBoxa().
| [in] | dew | |
| [in] | pixs | 1, 8 or 32 bpp |
| [in] | grayin | gray value, from 0 to 255, for pixels brought in; use -1 to use pixels on the boundary of pixs |
Notes:
(1) This applies the vertical disparity array to the specified
image. For src pixels above the image, we use the pixels
in the first raster line.
(2) Specify gray color for pixels brought in from the outside:
0 is black, 255 is white. Use -1 to select pixels from the
boundary of the source image.
Definition at line 306 of file dewarp3.c.
References L_Dewarp::fullvdispar, GET_DATA_BIT, GET_DATA_BYTE, GET_DATA_FOUR_BYTES, SET_DATA_BIT, and SET_DATA_BYTE.
Referenced by dewarpaApplyDisparity(), and dewarpaApplyDisparityBoxa().