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

關於Histogram Equalization

尚未結案
Weak
一般會員


發表:12
回覆:6
積分:3
註冊:2004-10-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-10-11 21:02:13 IP:140.113.xxx.xxx 未訂閱
請問一下這段程式哪裡錯了            Byte *ptr;         int avg,temp;         Graphics::TBitmap *Thepic;         Graphics::TBitmap *bmp=new Graphics::TBitmap;         Thepic=Image2->Picture->Bitmap;            for(int y=0;y < ImgHeight;y){           ptr=(Byte*)Thepic->ScanLine[y];           for(int x=0; x < ImgWidth; x++)           {             avg = ptr[x];             Histogram[avg]=Hstogram[avg]+1;           }         }         for(int i=0;i<256;i ) Histogram[i]=(Histogram[i]/(ImgHeight*ImgWidth)); for(int i=1;i<256;i ) Histogram[i]=Histogram[i] Histogram[i-1]; for(int i=0;i<256;i ) Histogram[i]=Histogram[i]*255; for(int i=0;i < ImgHeight; i ) { ptr=(Byte*)Thepic->ScanLine[i]; for(int j=0;j < ImgWidth; j ) { temp=ptr[j]; bmp->Canvas->Pixels[i][j] = int(Histogram[temp]);; } } Image2->Picture->Assign(bmp); 結果出現Access violation at address in module.Read of address 000000 請問是哪裡有錯呢 要怎麼修改呢 我實在不是很懂 請各位高手幫我解答 發表人 - weak 於 2004/10/11 21:05:03
cjs4a
一般會員


發表:2
回覆:2
積分:0
註冊:2004-10-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-10-12 23:52:22 IP:203.204.xxx.xxx 未訂閱
根據您程式內容,該程式應該是針對8bits灰階影像做 Histogram Equalization,但方法不正確,且post上來的程之可能為您重新以人工方式再鍵入,錯誤很多,本人就以會造成"Access violation at ......."之問題做問題之探討,以下為其中程式: for(int i=0;i < ImgHeight; i ) { ptr=(Byte*)Thepic->ScanLine[i]; for(int j=0;j < ImgWidth; j ) { temp=ptr[j]; bmp->Canvas->Pixels[i][j] = int(Histogram[temp]);; } } bmp->Canvas->Pixels[X][Y] 即代表您的i,j二個參數放錯位置,若影像寬度值比高度值還大時就會造成錯誤。
cjs4a
一般會員


發表:2
回覆:2
積分:0
註冊:2004-10-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-10-13 00:00:47 IP:203.204.xxx.xxx 未訂閱
不好意思~再附加提醒 Image物件的Width and Height不一定會和Image->Picture->Bitmap->Width and Height相同,所以應主要針對後者的寬高作來處理bitmap影像,而非用Image物件的寬高來處理
Weak
一般會員


發表:12
回覆:6
積分:3
註冊:2004-10-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-10-13 00:19:32 IP:140.113.xxx.xxx 未訂閱
------------------------------------------------------------------ Image物件的Width and Height不一定會和Image->Picture->Bitmap->Width and Height相同 ------------------------------------------------------------------ 抱歉 我看不太懂這段的意思 請你可以再解釋一下嗎 謝謝你的回答....
Weak
一般會員


發表:12
回覆:6
積分:3
註冊:2004-10-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-10-13 00:20:07 IP:140.113.xxx.xxx 未訂閱
------------------------------------------------------------------ Image物件的Width and Height不一定會和Image->Picture->Bitmap->Width and Height相同 ------------------------------------------------------------------ 抱歉 我看不太懂這段的意思 請你可以再解釋一下嗎 謝謝你的回答....
akway
一般會員


發表:1
回覆:11
積分:2
註冊:2006-08-17

發送簡訊給我
#6 引用回覆 回覆 發表時間:2008-10-12 11:10:25 IP:140.113.xxx.xxx 未訂閱
image->Picture->Height
是指image元件引入的圖的高度

image->Height
是指image這個元件的高度
istillloving
高階會員


發表:33
回覆:182
積分:183
註冊:2008-10-09

發送簡訊給我
#7 引用回覆 回覆 發表時間:2008-11-03 17:27:23 IP:140.127.xxx.xxx 訂閱




大略看了一下

[code cpp]
for(int i=0;i<256;i )
Histogram[i]=(Histogram[i]/(ImgHeight*ImgWidth));
for(int i=1;i<256;i )
Histogram[i]=Histogram[i] Histogram[i-1];
[/code]

應該是這裡錯了
應該要先累加完所有的值再做某一個色階在整張圖案出現的機率



剛好我個作業也是這個 我的給你參考一下

我做的是灰階的
所以n[w][h] 必須傳入灰階的陣列
如果你要做彩色的話 可以YIQ從新帶回去RGB就可以了

buffg[w][h]是Y陣列



[code cpp]

class Enhancement{


public:


void NormHist (double n[w][h])
{
double move=0.0,vv=0;
int x=0;



for(j=0;j {
for(i=0;i {
vv=n[i][j];
V[(int)vv] ;
}
}

for(i=1;i<256;i )
{
move=V[i-1];
V[i] =move;
}

for(i=1;i<256;i )
{
V[i]=(V[i]/(h*w))*255;
}

for(i=0;i<256;i )
{
x=(int)(V[i]);
if(( (V[i])-((double)x)) >= 0.5)
{
V[i]=(x 1);
}
else
{
V[i]=x;
}
}

for(j=0;j {
for(i=0;i {
buffg[i][j]=V[(int)(buffg[i][j])];
}
}


}



};

[/code]
------
恩...
編輯記錄
istillloving 重新編輯於 2008-11-03 17:28:04, 註解 無‧
istillloving 重新編輯於 2008-11-03 17:38:11, 註解 無‧
istillloving 重新編輯於 2008-11-03 17:38:32, 註解 無‧
istillloving 重新編輯於 2008-11-03 17:48:23, 註解 無‧
istillloving 重新編輯於 2008-11-05 16:32:30, 註解 無‧
istillloving 重新編輯於 2008-11-05 16:33:02, 註解 無‧
istillloving 重新編輯於 2008-11-05 16:37:49, 註解 無‧
istillloving 重新編輯於 2008-11-05 16:38:48, 註解 無‧
istillloving 重新編輯於 2008-11-05 16:39:32, 註解 無‧
系統時間:2024-04-19 11:23:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!