src/sel2.c
SELA *
selaAddBasic(SELA  *sela)
{
char     name[L_BUF_SIZE];
l_int32  i, size;
SEL     *sel;

    PROCNAME("selaAddBasic");

    if (!sela) {
        if ((sela = selaCreate(0)) == NULL)
            return (SELA *)ERROR_PTR("sela not made", procName, NULL);
    }

    /*--------------------------------------------------------------*
     *             Linear horizontal and vertical sels              *
     *--------------------------------------------------------------*/
    for (i = 0; i < num_linear; i++) {
        size = basic_linear[i];
        sel = selCreateBrick(1, size, 0, size / 2, 1);
        snprintf(name, L_BUF_SIZE, "sel_%dh", size);
        selaAddSel(sela, sel, name, 0);
    }
    for (i = 0; i < num_linear; i++) {
        size = basic_linear[i];
        sel = selCreateBrick(size, 1, size / 2, 0, 1);
        snprintf(name, L_BUF_SIZE, "sel_%dv", size);
        selaAddSel(sela, sel, name, 0);
    }

    /*-----------------------------------------------------------*
     *                      2-d Bricks                           *
     *-----------------------------------------------------------*/
    for (i = 2; i <= 5; i++) {
        sel = selCreateBrick(i, i, i / 2, i / 2, 1);
        snprintf(name, L_BUF_SIZE, "sel_%d", i);
        selaAddSel(sela, sel, name, 0);
    }

    /*-----------------------------------------------------------*
     *                        Diagonals                          *
     *-----------------------------------------------------------*/
        /*  0c  1
            1   0  */ 
    sel = selCreateBrick(2, 2, 0, 0, 1);
    selSetElement(sel, 0, 0, 0);
    selSetElement(sel, 1, 1, 0);
    selaAddSel(sela, sel, "sel_2dp", 0);

        /*  1c  0
            0   1   */ 
    sel = selCreateBrick(2, 2, 0, 0, 1);
    selSetElement(sel, 0, 1, 0);
    selSetElement(sel, 1, 0, 0);
    selaAddSel(sela, sel, "sel_2dm", 0);

        /*  Diagonal, slope +, size 5 */
    sel = selCreate(5, 5, "sel_5dp");
    sel->cy = 2;
    sel->cx = 2;
    selSetElement(sel, 0, 4, 1);
    selSetElement(sel, 1, 3, 1);
    selSetElement(sel, 2, 2, 1);
    selSetElement(sel, 3, 1, 1);
    selSetElement(sel, 4, 0, 1);
    selaAddSel(sela, sel, "sel_5dp", 0);

        /*  Diagonal, slope -, size 5 */
    sel = selCreate(5, 5, "sel_5dm");
    sel->cy = 2;
    sel->cx = 2;
    selSetElement(sel, 0, 0, 1);
    selSetElement(sel, 1, 1, 1);
    selSetElement(sel, 2, 2, 1);
    selSetElement(sel, 3, 3, 1);
    selSetElement(sel, 4, 4, 1);
    selaAddSel(sela, sel, "sel_5dm", 0);

    return sela;
}
/*! 
 *  selaAddBasic()
 *
 *      Input:  sela (<optional>)
 *      Return: sela with additional sels, or null on error
 *
 *  Notes:
 *      (1) Adds the following sels:
 *            - all linear (horiz, vert) brick sels that are
 *              necessary for decomposable sels up to size 63
 *            - square brick sels up to size 10
 *            - 4 diagonal sels
 */
selaAddBasic()
Input:  sela ()
Return: sela with additional sels, or null on error

(1) Adds the following sels:
- all linear (horiz, vert) brick sels that are
necessary for decomposable sels up to size 63
- square brick sels up to size 10
- 4 diagonal sels
selaAddBasic () Input : sela () Return : sela with additional sels or null on error ( 1 ) Adds the following sels : - all linear ( horiz vert ) brick sels that are necessary for decomposable sels up to size 63 - square brick sels up to size 10 - 4 diagonal sels
SELA *
selaAddBasic(SELA  *sela)
{
char     name[L_BUF_SIZE];
l_int32  i, size;
SEL     *sel;
    PROCNAME("selaAddBasic");
    if (!sela) {
        if ((sela = selaCreate(0)) == NULL)
            return (SELA *)ERROR_PTR("sela not made", procName, NULL);
    }
    for (i = 0; i < num_linear; i++) {
        size = basic_linear[i];
        sel = selCreateBrick(1, size, 0, size / 2, 1);
        snprintf(name, L_BUF_SIZE, "sel_%dh", size);
        selaAddSel(sela, sel, name, 0);
    }
    for (i = 0; i < num_linear; i++) {
        size = basic_linear[i];
        sel = selCreateBrick(size, 1, size / 2, 0, 1);
        snprintf(name, L_BUF_SIZE, "sel_%dv", size);
        selaAddSel(sela, sel, name, 0);
    }
    for (i = 2; i <= 5; i++) {
        sel = selCreateBrick(i, i, i / 2, i / 2, 1);
        snprintf(name, L_BUF_SIZE, "sel_%d", i);
        selaAddSel(sela, sel, name, 0);
    }
    sel = selCreateBrick(2, 2, 0, 0, 1);
    selSetElement(sel, 0, 0, 0);
    selSetElement(sel, 1, 1, 0);
    selaAddSel(sela, sel, "sel_2dp", 0);
    sel = selCreateBrick(2, 2, 0, 0, 1);
    selSetElement(sel, 0, 1, 0);
    selSetElement(sel, 1, 0, 0);
    selaAddSel(sela, sel, "sel_2dm", 0);
    sel = selCreate(5, 5, "sel_5dp");
    sel->cy = 2;
    sel->cx = 2;
    selSetElement(sel, 0, 4, 1);
    selSetElement(sel, 1, 3, 1);
    selSetElement(sel, 2, 2, 1);
    selSetElement(sel, 3, 1, 1);
    selSetElement(sel, 4, 0, 1);
    selaAddSel(sela, sel, "sel_5dp", 0);
    sel = selCreate(5, 5, "sel_5dm");
    sel->cy = 2;
    sel->cx = 2;
    selSetElement(sel, 0, 0, 1);
    selSetElement(sel, 1, 1, 1);
    selSetElement(sel, 2, 2, 1);
    selSetElement(sel, 3, 3, 1);
    selSetElement(sel, 4, 4, 1);
    selaAddSel(sela, sel, "sel_5dm", 0);
    return sela;
}
SELA * selaAddBasic ( SELA * sela ) { char name [ L_BUF_SIZE ] ; l_int32 i , size ; SEL * sel ; PROCNAME ( " " ) ; if ( ! sela ) { if ( ( sela = selaCreate ( 0 ) ) == NULL ) return ( SELA * ) ERROR_PTR ( " " , procName , NULL ) ; } for ( i = 0 ; i < num_linear ; i ++ ) { size = basic_linear [ i ] ; sel = selCreateBrick ( 1 , size , 0 , size / 2 , 1 ) ; snprintf ( name , L_BUF_SIZE , " " , size ) ; selaAddSel ( sela , sel , name , 0 ) ; } for ( i = 0 ; i < num_linear ; i ++ ) { size = basic_linear [ i ] ; sel = selCreateBrick ( size , 1 , size / 2 , 0 , 1 ) ; snprintf ( name , L_BUF_SIZE , " " , size ) ; selaAddSel ( sela , sel , name , 0 ) ; } for ( i = 2 ; i <= 5 ; i ++ ) { sel = selCreateBrick ( i , i , i / 2 , i / 2 , 1 ) ; snprintf ( name , L_BUF_SIZE , " " , i ) ; selaAddSel ( sela , sel , name , 0 ) ; } sel = selCreateBrick ( 2 , 2 , 0 , 0 , 1 ) ; selSetElement ( sel , 0 , 0 , 0 ) ; selSetElement ( sel , 1 , 1 , 0 ) ; selaAddSel ( sela , sel , " " , 0 ) ; sel = selCreateBrick ( 2 , 2 , 0 , 0 , 1 ) ; selSetElement ( sel , 0 , 1 , 0 ) ; selSetElement ( sel , 1 , 0 , 0 ) ; selaAddSel ( sela , sel , " " , 0 ) ; sel = selCreate ( 5 , 5 , " " ) ; sel -> cy = 2 ; sel -> cx = 2 ; selSetElement ( sel , 0 , 4 , 1 ) ; selSetElement ( sel , 1 , 3 , 1 ) ; selSetElement ( sel , 2 , 2 , 1 ) ; selSetElement ( sel , 3 , 1 , 1 ) ; selSetElement ( sel , 4 , 0 , 1 ) ; selaAddSel ( sela , sel , " " , 0 ) ; sel = selCreate ( 5 , 5 , " " ) ; sel -> cy = 2 ; sel -> cx = 2 ; selSetElement ( sel , 0 , 0 , 1 ) ; selSetElement ( sel , 1 , 1 , 1 ) ; selSetElement ( sel , 2 , 2 , 1 ) ; selSetElement ( sel , 3 , 3 , 1 ) ; selSetElement ( sel , 4 , 4 , 1 ) ; selaAddSel ( sela , sel , " " , 0 ) ; return sela ; }
selaAddBasic()
      Input:  sela (<optional>)
      Return: sela with additional sels, or null on error
selaAddBasic () Input : sela ( <optional > ) Return : sela with additional sels or null on error
/*--------------------------------------------------------------*
     *             Linear horizontal and vertical sels              *
     *--------------------------------------------------------------*/ /*-----------------------------------------------------------*
     *                      2-d Bricks                           *
     *-----------------------------------------------------------*/ /*-----------------------------------------------------------*
     *                        Diagonals                          *
     *-----------------------------------------------------------*/ /*  0c  1
            1   0  */ /*  1c  0
            0   1   */ /*  Diagonal, slope +, size 5 */ /*  Diagonal, slope -, size 5 */