src/bmf.c
static l_int32
pixGetTextBaseline(PIX      *pixs,
                   l_int32  *tab8,
                   l_int32  *py)
{
l_int32   i, h, val1, val2, diff, diffmax, ymax;
l_int32  *tab;
NUMA     *na;

    PROCNAME("pixGetTextBaseline");

    if (!pixs)
        return ERROR_INT("pixs not defined", procName, 1);
    if (!py)
        return ERROR_INT("&y not defined", procName, 1);
    *py = 0;
    if (!tab8)
        tab = makePixelSumTab8();
    else
        tab = tab8;

    na = pixCountPixelsByRow(pixs, tab);
    h = numaGetCount(na);
    diffmax = 0;
    ymax = 0;
    for (i = 1; i < h; i++) {
        numaGetIValue(na, i - 1, &val1);
        numaGetIValue(na, i, &val2);
        diff = L_MAX(0, val1 - val2);
        if (diff > diffmax) {
            diffmax = diff;
            ymax = i - 1;  /* upper raster line */
        }
    }
    *py = ymax;

    if (!tab8)
        FREE(tab);
    numaDestroy(&na);
    return 0;
}
/*!
 *  pixGetTextBaseline()
 *
 *      Input:  pixs (1 bpp, one textline character set)
 *              tab8 (<optional> pixel sum table)
 *              &y   (<return> baseline value)
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) Method: find the largest difference in pixel sums from one
 *          raster line to the next one below it.  The baseline is the
 *          upper raster line for the pair of raster lines that
 *          maximizes this function.
 */
pixGetTextBaseline()
Input:  pixs (1 bpp, one textline character set)
tab8 ( pixel sum table)
&y   ( baseline value)
Return: 0 if OK, 1 on error

(1) Method: find the largest difference in pixel sums from one
raster line to the next one below it.  The baseline is the
upper raster line for the pair of raster lines that
maximizes this function.
pixGetTextBaseline () Input : pixs ( 1 bpp one textline character set ) tab8 ( pixel sum table ) &y ( baseline value ) Return : 0 if OK 1 on error ( 1 ) Method : find the largest difference in pixel sums from one raster line to the next one below it . The baseline is the upper raster line for the pair of raster lines that maximizes this function .
static l_int32
pixGetTextBaseline(PIX      *pixs,
                   l_int32  *tab8,
                   l_int32  *py)
{
l_int32   i, h, val1, val2, diff, diffmax, ymax;
l_int32  *tab;
NUMA     *na;
    PROCNAME("pixGetTextBaseline");
    if (!pixs)
        return ERROR_INT("pixs not defined", procName, 1);
    if (!py)
        return ERROR_INT("&y not defined", procName, 1);
    *py = 0;
    if (!tab8)
        tab = makePixelSumTab8();
    else
        tab = tab8;
    na = pixCountPixelsByRow(pixs, tab);
    h = numaGetCount(na);
    diffmax = 0;
    ymax = 0;
    for (i = 1; i < h; i++) {
        numaGetIValue(na, i - 1, &val1);
        numaGetIValue(na, i, &val2);
        diff = L_MAX(0, val1 - val2);
        if (diff > diffmax) {
            diffmax = diff;
            ymax = i - 1;  
        }
    }
    *py = ymax;
    if (!tab8)
        FREE(tab);
    numaDestroy(&na);
    return 0;
}
static l_int32 pixGetTextBaseline ( PIX * pixs , l_int32 * tab8 , l_int32 * py ) { l_int32 i , h , val1 , val2 , diff , diffmax , ymax ; l_int32 * tab ; NUMA * na ; PROCNAME ( " " ) ; if ( ! pixs ) return ERROR_INT ( " " , procName , 1 ) ; if ( ! py ) return ERROR_INT ( " " , procName , 1 ) ; * py = 0 ; if ( ! tab8 ) tab = makePixelSumTab8 ( ) ; else tab = tab8 ; na = pixCountPixelsByRow ( pixs , tab ) ; h = numaGetCount ( na ) ; diffmax = 0 ; ymax = 0 ; for ( i = 1 ; i < h ; i ++ ) { numaGetIValue ( na , i - 1 , & val1 ) ; numaGetIValue ( na , i , & val2 ) ; diff = L_MAX ( 0 , val1 - val2 ) ; if ( diff > diffmax ) { diffmax = diff ; ymax = i - 1 ; } } * py = ymax ; if ( ! tab8 ) FREE ( tab ) ; numaDestroy ( & na ) ; return 0 ; }
pixGetTextBaseline()
      Input:  pixs (1 bpp, one textline character set)
              tab8 (<optional> pixel sum table)
              &y   (<return> baseline value)
      Return: 0 if OK, 1 on error
pixGetTextBaseline () Input : pixs ( 1 bpp one textline character set ) tab8 ( <optional > pixel sum table ) &y ( <return > baseline value ) Return : 0 if OK 1 on error
/* upper raster line */