線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2453
推到 Plurk!
推到 Facebook!

影像強化

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


發表:45
回覆:32
積分:15
註冊:2006-10-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-02-04 12:32:06 IP:163.18.xxx.xxx 訂閱
各位前輩好:
以下有個影像強化的範例,但是速度有點慢,請問能否加快執行速度呢?


[code cpp]
[code cpp]
void stretch(TImage *Image1,int max,int min) //伸張強化
{
for (int j=0;jHeight;j )
{
for (int i=0;iWidth;i )
{
int R=GetRValue(Image1->Canvas->Pixels[i][j]);
int G=GetGValue(Image1->Canvas->Pixels[i][j]);
int B=GetBValue(Image1->Canvas->Pixels[i][j]);
if(R<=min || R>=max)
{if(R<=min){R=0;}else{R=255;}}
else
{R= (R-min)*255 / (max-min);}

if(G<=min || G>=max)
{if(G<=min){G=0;}else{G=255;}}
else
{G= (G-min)*255 / (max-min);}

if(B<=min || B>=max)
{if(B<=min){B=0;}else{B=255;}}
else
{B= (B-min)*255 / (max-min);}

Image1->Picture->Bitmap->Canvas->Pixels[i][j]=RGB(check(R),check(G),check(B));
}
}
}
[/code]
[/code]
編輯記錄
jenglin 重新編輯於 2008-02-04 12:33:43, 註解 無‧
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-02-04 14:41:59 IP:211.75.xxx.xxx 訂閱
請搜尋ScanLine的用法^_^
jenglin
一般會員


發表:45
回覆:32
積分:15
註冊:2006-10-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-02-07 16:24:39 IP:124.8.xxx.xxx 訂閱
請問是這樣嗎?


[code cpp]
void stretch(TImage *Image1,int max,int min) //伸張強化
{
Byte **ptr;
int R, G, B, index;
Image1->Picture->Bitmap->PixelFormat = pf24bit;
ptr = new Byte*[Image1->Picture->Height];
for (int k=0; k<=Image1->Height; k )
ptr[k] = (Byte*) Image1->Picture->Bitmap->ScanLine[k];
for (int row=0; row<=Image1->Height; row )
{ index = 0;
for (int col=0; col<=Image1->Width; col )
{ B = ptr[row][index ];
G = ptr[row][index 1];
R = ptr[row][index 2];
if(R<=min || R>=max)
{if(R<=min){R=0;}else{R=255;}}
else
{R= (R-min)*255 / (max-min);}
if(G<=min || G>=max)
{if(G<=min){G=0;}else{G=255;}}
else
{G= (G-min)*255 / (max-min);}
if(B<=min || B>=max)
{if(B<=min){B=0;}else{B=255;}}
else
{B= (B-min)*255 / (max-min);}
Image1->Picture->Assign(Image1);
}
}
}
[/code]


===================引 用 taishyang 文 章===================
請搜尋ScanLine的用法^_^
taishyang
站務副站長


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-02-13 18:08:30 IP:118.169.xxx.xxx 訂閱
編輯記錄
taishyang 重新編輯於 2008-02-13 18:15:35, 註解 無‧
系統時間:2024-05-07 23:23:10
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!