|
Leptonica
1.54
|
Переменные | |
| static const l_int32 | INITIAL_PTR_ARRAYSIZE = 20 |
| static const l_int32 | MAX_PTR_ARRAYSIZE = 10000 |
| static const l_int32 | DEFAULT_ARRAY_SAMPLING = 30 |
| static const l_int32 | MIN_ARRAY_SAMPLING = 8 |
| static const l_int32 | DEFAULT_MIN_LINES = 15 |
| static const l_int32 | MIN_MIN_LINES = 4 |
| static const l_int32 | DEFAULT_MAX_REF_DIST = 16 |
| static const l_int32 | DEFAULT_MAX_LINECURV = 180 |
| static const l_int32 | DEFAULT_MIN_DIFF_LINECURV = 0 |
| static const l_int32 | DEFAULT_MAX_DIFF_LINECURV = 200 |
| static const l_int32 | DEFAULT_MAX_EDGECURV = 50 |
| static const l_int32 | DEFAULT_MAX_DIFF_EDGECURV = 40 |
| static const l_int32 | DEFAULT_MAX_EDGESLOPE = 80 |
| L_DEWARPA* dewarpaCreate | ( | l_int32 | nptrs, |
| l_int32 | sampling, | ||
| l_int32 | redfactor, | ||
| l_int32 | minlines, | ||
| l_int32 | maxdist | ||
| ) |
Input: nptrs (number of dewarp page ptrs; typically the number of pages) sampling (use 0 for default value; the minimum allowed is 8) redfactor (of input images: 1 is full resolution; 2 is 2x reduced) minlines (minimum number of lines to accept; use 0 for default) maxdist (for locating reference disparity; use -1 for default) Return: dewa (or null on error)
Notes: (1) The sampling, minlines and maxdist parameters will be applied to all images. (2) The sampling factor is used for generating the disparity arrays from the input image. For 2x reduced input, use a sampling factor that is half the sampling you want on the full resolution images. (3) Use @redfactor = 1 for full resolution; 2 for 2x reduction. All input images must be at one of these two resolutions. (4) @minlines is the minimum number of nearly full-length lines required to generate a vertical disparity array. The default number is 15. Use a smaller number to accept a questionable array, but not smaller than 4. (5) When a model can't be built for a page, it looks up to @maxdist in either direction for a valid model with the same page parity. Use -1 for the default value of @maxdist; use 0 to avoid using a ref model. (6) The ptr array is expanded as necessary to accommodate page images.
| L_DEWARPA* dewarpaCreateFromPixacomp | ( | PIXAC * | pixac, |
| l_int32 | useboth, | ||
| l_int32 | sampling, | ||
| l_int32 | minlines, | ||
| l_int32 | maxdist | ||
| ) |
Input: pixac (pixacomp of G4, 1 bpp images; with 1x1x1 placeholders) useboth (0 for vert disparity; 1 for both vert and horiz) sampling (use -1 or 0 for default value; otherwise minimum of 5) minlines (minimum number of lines to accept; e.g., 10) maxdist (for locating reference disparity; use -1 for default) Return: dewa (or null on error)
Notes: (1) The returned dewa has disparity arrays calculated and is ready for serialization or for use in dewarping. (2) The sampling, minlines and maxdist parameters are applied to all images. See notes in dewarpaCreate() for details. (3) The pixac is full. Placeholders, if any, are w=h=d=1 images, and the real input images are 1 bpp at full resolution. They are assumed to be cropped to the actual page regions, and may be arbitrarily sparse in the array. (4) The output dewarpa is indexed by the page number. The offset in the pixac gives the mapping between the array index in the pixac and the page number. (5) This adds the ref page models. (6) This can be used to make models for any desired set of pages. The direct models are only made for pages with images in the pixacomp; the ref models are made for pages of the same parity within @maxdist of the nearest direct model.
| void dewarpaDestroy | ( | L_DEWARPA ** | pdewa | ) |
Input: &dewa (<will be set to null before returning>) Return: void
Input: dewa
pageno (of dew to be destroyed)
Return: 0 if OK, 1 on error
Input: dewa
size (new size of dewarpa array)
Return: 0 if OK; 1 on error
Notes: (1) If necessary, reallocs main and cache dewarpa ptr arrays to @size.
Input: dewa (populated with dewarp structs for pages)
index (into dewa: this is the pageno)
Return: dew (handle; still owned by dewa), or null on error
Input: dewarpa
dewarp (to be added)
Return: 0 if OK, 1 on error
Notes: (1) This inserts the dewarp into the array, which now owns it. It also keeps track of the largest page number stored. It must be done before the disparity model is built. (2) Note that this differs from the usual method of filling out arrays in leptonica, where the arrays are compact and new elements are typically added to the end. Here, the dewarp can be added anywhere, even beyond the initial allocation.
| L_DEWARPA* dewarpaRead | ( | const char * | filename | ) |
Input: filename Return: dewa, or null on error
| L_DEWARPA* dewarpaReadStream | ( | FILE * | fp | ) |
Input: stream Return: dewa, or null on error
Notes: (1) The serialized dewarp contains a Numa that gives the (increasing) page number of the dewarp structs that are contained. (2) Reference pages are added in after readback.
| l_int32 dewarpaSetCurvatures | ( | L_DEWARPA * | dewa, |
| l_int32 | max_linecurv, | ||
| l_int32 | min_diff_linecurv, | ||
| l_int32 | max_diff_linecurv, | ||
| l_int32 | max_edgecurv, | ||
| l_int32 | max_diff_edgecurv, | ||
| l_int32 | max_edgeslope | ||
| ) |
Input: dewa
max_linecurv (-1 for default)
min_diff_linecurv (-1 for default; 0 to accept all models)
max_diff_linecurv (-1 for default)
max_edgecurv (-1 for default)
max_diff_edgecurv (-1 for default)
max_edgeslope (-1 for default)
Return: 0 if OK, 1 on error
Notes: (1) Approximating the line by a quadratic, the coefficent of the quadratic term is the curvature, and distance units are in pixels (of course). The curvature is very small, so we multiply by 10^6 and express the constraints on the model curvatures in micro-units. (2) This sets five curvature thresholds and a slope threshold:
Input: dewa
maxdist (for using ref models)
Return: 0 if OK, 1 on error
Notes: (1) This sets the maxdist field.
Input: dewa
useboth (0 for false, 1 for true)
Return: 0 if OK, 1 on error
Notes: (1) This sets the useboth field. If set, this will attempt to apply both vertical and horizontal disparity arrays. Note that a model with only a vertical disparity array will always be valid.
Input: filename
dewa
Return: 0 if OK, 1 on error
Input: stream (opened for "wb")
dewa
Return: 0 if OK, 1 on error
Input: pixs (1 bpp) pageno (page number) Return: dew (or null on error)
Notes: (1) The input pixs is either full resolution or 2x reduced. (2) The page number is typically 0-based. If scanned from a book, the even pages are usually on the left. Disparity arrays built for even pages should only be applied to even pages.
Input: pageno (this page number) refpage (page number of dewarp disparity arrays to be used) Return: dew (or null on error)
Notes: (1) This specifies which dewarp struct should be used for the given page. It is placed in dewarpa for pages for which no model can be built. (2) This page and the reference page have the same parity and the reference page is the closest page with a disparity model to this page.
| void dewarpDestroy | ( | L_DEWARP ** | pdew | ) |
Input: &dew (<will be set to null before returning>) Return: void
| L_DEWARP* dewarpRead | ( | const char * | filename | ) |
Input: filename Return: dew, or null on error
| L_DEWARP* dewarpReadStream | ( | FILE * | fp | ) |
Input: stream Return: dew, or null on error
Notes: (1) The dewarp struct is stored in minimized format, with only subsampled disparity arrays. (2) The sampling and extra horizontal disparity parameters are stored here. During generation of the dewarp struct, they are passed in from the dewarpa. In readback, it is assumed that they are (a) the same for each page and (b) the same as the values used to create the dewarpa.
Input: filename
dew
Return: 0 if OK, 1 on error
Input: stream (opened for "wb")
dew
Return: 0 if OK, 1 on error
Notes: (1) This should not be written if there is no sampled vertical disparity array, which means that no model has been built for this page.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |