Esempio n. 1
0
void InitUniformCentroids(Destin *d, uint l, uint ni, uint nb, uint np, uint ns)
{
    uint i, j;

    MALLOCV(d->uf_mu[l], float *, nb);
    MALLOCV(d->uf_sigma[l], float *, nb);
    MALLOCV(d->uf_absvar[l], float, ns);

    MALLOCV(d->uf_winCounts[l], uint, nb);
    MALLOCV(d->uf_winFreqs[l], float, nb);
    MALLOCV(d->uf_persistWinCounts[l], long, nb);
    MALLOCV(d->uf_persistWinCounts_detailed[l], long, nb);
    MALLOCV(d->uf_starv[l], float, nb);

    MALLOCV(d->uf_avgDelta[l], float *, nb);
    MALLOCV(d->uf_avgSquaredDelta[l], float *, nb);
    MALLOCV(d->uf_avgAbsDelta[l], float, ns);

    for (i=0; i < nb; i++)
    {
        MALLOCV(d->uf_mu[l][i], float, ns);
        MALLOCV(d->uf_sigma[l][i], float, ns);
        MALLOCV(d->uf_avgDelta[l][i], float, ns);
        MALLOCV(d->uf_avgSquaredDelta[l][i], float, ns);

        d->uf_winCounts[l][i] = 0;
        d->uf_winFreqs[l][i] = 1/(float) nb;
        d->uf_persistWinCounts[l][i] = 0;
        d->uf_persistWinCounts_detailed[l][i] = 0;
        d->uf_starv[l][i] = 1;

        _initUniformCentroidMu(d->uf_mu[l][i], ni, nb, np, ns);
        for (j=0; j < ns; j++)
        {
            d->uf_sigma[l][i][j] = INIT_SIGMA;
        }
    }

    for (j=0; j < ns; j++)
    {
        d->uf_absvar[l][j] = 0;
    }
}
Esempio n. 2
0
MDJVU_IMPLEMENT mdjvu_pattern_t mdjvu_pattern_create_from_array(byte **pixels, int32 w, int32 h)/*{{{*/
{
    int32 i, mass;
    Image *img = MALLOC(Image);
    byte *pool = MALLOCV(byte, w * h);
    memset(pool, 0, w * h);

    img->width = w;
    img->height = h;

    img->pixels = MALLOCV(byte *, h);
    for (i = 0; i < h; i++)
        img->pixels[i] = pool + i * w;

    mass = 0;
    for (i = 0; i < h; i++)
    {
        int32 j;
        for (j = 0; j < w; j++)
            if (pixels[i][j])
            {
                img->pixels[i][j] = 255; /* i don't remember what for */
                mass += 1;
            }
    }
    img->mass = mass;

    mdjvu_soften_pattern(img->pixels, img->pixels, w, h);
    get_mass_center(img->pixels, w, h,
                    &img->mass_center_x, &img->mass_center_y);
    mdjvu_get_gray_signature(img->pixels, w, h,
                             img->signature, SIGNATURE_SIZE);
    mdjvu_get_black_and_white_signature(img->pixels, w, h,
                                        img->signature2, SIGNATURE_SIZE);
    return (mdjvu_pattern_t) img;
}/*}}}*/