Example #1
0
/*---------------------------------------------------------------------------
    Cration d'une pyramide Laplacienne avec entre en conversationnel
    des diffrentes proprits de cette pyramide
---------------------------------------------------------------------------*/
Image *Pyramid::pyram_l (const Image *im, int etage_f, filtre &utile, string &to_print)
{
    if(!( im != NULL )) {
        throw "Error in Pyramid::pyram_g:\nim = NULL";
    }
    if(!( im->getWidth() == im->getHeight() )) {
        throw  "Error in Pyramid::pyram_g:\nim->getWidth() != im->getHeight()";
    }
    if( !isPowerOf2(im->getWidth()) ) {
        throw  "Error in Pyramid::pyram_g:\nimage dimensions not a power of 2";
    }
    long nbl = im->getHeight();
    long nbc = im->getWidth();
    const uint8_t* itab = im->begin();

//    uint8_t* rep = new uint8_t[nbc * nbl * 2];
    GrayscaleImage* resImg = new GrayscaleImage(im->getWidth(), im->getHeight() * 2);
    uint8_t* rep = resImg->begin();
    int temp_etage_max = etage_max( im );
    if( etage_f > temp_etage_max ) etage_f = temp_etage_max;
    if( etage_f < 1 ) etage_f = 1;

    pyram_l_n(rep,etage_f,nbc,nbl,itab,utile);
    to_print = entropie_p(rep,etage_f,nbc,nbl);
    reconstruction(rep,etage_f,nbc,nbl);

    return resImg;

}
Example #2
0
/*---------------------------------------------------------------------------
    Cration d'un tage de la  pyramide Laplacienne
---------------------------------------------------------------------------*/
Image *Pyramid::n_pyram_l(const Image *im, int etage_f, filtre &utile)
{
    if(!( im != NULL )) {
        throw "Error in Pyramid::pyram_g:\nim = NULL";
    }
    if(!( im->getWidth() == im->getHeight() )) {
        throw  "Error in Pyramid::pyram_g:\nim->getWidth() != im->getHeight()";
    }
    if( !isPowerOf2(im->getWidth()) ) {
        throw  "Error in Pyramid::pyram_g:\nimage dimensions not a power of 2";
    }

    int i;
    int k=0;
    int taille_c,taille_l;
    long nbl = im->getHeight();
    long nbc = im->getWidth();
    const uint8_t* itab = im->begin();

    taille_c=nbc;
    taille_l=nbl;
    int temp_etage_max = etage_max(im) - 1;
    if( etage_f > temp_etage_max ) etage_f = temp_etage_max;
    if( etage_f < 0 ) etage_f = 0;

    for(i=0;i<etage_f;i++)
    {
        k=k+taille_c*taille_l;
        taille_c=taille_c/2;
        taille_l=taille_l/2;
    }
    GrayscaleImage* resImg = new GrayscaleImage(taille_c, taille_l);
    uint8_t* rep = resImg->begin();
    uint8_t* tab = new uint8_t[(nbc * nbc) / 2 * 3];
    pyram_g_n(tab,etage_f,nbc,nbl,itab,utile);
    pyram_l_n(tab,etage_f+1,nbc,nbl,itab,utile);
    for(i=0;i<taille_c*taille_l;i++)
    {
        rep[i] = tab[i+k];
    }
    delete[] tab;
    return resImg;
}