src/ptafunc1.c
BOX *
ptaGetBoundingRegion(PTA  *pta)
{
l_int32  n, i, x, y, minx, maxx, miny, maxy;

    PROCNAME("ptaGetBoundingRegion");

    if (!pta)
        return (BOX *)ERROR_PTR("pta not defined", procName, NULL);

    minx = 10000000;
    miny = 10000000;
    maxx = -10000000;
    maxy = -10000000;
    n = ptaGetCount(pta);
    for (i = 0; i < n; i++) {
        ptaGetIPt(pta, i, &x, &y);
        if (x < minx) minx = x;
        if (x > maxx) maxx = x;
        if (y < miny) miny = y;
        if (y > maxy) maxy = y;
    }

    return boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
}
/*!
 *  ptaGetBoundingRegion()
 *
 *      Input:  pta
 *      Return: box, or null on error
 *
 *  Notes:
 *      (1) This is used when the pta represents a set of points in
 *          a two-dimensional image.  It returns the box of minimum
 *          size containing the pts in the pta.
 */
ptaGetBoundingRegion()
Input:  pta
Return: box, or null on error

(1) This is used when the pta represents a set of points in
a two-dimensional image.  It returns the box of minimum
size containing the pts in the pta.
ptaGetBoundingRegion () Input : pta Return : box or null on error ( 1 ) This is used when the pta represents a set of points in a two - dimensional image . It returns the box of minimum size containing the pts in the pta .
BOX *
ptaGetBoundingRegion(PTA  *pta)
{
l_int32  n, i, x, y, minx, maxx, miny, maxy;
    PROCNAME("ptaGetBoundingRegion");
    if (!pta)
        return (BOX *)ERROR_PTR("pta not defined", procName, NULL);
    minx = 10000000;
    miny = 10000000;
    maxx = -10000000;
    maxy = -10000000;
    n = ptaGetCount(pta);
    for (i = 0; i < n; i++) {
        ptaGetIPt(pta, i, &x, &y);
        if (x < minx) minx = x;
        if (x > maxx) maxx = x;
        if (y < miny) miny = y;
        if (y > maxy) maxy = y;
    }
    return boxCreate(minx, miny, maxx - minx + 1, maxy - miny + 1);
}
BOX * ptaGetBoundingRegion ( PTA * pta ) { l_int32 n , i , x , y , minx , maxx , miny , maxy ; PROCNAME ( " " ) ; if ( ! pta ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; minx = 10000000 ; miny = 10000000 ; maxx = -10000000 ; maxy = -10000000 ; n = ptaGetCount ( pta ) ; for ( i = 0 ; i < n ; i ++ ) { ptaGetIPt ( pta , i , & x , & y ) ; if ( x < minx ) minx = x ; if ( x > maxx ) maxx = x ; if ( y < miny ) miny = y ; if ( y > maxy ) maxy = y ; } return boxCreate ( minx , miny , maxx - minx + 1 , maxy - miny + 1 ) ; }
ptaGetBoundingRegion()
      Input:  pta
      Return: box, or null on error
ptaGetBoundingRegion () Input : pta Return : box or null on error