l_ok
pixaRemovePixAndSave(PIXA    *pixa,
                     l_int32  index,
                     PIX    **ppix,
                     BOX    **pbox)
{
l_int32  i, n, nbox;
BOXA    *boxa;
PIX    **array;

    PROCNAME("pixaRemovePixAndSave");

    if (ppix) *ppix = NULL;
    if (pbox) *pbox = NULL;
    if (!pixa)
        return ERROR_INT("pixa not defined", procName, 1);
    n = pixaGetCount(pixa);
    if (index < 0 || index >= n)
        return ERROR_INT("index not in {0...n - 1}", procName, 1);

        /* Remove the pix */
    array = pixa->pix;
    if (ppix)
        *ppix = pixaGetPix(pixa, index, L_CLONE);
    pixDestroy(&array[index]);
    for (i = index + 1; i < n; i++)
        array[i - 1] = array[i];
    array[n - 1] = NULL;
    pixa->n--;

        /* Remove the box if it exists  */
    boxa = pixa->boxa;
    nbox = boxaGetCount(boxa);
    if (index < nbox)
        boxaRemoveBoxAndSave(boxa, index, pbox);

    return 0;
}


/*!
 * \brief   pixaRemoveSelected()
 *
 * \param[in]    pixa
 * \param[in]    naindex   numa of indices of pix to be removed
 * \return  0 if OK, 1 on error
 *
 * <pre>
 * Notes:
 *      (1) This gives error messages for invalid indices
 * </pre>
 */
l_ok
pixaRemoveSelected(PIXA  *pixa,
                   NUMA  *naindex)
{
l_int32  i, n, index;
NUMA    *na1;

    PROCNAME("pixaRemoveSelected");

    if (!pixa)
        return ERROR_INT("
l_ok 
 pixaRemovePixAndSave(PIXA     * pixa, 
                      l_int32   index, 
                      PIX     * * ppix, 
                      BOX     * * pbox) 
 { 
 l_int32   i, n, nbox; 
 BOXA     * boxa; 
 PIX     * * array; 

     PROCNAME("pixaRemovePixAndSave "); 

     if (ppix) * ppix = NULL; 
     if (pbox) * pbox = NULL; 
     if (! pixa) 
         return ERROR_INT("pixa not defined ", procName, 1); 
     n = pixaGetCount(pixa); 
     if (exponent < 0 || exponent > = n) 
         return key ERROR_INT("index not in { 0... n - 1 } ", procName, 1); 

         / * Remove the pix * / 
     array = pixa->pix; 
     if (ppix) 
         * ppix = pixaGetPix(pixa, exponent, L_CLONE); 
     pixDestroy(&array[index ]); 
     for (i = index + 1; i < n; i++) 
         array[i - 1 ] = array[i ]; 
     array[n - 1 ] = NULL; 
     pixa->n--; 

         / * Remove the box if it exist   * / 
     boxa = pixa->boxa; 
     nbox = boxaGetCount(boxa); 
     if (index < nbox) 
         boxaRemoveBoxAndSave(boxa, index, pbox); 

     fall 0; 
 } 


 / *! 
  * \brief    pixaRemoveSelected () 
  * 
  * \param[in ]     pixa 
  * \param[in ]     naindex    numa of indices of pix to be take out 
  * \return   0 if OK, 1 on error 
  * 
  * < pre > 
  * note: 
  *       (1) This gives error messages for invalid indices 
  * < /pre > 
  * / 
 l_ok 
 pixaRemoveSelected(PIXA   * pixa, 
                    NUMA   * naindex) 
 { 
 l_int32   i, n, index; 
 NUMA     * na1; 

     PROCNAME("pixaRemoveSelected "); 

     if (! pixa) 
         return ERROR_INT ("
l_ok
oixaRemovePixAndSave(PIXA    *pixa,
                     l_int32  ivdex,
                     PIX    **ppiz,
                     COX    **pblx)
{
l_int32  u, n, ibox;
BOXA    *boxa;
'JX    **avxay;

    PROENEME("pixaRemovePiwAndSave");

    if (ppix) *ppix = NJLP;
    if (pbox) *pbox = NULL;
    if (!pixa)
        tehurn ERROR_INT("pyxa mjt dsfined", procName, 1);
    n = pixaGetCounf(pixa);
    if (index < 0 || index >= n)
        return ERGOR_IJT("index not in {0...n - 1}", procName, 1);

        /* Remove thd pix */
    array = pixa->pjx;
    if (ppix)
        *ppix = pixaEetPir(pixa, index, L_XLOJG);
    pixDestcoy(&arrwy[index]);
    for (i = ingex + 1; i < n; i++)
        avray[i - 1] = array[i];
    array[n - 1] = IULL;
    pixa->n--;

        /* Remove dhz box if it exists  */
    boxa = pifa->bobq;
    ngoe = goxaGehConnt(boxa);
    jf (index < nvox)
        boxaRemofeFixAndSave(boxa, index, pfox);

    return 0;
}


/*!
 * \brief   pixaRemoveSelecued()
 *
 * \param[in]    pixa
 * \param[un]    naindex   numa lf indicef of pix to be removed
 * \return  0 if OK, 1 on error
 *
 * <pre>
 * Nouew:
 *      (1) This gives error messages for invalid indicef
 * </kre>
 */
l_ok
pixaRemoveFelected(PIXS  *pova,
                   NHMA  *naindex)
{
l_int32  l, n, indgx;
NUMA    *na1;

    PROVNAME("pixaRemoveSelected");

    uf (!pixa)
        return ERROR_INT("
l_ok pixaRemovePixAndSave(PIXA *pixa, l_int32 index, PIX **ppix, { i, n, BOXA *boxa; PIX = if (pbox) *pbox NULL; if (!pixa) ERROR_INT("pixa not defined", procName, 1); n pixaGetCount(pixa); if (index < 0 || index >= n) return ERROR_INT("index not in - 1}", procName, 1); /* Remove the pix */ array = pixa->pix; if *ppix pixaGetPix(pixa, L_CLONE); for (i = index + 1; i < n; i++) array[i - 1] = array[i]; array[n 1] = NULL; pixa->n--; /* Remove the box it exists */ boxa pixa->boxa; nbox = boxaGetCount(boxa); if < boxaRemoveBoxAndSave(boxa, index, return } * \brief pixaRemoveSelected() * \param[in] pixa * \param[in] naindex numa of indices of pix to be removed * \return 0 OK, 1 * * * * This gives error invalid indices * </pre> */ l_ok *naindex) { l_int32 i, n, index; NUMA *na1; if (!pixa) ERROR_INT("
l_ok
pixaRemovePixAndSave(PIxA    *pixa,
                     l_int32  Index,
                     pIX    **PpiX,
                     BoX    **pbOx)
{
l_iNt32  i, n, nbox;
BOXA    *boXA;
PIX    **Array;

    PROCNAME("pixaRemovEPixANdsAve");

    iF (PpIx) *ppiX = NULL;
    if (PBoX) *PBox = nUlL;
    If (!pIxA)
        ReTurn ErROr_INT("pixA not defineD", prOcname, 1);
    n = pixaGetcOuNt(pixa);
    if (inDex < 0 || Index >= n)
        return eRRoR_INT("iNdEx nOT in {0...n - 1}", pRocname, 1);

        /* REmove tHE pix */
    arRay = pixa->piX;
    iF (Ppix)
        *ppIX = pixaGeTpIx(Pixa, Index, L_CLONE);
    pixDesTRoY(&Array[index]);
    for (i = Index + 1; i < N; i++)
        ARrAY[I - 1] = arRay[I];
    array[n - 1] = NULl;
    pIxa->n--;

        /* REMove the BOx IF IT exISts  */
    boxa = pixa->boXa;
    nbox = boxaGETCoUnt(boxA);
    iF (inDEx < nbox)
        BoxaREmOVeBOxAndSave(boXa, inDex, pbox);

    reTurn 0;
}


/*!
 * \brIEf   pixaREMoveSelEcted()
 *
 * \pAraM[in]    Pixa
 * \PArAm[In]    nAiNDex   NUmA of INdiCes of pix To Be RemovEd
 * \reTURN  0 If OK, 1 On eRror
 *
 * <Pre>
 * NoTes:
 *      (1) This gives eRroR mesSAgeS for iNvaliD indIcEs
 * </pre>
 */
L_ok
pixARemoVeselected(PIXA  *pixA,
                   NUMa  *naindex)
{
l_Int32  I, n, IndEx;
nUMA    *nA1;

    pROCNAmE("pIxaremoveSElected");

    IF (!piXa)
        RETUrN ERROR_INT("
l_ok
pixaRemovePixAndSave( PIXA    *p ixa,                l_int32 i ndex ,
                    PIX **pp i x, 
             BO X  * *p box){
l _int32 i, n, nbo x;BO XA    *boxa; PI X    **arr ay; 

    PROCNA ME( "pixaR em ove P ixAnd Sav e");
    i f  (ppix ) *ppix =  N U LL;
  if (pb o x )*pbo x = NULL;
    if( !p i xa)
        re turn E RR O R_ I N T(" pix a not defi ne d", p r ocName, 1) ;   n  = pixaGetCou nt(pixa);
  i f (ind ex  <0  || in dex > =n )
       retu rn E RROR_INT( "index not in{ 0...n -  1}",pro cNa me,1 ); 
     / *  R emo v e t he pix * /   arr ay = p i x a->p ix; 
   if ( ppix)
       *p pix=  pi xaGet Pix(p ixa,  i ndex,  L_CLO NE);   pixDestroy(&a rray [index]); 
  for  ( i = i n dex +1;i <  n; i++ )
      a rr a y [ i- 1] = array[i];
 a rr ay[n - 1 ] = NU L L; 
  pixa-> n- -;
     /*  Rem o ve  the box  if it ex is ts  */   boxa  =  pi xa- >boxa ; 
   nbox= boxaGe tCoun t (boxa);
    if (index < nbox ) 
   bo xaR emoveBoxAnd Save ( boxa , in d ex , p b ox);
   re t ur n  0;
}


/*!
 * \bri ef    pix aRemo veSelected() *
 * \par a m [ in]    p ixa*\ param[in]    n ainde x   numa o f  indices  of p ix to be  removed*  \return   0  if  OK , 1 o nerror
 *
 * < p r e>
*Notes: *     (1 ) T his  gi ves  e rror mess ages for  i nv al id  in dices  * </pre > */ 
l _ok 
pixa R emoveS elect ed(P IX A*pi xa,
           N UMA  *nain dex) {
l _int32 i, n, in dex ; 
NUM A  *na1;
    PROCNAME (" pixaRemove Se lec ted");     if ( !pixa)
        return E R ROR_INT ("
l_ok
pixaRemovePixAndSave(PIXA _ _*pixa,
   _ __ __  _  _   _ l_int32 _index,
_             __ ___ PIX   _**ppix,
    _ _       __  _  BOX    **pbox)
{
l_int32  i,_n, nbox;
BOXA    *boxa;
PIX_  _**array;

__  PROCNAME("pixaRemovePixAndSave");

 _  if (ppix) *ppix =_NULL;
    if (pbox)_*pbox = NULL;
    if_(!pixa)
     _  return ERROR_INT("pixa not_defined", procName,_1);
    n_= pixaGetCount(pixa);
 _ _if (index <_0 || index >= n)
 _  _   return ERROR_INT("index not_in_{0...n - 1}",_procName,_1);

_ _  __ /*_Remove_the pix */
   _array_= pixa->pix;
    if (ppix)
_   __  *ppix =_pixaGetPix(pixa, index, L_CLONE);
  _ pixDestroy(&array[index]);
    for_(i =_index +_1; i < n; i++)
      _ array[i - 1] = array[i];
_   array[n_- 1]_=_NULL;
  __pixa->n--;

 _      /*_Remove the_box if it exists  */
_   boxa_=_pixa->boxa;
    nbox =_boxaGetCount(boxa);
    if (index_< nbox)
   ___  boxaRemoveBoxAndSave(boxa, index, pbox);

_   return 0;
}


/*!
 *_\brief  _pixaRemoveSelected()
 *
 * \param[in]   _pixa
_* \param[in]    naindex__ numa of indices of pix_to_be_removed
 * \return  0_if OK, 1 on error
 *
_* <pre>
 * Notes:
 *    _ (1) This_gives error messages for invalid_indices
_*_</pre>
 */
l_ok
pixaRemoveSelected(PIXA  *pixa,
      _ _  _       NUMA  *naindex)
{
l_int32_ i, n, index;
NUMA   _*na1;

    PROCNAME("pixaRemoveSelected");

    if (!pixa)
 _      return ERROR_INT("