src/dewarp.c
L_DEWARP *
dewarpCreate(PIX     *pixs,
             l_int32  pageno,
             l_int32  sampling,
             l_int32  minlines,
             l_int32  applyhoriz)
{
l_int32    w, h;
L_DEWARP  *dew;

    PROCNAME("dewarpCreate");

    if (!pixs)
        return (L_DEWARP *)ERROR_PTR("pixs not defined", procName, NULL);
    if (pixGetDepth(pixs) != 1)
        return (L_DEWARP *)ERROR_PTR("pixs not 1 bpp", procName, NULL);

    if ((dew = (L_DEWARP *)CALLOC(1, sizeof(L_DEWARP))) == NULL)
        return (L_DEWARP *)ERROR_PTR("dew not made", procName, NULL);
    dew->pixs = pixClone(pixs);

    if (sampling <= 0)
        sampling = L_DEFAULT_SAMPLING;
    else if (sampling < 5) {
         L_WARNING("sampling too small; setting to 5", procName);
         sampling = 5;
    }
    dew->sampling = sampling;
    dew->minlines = minlines;
    dew->applyhoriz = applyhoriz;
    dew->pageno = pageno;

        /* Get the dimensions of the sampled array.  This will be
         * stored in an fpix, and the full resolution version is
         * guaranteed to be larger than pixs. */
    pixGetDimensions(pixs, &w, &h, NULL);
    dew->nx = (w + 2 * sampling - 2) / sampling;
    dew->ny = (h + 2 * sampling - 2) / sampling;
    return dew;
}
/*!
 *  dewarpCreate()
 *
 *     Input: pixs (1 bpp)
 *            pageno (page number)
 *            sampling (use -1 or 0 for default value; otherwise minimum of 5)
 *            minlines (minimum number of lines to accept; e.g., 10)
 *            applyhoriz (1 to estimate horiz disparity; 0 to skip)
 *     Return: dew (or null on error)
 *
 *  Notes:
 *      (1) 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.
 *      (2) The sampling factor is for the disparity array.  The number
 *          used is not critical; anything between 10 and 60 should be fine.
 *      (3) The minimum number of nearly full-length lines required
 *          to generate a vertical disparity array.  Use a small number
 *          if you are willing to accept a questionable array.
 */


(1) 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.
(2) The sampling factor is for the disparity array.  The number
used is not critical; anything between 10 and 60 should be fine.
(3) The minimum number of nearly full-length lines required
to generate a vertical disparity array.  Use a small number
if you are willing to accept a questionable array.
( 1 ) 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 . ( 2 ) The sampling factor is for the disparity array . The number used is not critical ; anything between 10 and 60 should be fine . ( 3 ) The minimum number of nearly full - length lines required to generate a vertical disparity array . Use a small number if you are willing to accept a questionable array .
L_DEWARP *
dewarpCreate(PIX     *pixs,
             l_int32  pageno,
             l_int32  sampling,
             l_int32  minlines,
             l_int32  applyhoriz)
{
l_int32    w, h;
L_DEWARP  *dew;
    PROCNAME("dewarpCreate");
    if (!pixs)
        return (L_DEWARP *)ERROR_PTR("pixs not defined", procName, NULL);
    if (pixGetDepth(pixs) != 1)
        return (L_DEWARP *)ERROR_PTR("pixs not 1 bpp", procName, NULL);
    if ((dew = (L_DEWARP *)CALLOC(1, sizeof(L_DEWARP))) == NULL)
        return (L_DEWARP *)ERROR_PTR("dew not made", procName, NULL);
    dew->pixs = pixClone(pixs);
    if (sampling <= 0)
        sampling = L_DEFAULT_SAMPLING;
    else if (sampling < 5) {
         L_WARNING("sampling too small; setting to 5", procName);
         sampling = 5;
    }
    dew->sampling = sampling;
    dew->minlines = minlines;
    dew->applyhoriz = applyhoriz;
    dew->pageno = pageno;
    pixGetDimensions(pixs, &w, &h, NULL);
    dew->nx = (w + 2 * sampling - 2) / sampling;
    dew->ny = (h + 2 * sampling - 2) / sampling;
    return dew;
}
L_DEWARP * dewarpCreate ( PIX * pixs , l_int32 pageno , l_int32 sampling , l_int32 minlines , l_int32 applyhoriz ) { l_int32 w , h ; L_DEWARP * dew ; PROCNAME ( " " ) ; if ( ! pixs ) return ( L_DEWARP * ) ERROR_PTR ( " " , procName , NULL ) ; if ( pixGetDepth ( pixs ) != 1 ) return ( L_DEWARP * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ( dew = ( L_DEWARP * ) CALLOC ( 1 , sizeof ( L_DEWARP ) ) ) == NULL ) return ( L_DEWARP * ) ERROR_PTR ( " " , procName , NULL ) ; dew -> pixs = pixClone ( pixs ) ; if ( sampling <= 0 ) sampling = L_DEFAULT_SAMPLING ; else if ( sampling < 5 ) { L_WARNING ( " " , procName ) ; sampling = 5 ; } dew -> sampling = sampling ; dew -> minlines = minlines ; dew -> applyhoriz = applyhoriz ; dew -> pageno = pageno ; pixGetDimensions ( pixs , & w , & h , NULL ) ; dew -> nx = ( w + 2 * sampling - 2 ) / sampling ; dew -> ny = ( h + 2 * sampling - 2 ) / sampling ; return dew ; }
dewarpCreate()
     Input: pixs (1 bpp)
            pageno (page number)
            sampling (use -1 or 0 for default value; otherwise minimum of 5)
            minlines (minimum number of lines to accept; e.g., 10)
            applyhoriz (1 to estimate horiz disparity; 0 to skip)
     Return: dew (or null on error)
dewarpCreate () Input : pixs ( 1 bpp ) pageno ( page number ) sampling ( use - 1 or 0 for default value ; otherwise minimum of 5 ) minlines ( minimum number of lines to accept ; e . g . 10 ) applyhoriz ( 1 to estimate horiz disparity ; 0 to skip ) Return : dew ( or null on error )
/* Get the dimensions of the sampled array.  This will be
         * stored in an fpix, and the full resolution version is
         * guaranteed to be larger than pixs. */