[問題] 二維影像的DFT

看板C_and_CPP (C/C++)作者時間14年前 (2011/10/04 20:19), 編輯推噓0(0010)
留言10則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) BCB 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 請問一下為何我做完DFT所得到的圖片跟原始影像一模一樣? 餵入的資料(Input): 64*64的bmp影像 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) void __fastcall TForm1::Button11Click(TObject *Sender) { Graphics::TBitmap *TheBitmap, *TempBitmap; int Width,Height,x,y,u,v,real_max=0; double real_min=1000000; float a; Byte *ptr1,*ptrt; std::complex<double> B; TempBitmap= new Graphics::TBitmap(); TheBitmap=Image1->Picture ->Bitmap; TheBitmap->PixelFormat=pf8bit; TempBitmap->Assign(TheBitmap); TempBitmap->PixelFormat=pf8bit; Width=TheBitmap->Width; Height= TheBitmap->Height; int aaa[64][64]={0}; for(v=0;v<(Height);v++) { ptr1=(Byte*) TheBitmap->ScanLine[v]; ptrt=(Byte*) TempBitmap->ScanLine[v]; for(u=0;u<(Width);u++) { B._M_re=0; B._M_im=0; for(x=0;x<(Width);x++) { for(y=0;y<(Height);y++) { a=2*M_PI*(((u*x)/Width)+((v*y)/Height)); B._M_re+=(ptr1[u]*cos(a)/(Width*Height)); B._M_im+=(-1)*(ptr1[u]*sin(a)/(Width*Height)); } } ptrt[u]=(int)B._M_re; } } TheBitmap->Assign(TempBitmap); Image1->Refresh(); delete TempBitmap; } 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.118.141.34 ※ 編輯: sd016808 來自: 140.118.141.34 (10/04 20:20)

10/04 23:22, , 1F
輸入的位圖檔很平滑?
10/04 23:22, 1F

10/04 23:49, , 2F
沒有很平滑 有測試過很多張影像 結果都一樣O~Q"
10/04 23:49, 2F

10/05 13:33, , 3F
有人可以幫幫我嗎 我已經因為這個問題卡了好幾個禮拜了..
10/05 13:33, 3F

10/05 21:29, , 4F
先把計算結果output到檔案看對不對 排除BCB元件的影響
10/05 21:29, 4F

10/07 01:08, , 5F
我改用canvas的形式 不要用scanline 稍微改一下程式碼
10/07 01:08, 5F

10/07 01:08, , 6F
終於寫出來了 不知道為何Scanline的方式就是不能...
10/07 01:08, 6F

10/07 01:09, , 7F
scanline的方式做出來的圖案黑底中間白點 不像Canvas的
10/07 01:09, 7F

10/07 01:09, , 8F
方式 中間看的出來是光點的感覺
10/07 01:09, 8F

10/07 15:54, , 9F
我今天發現跟scanline沒有關係 是我自己打錯了
10/07 15:54, 9F

10/07 15:54, , 10F
scanline跟canvas都可以用ORZ
10/07 15:54, 10F
文章代碼(AID): #1EYlc-oZ (C_and_CPP)
文章代碼(AID): #1EYlc-oZ (C_and_CPP)