下面是我的快速DCT变换的代码,调试通过了,肯能往这敲时会有点手误,你看看吧,兄弟我的毕业设
计就是做基于DCT的图象压缩算法,你看看吧,分块的都考虑在主程序里了,后面那段是反变换的IDC
T.希望对你有用
/* This program is for carrying out 2-D fast consine Transform of blocks subdividing a given
image .Block size is user specified .*/
#define PI 3.14159
#include <stdio.h>
#include <math.h>
#include <alloc.h>
#include <conio.h>
#include <io.h>
#include <process.h>
void FCT(float *,unsigned int *,float *,int,int);
void bit_reversal(unsigned int *,int,int);
void WTS(float *,int,int);
void main()
{
int m,N,j,i,k1,k2,NB,NS,NT,k;
float *x,*C,**w;
unsigned int *L;
double nsq;
FILE *fptri,*fptro;
char file_name[14];
unsigned char *buffi;
float *buffo;
clrscr();
printf("Enter name of input file-->");
scanf("%s",file_name);
fptri=fopen(file_name,"rb");
if(fptri==NULL)
{
printf("No such file exists.[BS)]");
exit(1);
}
nsq=(double)filelength(fileno(fptri)); /*得到文件长度, 用 open()函数打开的文件句柄
返回文件长度,操作失败时返回 -1*/
/*assume image is square.*/
N=(int)sqrt(nsq);
m=(int)(log10((double)N)/log10((double)2.0));
k=1;