src/jbclass.c
PIXA *
jbTemplatesFromComposites(PIXA  *pixac,
                          NUMA  *na)
{
l_int32    n, i;
l_float32  nt;  /* number of samples in the composite; always an integer */
l_float32  factor;
PIX       *pixsum;   /* accumulated composite */
PIX       *pixd;
PIXA      *pixad;

    PROCNAME("jbTemplatesFromComposites");

    if (!pixac)
        return (PIXA *)ERROR_PTR("pixac not defined", procName, NULL);
    if (!na)
        return (PIXA *)ERROR_PTR("na not defined", procName, NULL);

    n = pixaGetCount(pixac);
    pixad = pixaCreate(n);
    for (i = 0; i < n; i++) {
        pixsum = pixaGetPix(pixac, i, L_COPY);  /* changed internally */
        numaGetFValue(na, i, &nt);
        factor = 255. / nt;
        pixMultConstAccumulate(pixsum, factor, 0);  /* changes pixsum */
        pixd = pixFinalAccumulate(pixsum, 0, 8);
        pixaAddPix(pixad, pixd, L_INSERT);
        pixDestroy(&pixsum);
    }

    return pixad;
}
/*!
 *  jbTemplatesFromComposites()
 *
 *      Input:  pixac (one pix of composites for each class)
 *              na (number of samples used for each class composite)
 *      Return: pixad (8 bpp templates for each class), or null on error
 *
 */
jbTemplatesFromComposites()
Input:  pixac (one pix of composites for each class)
na (number of samples used for each class composite)
Return: pixad (8 bpp templates for each class), or null on error
jbTemplatesFromComposites () Input : pixac ( one pix of composites for each class ) na ( number of samples used for each class composite ) Return : pixad ( 8 bpp templates for each class ) or null on error
PIXA *
jbTemplatesFromComposites(PIXA  *pixac,
                          NUMA  *na)
{
l_int32    n, i;
l_float32  nt;  
l_float32  factor;
PIX       *pixsum;   
PIX       *pixd;
PIXA      *pixad;
    PROCNAME("jbTemplatesFromComposites");
    if (!pixac)
        return (PIXA *)ERROR_PTR("pixac not defined", procName, NULL);
    if (!na)
        return (PIXA *)ERROR_PTR("na not defined", procName, NULL);
    n = pixaGetCount(pixac);
    pixad = pixaCreate(n);
    for (i = 0; i < n; i++) {
        pixsum = pixaGetPix(pixac, i, L_COPY);  
        numaGetFValue(na, i, &nt);
        factor = 255. / nt;
        pixMultConstAccumulate(pixsum, factor, 0);  
        pixd = pixFinalAccumulate(pixsum, 0, 8);
        pixaAddPix(pixad, pixd, L_INSERT);
        pixDestroy(&pixsum);
    }
    return pixad;
}
PIXA * jbTemplatesFromComposites ( PIXA * pixac , NUMA * na ) { l_int32 n , i ; l_float32 nt ; l_float32 factor ; PIX * pixsum ; PIX * pixd ; PIXA * pixad ; PROCNAME ( " " ) ; if ( ! pixac ) return ( PIXA * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ! na ) return ( PIXA * ) ERROR_PTR ( " " , procName , NULL ) ; n = pixaGetCount ( pixac ) ; pixad = pixaCreate ( n ) ; for ( i = 0 ; i < n ; i ++ ) { pixsum = pixaGetPix ( pixac , i , L_COPY ) ; numaGetFValue ( na , i , & nt ) ; factor = 255. / nt ; pixMultConstAccumulate ( pixsum , factor , 0 ) ; pixd = pixFinalAccumulate ( pixsum , 0 , 8 ) ; pixaAddPix ( pixad , pixd , L_INSERT ) ; pixDestroy ( & pixsum ) ; } return pixad ; }
jbTemplatesFromComposites()
      Input:  pixac (one pix of composites for each class)
              na (number of samples used for each class composite)
      Return: pixad (8 bpp templates for each class), or null on error
jbTemplatesFromComposites () Input : pixac ( one pix of composites for each class ) na ( number of samples used for each class composite ) Return : pixad ( 8 bpp templates for each class ) or null on error
/* number of samples in the composite; always an integer */ /* accumulated composite */ /* changed internally */ /* changes pixsum */