src/sel1.c
PIX *
selaDisplayInPix(SELA    *sela,
                 l_int32  size,
                 l_int32  gthick,
                 l_int32  spacing,
                 l_int32  ncols)
{
l_int32  nsels, i, w, width;
PIX     *pixt, *pixd;
PIXA    *pixa;
SEL     *sel;

    PROCNAME("selaDisplayInPix");

    if (!sela)
        return (PIX *)ERROR_PTR("sela not defined", procName, NULL);
    if (size < 13) {
        L_WARNING("size < 13; setting to 13", procName);
        size = 13;
    }
    if (size % 2 == 0)
        size++;
    if (gthick < 2) {
        L_WARNING("grid thickness < 2; setting to 2", procName);
        gthick = 2;
    }
    if (spacing < 5) {
        L_WARNING("spacing < 5; setting to 5", procName);
        spacing = 5;
    }

        /* Accumulate the pix of each sel */
    nsels = selaGetCount(sela);
    pixa = pixaCreate(nsels);
    for (i = 0; i < nsels; i++) {
        sel = selaGetSel(sela, i);
        pixt = selDisplayInPix(sel, size, gthick);
        pixaAddPix(pixa, pixt, L_INSERT);
    }

        /* Find the tiled output width, using just the first
         * ncols pix in the pixa.   If all pix have the same width,
         * they will align properly in columns. */
    width = 0;
    ncols = L_MIN(nsels, ncols);
    for (i = 0; i < ncols; i++) {
        pixt = pixaGetPix(pixa, i, L_CLONE);
        pixGetDimensions(pixt, &w, NULL, NULL);
        width += w;
        pixDestroy(&pixt);
    }
    width += (ncols + 1) * spacing;  /* add spacing all around as well */
    
    pixd = pixaDisplayTiledInRows(pixa, 1, width, 1.0, 0, spacing, 0);
    pixaDestroy(&pixa);
    return pixd;
}
/*!
 *  selaDisplayInPix()
 *
 *      Input:  sela
 *              size (of grid interiors; odd; minimum size of 13 is enforced)
 *              gthick (grid thickness; minimum size of 2 is enforced)
 *              spacing (between sels, both horizontally and vertically)
 *              ncols (number of sels per "line")
 *      Return: pix (display of all sels in sela), or null on error
 *
 *  Notes:
 *      (1) This gives a visual representation of all the sels in a sela.
 *      (2) See notes in selDisplayInPix() for display params of each sel.
 *      (3) This gives the nicest results when all sels in the sela
 *          are the same size.
 */
selaDisplayInPix()
Input:  sela
size (of grid interiors; odd; minimum size of 13 is enforced)
gthick (grid thickness; minimum size of 2 is enforced)
spacing (between sels, both horizontally and vertically)
ncols (number of sels per "line")
Return: pix (display of all sels in sela), or null on error

(1) This gives a visual representation of all the sels in a sela.
(2) See notes in selDisplayInPix() for display params of each sel.
(3) This gives the nicest results when all sels in the sela
are the same size.
selaDisplayInPix () Input : sela size ( of grid interiors ; odd ; minimum size of 13 is enforced ) gthick ( grid thickness ; minimum size of 2 is enforced ) spacing ( between sels both horizontally and vertically ) ncols ( number of sels per " line " ) Return : pix ( display of all sels in sela ) or null on error ( 1 ) This gives a visual representation of all the sels in a sela . ( 2 ) See notes in selDisplayInPix () for display params of each sel . ( 3 ) This gives the nicest results when all sels in the sela are the same size .
PIX *
selaDisplayInPix(SELA    *sela,
                 l_int32  size,
                 l_int32  gthick,
                 l_int32  spacing,
                 l_int32  ncols)
{
l_int32  nsels, i, w, width;
PIX     *pixt, *pixd;
PIXA    *pixa;
SEL     *sel;
    PROCNAME("selaDisplayInPix");
    if (!sela)
        return (PIX *)ERROR_PTR("sela not defined", procName, NULL);
    if (size < 13) {
        L_WARNING("size < 13; setting to 13", procName);
        size = 13;
    }
    if (size % 2 == 0)
        size++;
    if (gthick < 2) {
        L_WARNING("grid thickness < 2; setting to 2", procName);
        gthick = 2;
    }
    if (spacing < 5) {
        L_WARNING("spacing < 5; setting to 5", procName);
        spacing = 5;
    }
    nsels = selaGetCount(sela);
    pixa = pixaCreate(nsels);
    for (i = 0; i < nsels; i++) {
        sel = selaGetSel(sela, i);
        pixt = selDisplayInPix(sel, size, gthick);
        pixaAddPix(pixa, pixt, L_INSERT);
    }
    width = 0;
    ncols = L_MIN(nsels, ncols);
    for (i = 0; i < ncols; i++) {
        pixt = pixaGetPix(pixa, i, L_CLONE);
        pixGetDimensions(pixt, &w, NULL, NULL);
        width += w;
        pixDestroy(&pixt);
    }
    width += (ncols + 1) * spacing;  
    pixd = pixaDisplayTiledInRows(pixa, 1, width, 1.0, 0, spacing, 0);
    pixaDestroy(&pixa);
    return pixd;
}
PIX * selaDisplayInPix ( SELA * sela , l_int32 size , l_int32 gthick , l_int32 spacing , l_int32 ncols ) { l_int32 nsels , i , w , width ; PIX * pixt , * pixd ; PIXA * pixa ; SEL * sel ; PROCNAME ( " " ) ; if ( ! sela ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( size < 13 ) { L_WARNING ( " " , procName ) ; size = 13 ; } if ( size % 2 == 0 ) size ++ ; if ( gthick < 2 ) { L_WARNING ( " " , procName ) ; gthick = 2 ; } if ( spacing < 5 ) { L_WARNING ( " " , procName ) ; spacing = 5 ; } nsels = selaGetCount ( sela ) ; pixa = pixaCreate ( nsels ) ; for ( i = 0 ; i < nsels ; i ++ ) { sel = selaGetSel ( sela , i ) ; pixt = selDisplayInPix ( sel , size , gthick ) ; pixaAddPix ( pixa , pixt , L_INSERT ) ; } width = 0 ; ncols = L_MIN ( nsels , ncols ) ; for ( i = 0 ; i < ncols ; i ++ ) { pixt = pixaGetPix ( pixa , i , L_CLONE ) ; pixGetDimensions ( pixt , & w , NULL , NULL ) ; width += w ; pixDestroy ( & pixt ) ; } width += ( ncols + 1 ) * spacing ; pixd = pixaDisplayTiledInRows ( pixa , 1 , width , 1.0 , 0 , spacing , 0 ) ; pixaDestroy ( & pixa ) ; return pixd ; }
selaDisplayInPix()
      Input:  sela
              size (of grid interiors; odd; minimum size of 13 is enforced)
              gthick (grid thickness; minimum size of 2 is enforced)
              spacing (between sels, both horizontally and vertically)
              ncols (number of sels per "line")
      Return: pix (display of all sels in sela), or null on error
selaDisplayInPix () Input : sela size ( of grid interiors ; odd ; minimum size of 13 is enforced ) gthick ( grid thickness ; minimum size of 2 is enforced ) spacing ( between sels both horizontally and vertically ) ncols ( number of sels per " line " ) Return : pix ( display of all sels in sela ) or null on error
/* Accumulate the pix of each sel */ /* Find the tiled output width, using just the first
         * ncols pix in the pixa.   If all pix have the same width,
         * they will align properly in columns. */ /* add spacing all around as well */