Esempio n. 1
0
int main()
{
    int i;
    float src[N*N];
    float ref_fdct[N*N], ref_idct[N*N];
    float out_fdct[N*N], out_idct[N*N];

    for (i = 0; i < N*N; i++)
        src[i] = random() % 256;

    init_dct();

    fdct_ref(ref_fdct, src);
    fdct(out_fdct, src);
    if (check_output("FDCT", ref_fdct, out_fdct) < 0)
        return 1;

    idct_ref(ref_idct, ref_fdct);
    idct(out_idct, out_fdct);
    if (check_output("IDCT", ref_idct, out_idct) < 0)
        return 1;

    return 0;
}
Esempio n. 2
0
int main()
{
    int i,j;
    
    float src1[N*N],src2[N*N];
	
    float out_fdct1[N*N],out_fdct2[N*N], out_idct[N*N];
	int *matrix1=filehand("/home/dhyandeepak/Desktop/input1.bmp");
	int in1[128][128],in2[128][128];
	for(i=0;i<LENGTH;i++)
	{
			
			for(j=0;j<LENGTH;j++)
			{
				
				in1[i][j]=mat[i][j];//store the returned matrix in in1
				printf("matrix %d",in1[i][j]);
			}
				
	}
	int *matrix2=filehand("/home/dhyandeepak/Desktop/input2.bmp");
	for(i=0;i<LENGTH;i++)
	{
			
			for(j=0;j<LENGTH;j++)
			{
					
				in2[i][j]=(mat[i][j]);//store the returned matrix in in2
			}
				
	}

	
	int l=0,k,res=0,p;
	init_dct();
	for(j=0;j<LENGTH/N;j++)
	{
	   for(i=0;i<LENGTH/N;i++)
	   {
			for(k=0;k<N;k++)
			{
				for(l=0;l<N;l++)
				{
					src1[l+N*k]=in1[(N*j+k)][(l+N*i)];//store 8X8 image block into an array
					src2[l+N*k]=in2[(N*j+k)][(l+N*i)];
					printf("src:%f ",src1[l+N*k]);
				}
				printf("\n");
			}
			printf("\n");
			
			fdct_ref(out_fdct1, src1);//find fast dct for each 8X8 blocks
			fdct_ref(out_fdct2, src2);
			int med;
			for(med=0;med<64;med++)
			{
				out_fdct1[med]=(out_fdct1[med]+out_fdct2[med])/2;
			}
			
			idct_ref(out_idct, out_fdct1);
			for(k=0;k<N;k++)
			{
			
				for(l=0;l<N;l++)
				{
					
					mat[(N*j+k)][(l+N*i)]=out_idct[l+N*k];//store 8X8  block's compressed values into the matrix itself
				}
				
			}
	   }
	   
	}
    filewrite("/home/dhyandeepak/Desktop/out.pgm");//write the matrix into file
    
    return 0;
}