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

Haar小波轉換的問題

答題得分者是:taishyang
chrislove87
一般會員


發表:11
回覆:14
積分:5
註冊:2007-05-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-03-23 17:37:40 IP:210.70.xxx.xxx 訂閱
日前剛踏入影像處理的領域 還不太熟練

練習了一下3階Haar小波

但是跑出來的結果跟別人跑的不太一樣

原圖
這是原圖

這是範例解
這是網路上的範例解


這是我自己寫出來的結果

整個看起來很奇怪,但是程式碼我看不出來哪兒有錯...

還請各位論壇上的高手幫小弟看一下

以下是片段:

[code cpp]
float R,G,B;
Byte *ptr;
//rgb to gray & gray histogram compute 0.
int grayhist[256];
for(int i=0;i<256;i ) grayhist[i]=0;
for(int i=0;i ptr=(Byte *)Bitmap1->ScanLine[i];
for(int j=0;j B = ptr[j*3];
G = ptr[j*3 1];
R = ptr[j*3 2];
float clRGB=rgb2gray(R,G,B);
y[j][i]=TColor(RGB(clRGB,clRGB,clRGB));
Image3->Picture->Bitmap->Canvas->Pixels[j][i]=y[j][i];
} //for j end
} //for i end
//******一階小波轉換***************
for(int i=0;i int a=0,b=H/2;
for(int j=0;j y_one[i][a]=y[i][j] y[i][j 1];
y_one[i][b]=y[i][j]-y[i][j 1];
a ;b ;
} //for j end
} //for i end
for(int i=0;i int a=0,b=W/2;
for(int j=0;j y_two[a][i]=y_one[j][i] y_one[j 1][i];
y_two[b][i]=y_one[j][i]-y_one[j 1][i];
a ;b ;
} //for j end
} //for i end
for(int i=0;i for(int j=0;j y_one[i][j]=y_two[i][j];
//*****二階小波轉換****************
for(int i=0;i int a=0,b=H/4;
for(int j=0;j y_one[i][a]=y_two[i][j] y_two[i][j 1];
y_one[i][b]=y_two[i][j]-y_two[i][j 1];
a ;b ;
} //for j end
} //for i end
for(int i=0;i int a=0,b=W/4;
for(int j=0;j y_two[a][i]=y_one[j][i] y_one[j 1][i];
y_two[b][i]=y_one[j][i]-y_one[j 1][i];
a ;b ;
} //for j end
} //for i end
//*****三階小波轉換*****************
for(int i=0;i for(int j=0;j y_one[i][j]=y_two[i][j];
for(int i=0;i int a=0,b=H/8;
for(int j=0;j y_one[i][a]=y_two[i][j] y_two[i][j 1];
y_one[i][b]=y_two[i][j]-y_two[i][j 1];
a ;b ;
} //for j end
} //for i end
for(int i=0;i int a=0,b=W/8;
for(int j=0;j y_two[a][i]=y_one[j][i] y_one[j 1][i];
y_two[b][i]=y_one[j][i]-y_one[j 1][i];
a ;b ;
} //for j end
} //for i end
Bitmap2->Height=H;
Bitmap2->Width=W;
for(int i=0;i for(int j=0;j Image3->Picture->Bitmap->Canvas->Pixels[i][j]=TColor(RGB(y_two[i][j],y_two[i][j],y_two[i][j]));
//Bitmap2->Canvas->Pixels[i][j]=TColor(RGB(y_two[i][j],y_two[i][j],y_two[i][j]));
}
//Image3->Picture->Assign(Bitmap2);

[/code]





編輯記錄
chrislove87 重新編輯於 2009-03-23 17:38:34, 註解 無‧
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-03-23 17:43:01 IP:118.169.xxx.xxx 訂閱
顯示像素的範圍只有0~255,運算的過程中會不會overflow or underflow?
chrislove87
一般會員


發表:11
回覆:14
積分:5
註冊:2007-05-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-03-23 17:46:44 IP:210.70.xxx.xxx 訂閱

===================引 用 taishyang 文 章===================
顯示像素的範圍只有0~255,運算的過程中會不會overflow or underflow?

目前沒有發生過這樣的問題

像素範圍0~255 這樣會發生什麼事@@?

taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-03-23 18:13:46 IP:118.169.xxx.xxx 訂閱
顯示的時候 0xff 0x01 = 0xff 白色
倘若你 0xff 0x01 = 0x00 黑色

P.S:搜尋
[haar 小波]有很多範例可以參考
編輯記錄
taishyang 重新編輯於 2009-03-23 18:17:46, 註解 無‧
chrislove87
一般會員


發表:11
回覆:14
積分:5
註冊:2007-05-09

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-03-23 21:02:37 IP:210.70.xxx.xxx 訂閱

===================引 用 taishyang 文 章===================
顯示的時候 0xff 0x01 = 0xff 白色
倘若你 0xff 0x01 = 0x00 黑色

P.S:搜尋
[haar 小波]有很多範例可以參考

感謝您的建議

我後來回去看講義 他將兩個值相加除於二

這樣的作法應該OK吧?

還有一點就是

我直接將值輸出給Pixels 這樣的做法正確嗎?
系統時間:2024-03-28 17:18:20
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!