欢迎来到天天文库
浏览记录
ID:55767509
大小:18.00 KB
页数:7页
时间:2020-06-06
《图像的离散余弦变换代码.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、对图像进行离散余弦变换(DCT)处理(图像变换)的源代码#defineEXTRA_NAME"@dcttransform."#include"loadbmp.h"#definePoint(x,y)lpPoints[(x)+(y)*nWidth]voidFFT(COMPLEX*TD,COMPLEX*FD,intpower){intcount;inti,j,k,bfsize,p;doubleangle;COMPLEX*W,*X1,*X2,*X;count=1<2、X*)malloc(sizeof(COMPLEX)*count);X2=(COMPLEX*)malloc(sizeof(COMPLEX)*count);for(i=0;i3、X2[i+p]=Add(X1[i+p],X1[i+p+bfsize/2]);X2[i+p+bfsize/2]=Mul(Sub(X1[i+p],X1[i+p+bfsize/2]),W[i*(1<4、OMPLEX*X;doubles;count=1<5、s;}free(X);}voidDct(){intw=1,h=1,wp=0,hp=0;while(w*2<=nWidth){w*=2;wp++;}while(h*2<=nHeight){h*=2;hp++;}intx,y;BYTE*lpPoints=newBYTE[nWidth*nHeight];GetPoints(lpPoints);double*f=newdouble[w*h];double*W=newdouble[w*h];for(y=0;y6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
2、X*)malloc(sizeof(COMPLEX)*count);X2=(COMPLEX*)malloc(sizeof(COMPLEX)*count);for(i=0;i3、X2[i+p]=Add(X1[i+p],X1[i+p+bfsize/2]);X2[i+p+bfsize/2]=Mul(Sub(X1[i+p],X1[i+p+bfsize/2]),W[i*(1<4、OMPLEX*X;doubles;count=1<5、s;}free(X);}voidDct(){intw=1,h=1,wp=0,hp=0;while(w*2<=nWidth){w*=2;wp++;}while(h*2<=nHeight){h*=2;hp++;}intx,y;BYTE*lpPoints=newBYTE[nWidth*nHeight];GetPoints(lpPoints);double*f=newdouble[w*h];double*W=newdouble[w*h];for(y=0;y6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
3、X2[i+p]=Add(X1[i+p],X1[i+p+bfsize/2]);X2[i+p+bfsize/2]=Mul(Sub(X1[i+p],X1[i+p+bfsize/2]),W[i*(1<4、OMPLEX*X;doubles;count=1<5、s;}free(X);}voidDct(){intw=1,h=1,wp=0,hp=0;while(w*2<=nWidth){w*=2;wp++;}while(h*2<=nHeight){h*=2;hp++;}intx,y;BYTE*lpPoints=newBYTE[nWidth*nHeight];GetPoints(lpPoints);double*f=newdouble[w*h];double*W=newdouble[w*h];for(y=0;y6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
4、OMPLEX*X;doubles;count=1<5、s;}free(X);}voidDct(){intw=1,h=1,wp=0,hp=0;while(w*2<=nWidth){w*=2;wp++;}while(h*2<=nHeight){h*=2;hp++;}intx,y;BYTE*lpPoints=newBYTE[nWidth*nHeight];GetPoints(lpPoints);double*f=newdouble[w*h];double*W=newdouble[w*h];for(y=0;y6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
5、s;}free(X);}voidDct(){intw=1,h=1,wp=0,hp=0;while(w*2<=nWidth){w*=2;wp++;}while(h*2<=nHeight){h*=2;hp++;}intx,y;BYTE*lpPoints=newBYTE[nWidth*nHeight];GetPoints(lpPoints);double*f=newdouble[w*h];double*W=newdouble[w*h];for(y=0;y6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
6、DCT_Pre(&f[w*y],&W[w*y],wp);}for(y=0;y255)a=255;Point(x,nHeight-y-1)=(BYTE)(a);}}deletef;deleteW;PutP
7、oints(lpPoints);deletelpPoints;}voidmain(intargc,char*argv[]){if(argc==2)FileName=argv[1];elsereturn;OpenFile();Dct();SaveAs();}
此文档下载收益归作者所有