全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1723
推到 Plurk!
推到 Facebook!

DCT轉換問題

尚未結案
mike555
一般會員


發表:1
回覆:0
積分:0
註冊:2007-01-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-01-24 22:30:36 IP:61.64.xxx.xxx 訂閱
各位大大
請教一下在下我寫了一個DCT的程式
但是不知道為什麼跑出來的結果都不是我要的
實在是百思不得其解
我把部分的程式碼寫在下面
我是用C寫的環境是VC 6.0
請各位大大指教
謝謝


double DCT(unsigned char *outputbuf, int x, int y)
{
double cc;
int i,j,k,u,v,count=0 ;
float temp,temp1,temp2;

float one_div_sqrtcolrow=1.0/sqrt((int)x*y);
float sqrt_two_colrow=sqrt(2.0/(x*y));
float two_div_sqrtcolrow=2.0/(sqrt((int)x*y));



for(u=0;uwidth;u )
{
for(v=0;vheight;v )
{


for(i=0;iwidth;i )
{
for(j=0;jheight;j )
{

outputbuf[3*(u*bmpheaderptr->height v)] =
(outputbuf[3*(i*bmpheaderptr->height j)])*cos((2*i 1)*u*PI/(2*y))*cos((2*j 1)*v*PI/(2*x));
outputbuf[3*(u*bmpheaderptr->height v) 1] =(outputbuf[3*(i*bmpheaderptr->height j) 1])*cos((2*i 1)*u*PI/(2*y))*cos((2*j 1)*v*PI/(2*x));

outputbuf[3*(u*bmpheaderptr->height v) 2] =(outputbuf[3*(i*bmpheaderptr->height j) 2])*cos((2*i 1)*u*PI/(2*y))*cos((2*j 1)*v*PI/(2*x));

}

}
if(u==0 && v==0)
{
outputbuf[3*(u*bmpheaderptr->height v)]=one_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v)];
outputbuf[3*(u*bmpheaderptr->height v) 1]=one_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v) 1];
outputbuf[3*(u*bmpheaderptr->height v) 2]=one_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v) 2];
}
else if(v!=0 || u!=0)
{
outputbuf[3*(u*bmpheaderptr->height v)]=sqrt_two_colrow*outputbuf[3*(u*bmpheaderptr->height v)];
outputbuf[3*(u*bmpheaderptr->height v) 1]=sqrt_two_colrow*outputbuf[3*(u*bmpheaderptr->height v) 1];
outputbuf[3*(u*bmpheaderptr->height v) 2]=sqrt_two_colrow*outputbuf[3*(u*bmpheaderptr->height v) 2];
}
else
{
outputbuf[3*(u*bmpheaderptr->height v)]=two_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v)];
outputbuf[3*(u*bmpheaderptr->height v) 1]=two_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v) 1];
outputbuf[3*(u*bmpheaderptr->height v) 2]=two_div_sqrtcolrow*outputbuf[3*(u*bmpheaderptr->height v) 2];
}


}

}

附加檔案:45b76d8cb846d_DCT.rar
系統時間:2024-05-05 22:51:41
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!