⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idct.cpp

📁 反DCT变换代码
💻 CPP
字号:
#include <math.h>
#include <iostream.h>
#include <iomanip.h>
#define pi 3.1415926
void main(void)
{
	int u,v,x,y;
	float CU,CV;
	float I[8][8]={0};
	float D[8][8]=
	{
		{123,157,142,127,131,102,99,235},
		{134,135,157,112,109,106,108,136},
		{135,144,159,108,112,118,109,126},
		{176,183,161,111,186,130,132,133},
		{137,149,154,126,185,146,131,132},
		{121,130,127,146,205,150,130,126},
		{117,151,160,181,250,161,134,125},
		{168,170,171,178,183,179,112,124}
	};
	
	float F[8][8]=
	{
		{1149.38,38.5669,-43.0705,-10.3124,25.125,-83.5118,10.6695,40.7656},
		{-81.1357,-3.04752,114.259,-73.5022,-6.38494,-2.12443,21.2252,-5.77706},
		{13.5307,-11.4702,0.35831,-42.9741,25.0809,-3.07197,16.7017,-38.8314},
		{1.2772,-61.1874,-13.6619,-12.4659,35.8633,-23.9721,-18.0568,4.27319},
		{43.875,12.9649,36.3616,-4.85862,9.125,-21.7076,6.45108,-8.025},
		{35.6621,-11.7247,-9.20415,-4.992,19.7537,-28.8279,-21.1232,13.0852},
		{-19.2699,-7.71287,20.9517,-6.13366,2.73517,2.20651,11.1417,-21.9884},
		{-5.3744,-13.797,-11.354,-17.6482,-4.83862,-1.05066,6.7316,-4.65868}
	};
	for (x=0;x<8;x++)
	    for (y=0;y<8;y++)
	    	 for (u=0;u<8;u++)
		    	 for (v=0;v<8;v++)
				 {
				     if (u==0)
				    	 CU=1/sqrt(2);
			    	 else
			    		 CU=1;
			    	 if (v==0)
			    		 CV=1/sqrt(2);
			    	 else
			    		 CV=1;

			    	 I[x][y]+=0.25*CU*CV*F[u][v]*cos((2*x+1)*u*pi/16)*cos((2*y+1)*v*pi/16);
				 }
	cout<<"RESULTS OF IDCT: "<<endl;
	for (x=0;x<8;x++)
	{
		for (y=0;y<8;y++)
		{
			cout<<setw(8)<<I[x][y]<<"  ";
		}
		cout<<endl;
	}
cout<<endl;
cout<<endl;
	cout<<"THE ERRORS ARE:"<<endl;
	for (x=0;x<8;x++)
	{
		for (y=0;y<8;y++)
		{
			cout<<setw(11)<<I[x][y]-D[x][y]<<"  ";
		}
		cout<<endl;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -