ip_lib.c
/* Converte una Bitmap in una ip_mat*/
Converte una Bitmap in una ip_mat
Converte una Bitmap in una ip_mat
ip_mat *bitmap_to_ip_mat(Bitmap *img)
{
    if (img)
    {
        unsigned int i = 0, j = 0;
        unsigned char R, G, B;
        unsigned int h = img->h;
        unsigned int w = img->w;
        ip_mat *out = ip_mat_create(h, w, 3, 0);
        for (i = 0; i < h; i++) 
        {
            for (j = 0; j < w; j++) 
            {
                bm_get_pixel(img, j, i, &R, &G, &B);
                set_val(out, i, j, 0, (float)R);
                set_val(out, i, j, 1, (float)G);
                set_val(out, i, j, 2, (float)B);
            }
        }
        compute_stats(out);
        return out;
    }
    else
    {
        printf("Insert a valid image\n");
        exit(1);
    }
}
ip_mat * bitmap_to_ip_mat ( Bitmap * img ) { if ( img ) { unsigned int i = 0 , j = 0 ; unsigned char R , G , B ; unsigned int h = img -> h ; unsigned int w = img -> w ; ip_mat * out = ip_mat_create ( h , w , 3 , 0 ) ; for ( i = 0 ; i < h ; i ++ ) { for ( j = 0 ; j < w ; j ++ ) { bm_get_pixel ( img , j , i , & R , & G , & B ) ; set_val ( out , i , j , 0 , ( float ) R ) ; set_val ( out , i , j , 1 , ( float ) G ) ; set_val ( out , i , j , 2 , ( float ) B ) ; } } compute_stats ( out ) ; return out ; } else { printf ( " \n " ) ; exit ( 1 ) ; } }
Converte una Bitmap in una ip_mat
Converte una Bitmap in una ip_mat
/* rows */ /* columns */