src/jbclass.c
l_int32
jbGetLLCorners(JBCLASSER  *classer)
{
l_int32    i, iclass, n, x1, y1, h;
NUMA      *naclass;
PIX       *pix;
PIXA      *pixat;
PTA       *ptaul, *ptall;

    PROCNAME("jbGetLLCorners");

    if (!classer)
        return ERROR_INT("classer not defined", procName, 1);

    ptaul = classer->ptaul;
    naclass = classer->naclass;
    pixat = classer->pixat;

    ptaDestroy(&classer->ptall);
    n = ptaGetCount(ptaul);
    ptall = ptaCreate(n);
    classer->ptall = ptall;

        /* If the templates were bordered, we would add h - 1 to the UL
         * corner y-value.  However, because the templates to be used
         * here have their borders removed, and the borders are
         * JB_ADDED_PIXELS on each side, we add h - 1 - 2 * JB_ADDED_PIXELS
         * to the UL corner y-value.  */
    for (i = 0; i < n; i++) {
        ptaGetIPt(ptaul, i, &x1, &y1);
        numaGetIValue(naclass, i, &iclass);
        pix = pixaGetPix(pixat, iclass, L_CLONE);
        h = pixGetHeight(pix);
        ptaAddPt(ptall, x1, y1 + h - 1 - 2 * JB_ADDED_PIXELS);
        pixDestroy(&pix);
    }

    return 0;
}
/*!
 *  jbGetLLCorners()
 *
 *      Input:  jbclasser
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) This computes the ptall field, which has the global LL corners,
 *          adjusted for each specific component, so that each component
 *          can be replaced by the template for its class and have the
 *          centroid in the template in the same position as the
 *          centroid of the original connected component. It is important
 *          that this be done properly to avoid a wavy baseline in the result.
 *      (2) It is computed here from the corresponding UL corners, where
 *          the input templates and stored instances are all bordered.
 *          This should be done after all pages have been processed.
 *      (3) For proper substitution, the templates whose LL corners are
 *          placed in these locations must be UN-bordered.
 *          This is available for a realistic jbig2 encoder, which would
 *          (1) encode each template without a border, and (2) encode
 *          the position using the LL corner (rather than the UL
 *          corner) because the difference between y-values
 *          of successive instances is typically close to zero.
 */
jbGetLLCorners()
Input:  jbclasser
Return: 0 if OK, 1 on error

(1) This computes the ptall field, which has the global LL corners,
adjusted for each specific component, so that each component
can be replaced by the template for its class and have the
centroid in the template in the same position as the
centroid of the original connected component. It is important
that this be done properly to avoid a wavy baseline in the result.
(2) It is computed here from the corresponding UL corners, where
the input templates and stored instances are all bordered.
This should be done after all pages have been processed.
(3) For proper substitution, the templates whose LL corners are
placed in these locations must be UN-bordered.
This is available for a realistic jbig2 encoder, which would
(1) encode each template without a border, and (2) encode
the position using the LL corner (rather than the UL
corner) because the difference between y-values
of successive instances is typically close to zero.
jbGetLLCorners () Input : jbclasser Return : 0 if OK 1 on error ( 1 ) This computes the ptall field which has the global LL corners adjusted for each specific component so that each component can be replaced by the template for its class and have the centroid in the template in the same position as the centroid of the original connected component . It is important that this be done properly to avoid a wavy baseline in the result . ( 2 ) It is computed here from the corresponding UL corners where the input templates and stored instances are all bordered . This should be done after all pages have been processed . ( 3 ) For proper substitution the templates whose LL corners are placed in these locations must be UN - bordered . This is available for a realistic jbig2 encoder which would ( 1 ) encode each template without a border and ( 2 ) encode the position using the LL corner ( rather than the UL corner ) because the difference between y - values of successive instances is typically close to zero .
l_int32
jbGetLLCorners(JBCLASSER  *classer)
{
l_int32    i, iclass, n, x1, y1, h;
NUMA      *naclass;
PIX       *pix;
PIXA      *pixat;
PTA       *ptaul, *ptall;
    PROCNAME("jbGetLLCorners");
    if (!classer)
        return ERROR_INT("classer not defined", procName, 1);
    ptaul = classer->ptaul;
    naclass = classer->naclass;
    pixat = classer->pixat;
    ptaDestroy(&classer->ptall);
    n = ptaGetCount(ptaul);
    ptall = ptaCreate(n);
    classer->ptall = ptall;
    for (i = 0; i < n; i++) {
        ptaGetIPt(ptaul, i, &x1, &y1);
        numaGetIValue(naclass, i, &iclass);
        pix = pixaGetPix(pixat, iclass, L_CLONE);
        h = pixGetHeight(pix);
        ptaAddPt(ptall, x1, y1 + h - 1 - 2 * JB_ADDED_PIXELS);
        pixDestroy(&pix);
    }
    return 0;
}
l_int32 jbGetLLCorners ( JBCLASSER * classer ) { l_int32 i , iclass , n , x1 , y1 , h ; NUMA * naclass ; PIX * pix ; PIXA * pixat ; PTA * ptaul , * ptall ; PROCNAME ( " " ) ; if ( ! classer ) return ERROR_INT ( " " , procName , 1 ) ; ptaul = classer -> ptaul ; naclass = classer -> naclass ; pixat = classer -> pixat ; ptaDestroy ( & classer -> ptall ) ; n = ptaGetCount ( ptaul ) ; ptall = ptaCreate ( n ) ; classer -> ptall = ptall ; for ( i = 0 ; i < n ; i ++ ) { ptaGetIPt ( ptaul , i , & x1 , & y1 ) ; numaGetIValue ( naclass , i , & iclass ) ; pix = pixaGetPix ( pixat , iclass , L_CLONE ) ; h = pixGetHeight ( pix ) ; ptaAddPt ( ptall , x1 , y1 + h - 1 - 2 * JB_ADDED_PIXELS ) ; pixDestroy ( & pix ) ; } return 0 ; }
jbGetLLCorners()
      Input:  jbclasser
      Return: 0 if OK, 1 on error
jbGetLLCorners () Input : jbclasser Return : 0 if OK 1 on error
/* If the templates were bordered, we would add h - 1 to the UL
         * corner y-value.  However, because the templates to be used
         * here have their borders removed, and the borders are
         * JB_ADDED_PIXELS on each side, we add h - 1 - 2 * JB_ADDED_PIXELS
         * to the UL corner y-value.  */