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

實做不用Scanline,邊緣強化時,圖形被切掉...

尚未結案
gues
一般會員


發表:6
回覆:7
積分:2
註冊:2004-04-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-04-22 18:16:33 IP:140.134.xxx.xxx 未訂閱
請問一下各位先進, 最近再練習寫影像相關的程式時, 在做不用Scanline的邊緣強化時, 發現圖形被切割了(如附圖)請問是什麼原因呢? thx.~ 程式碼如下(其中,Gx和Gy是使用taishyang大大的影像處理III,p1為[1024][768]): void __fastcall TForm1::Button9Click(TObject *Sender) { //邊緣加強, No scanline if (Image1->Picture->Bitmap->Empty==true) ShowMessage("請載入圖檔!!"); Graphics::TBitmap *first=new Graphics::TBitmap; Graphics::TBitmap *second=new Graphics::TBitmap; first->Assign(Image1->Picture->Bitmap); second->Width=first->Width; second->Height=first->Height; for (int i=0;j< second->Height;i++ ) { for (int j=0;j< second->Width; j++ ) { TColor Color=first->Canvas->Pixels[i][j]; BYTE R=GetRValue(Color); p1[j][i] = R; //因為是灰階,取RGB都一樣 } } for (int i=0;i< second->Height;i++ ) { for (int j=0;j< second->Width; j++ ) { TColor Color=second->Canvas->Pixels[i][j]; if ((Gx(j,i)+Gy(j,i))>255) { Color=(TColor)RGB(255, 255, 255); second->Canvas->Pixels[i][j]=Color; } else { Color=(TColor)RGB(Gx(j,i)+Gy(j,i), Gx(j,i)+Gy(j,i), Gx(j,i)+Gy(j,i)); second->Canvas->Pixels[i][j]=Color; } } } Image2->Picture->Assign(second); delete second; }
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-04-22 18:26:33 IP:140.135.xxx.xxx 未訂閱
gues您好: PO程式碼的方式請參考版規說明 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=47262 謝謝您的配合
brook
資深會員


發表:57
回覆:323
積分:371
註冊:2002-07-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-04-22 19:05:02 IP:218.160.xxx.xxx 未訂閱
這行有錯,修正看看  
 
for (int i=0;j< second->Height;i   )
taishyang
站務副站長


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-04-22 19:41:14 IP:140.135.xxx.xxx 未訂閱
brook前輩的眼睛真銳利
gues
一般會員


發表:6
回覆:7
積分:2
註冊:2004-04-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-04-23 09:39:51 IP:61.30.xxx.xxx 未訂閱
各位大大...不好意思.... 因為一開始貼for (int i=0;i< second->Height;i++ )時, 因為 i< second->Height一直出不來, "second->"會不見,因為"小於"和second相連,所以出不來....因此,我就自己改了一下,那個地方沒改到...sorry... PS: "i加加"和 "j加加" 若是 "加加" 和i 和j相連,為什麼"加加"會出不來阿?  (已使用版大說的用插入code的方法了...)    然後,現在的code,我從button copy出來了, 請大大幫我看一下,問題好像不是for loop指定錯說...謝謝...     
void __fastcall TForm1::Button9Click(TObject *Sender)
{
 //邊緣加強, No scanline
 if (Image1->Picture->Bitmap->Empty==true)
 ShowMessage("請載入圖檔!!");
 
 Graphics::TBitmap *first=new Graphics::TBitmap;
 Graphics::TBitmap *second=new Graphics::TBitmap;
 
 first->Assign(Image1->Picture->Bitmap);
 second->Width=first->Width;
 second->Height=first->Height;
 
 for (int i=0;iHeight;i   )
 {
  for (int j=0;jWidth; j   )
  {
   TColor Color=first->Canvas->Pixels[i][j];
   BYTE R=GetRValue(Color);
   p1[j][i] = R;
  }
 }
 
 for (int i=0;iHeight;i   )
 {
  for (int j=0;jWidth; j   )
   {
   TColor Color=second->Canvas->Pixels[i][j];
    if ((Gx(j,i) Gy(j,i))>255)
    {
     Color=(TColor)RGB(255, 255, 255);        
     second->Canvas->Pixels[i][j]=Color;
    }
    else
    {
    Color=(TColor)RGB(Gx(j,i) Gy(j,i), Gx(j,i) Gy(j,i), Gx(j,i) Gy(j,i));
    second->Canvas->Pixels[i][j]=Color;
    } 
   }
  }
  Image2->Picture->Assign(second);
  
  delete second;          
} 
taishyang
站務副站長


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-04-23 13:12:28 IP:140.135.xxx.xxx 未訂閱
gues您好: 您的 i 與 j 有些地方弄錯了,試試下面的code  
 if (Image1->Picture->Bitmap->Empty==true)
    ShowMessage("請載入圖檔!!");     Graphics::TBitmap *first=new Graphics::TBitmap;
 Graphics::TBitmap *second=new Graphics::TBitmap;
 first->Assign(Image1->Picture->Bitmap);
 second->Width=first->Width;
 second->Height=first->Height;
 for (int i=0;iHeight;i   )
 {
    for (int j=0;jWidth; j   )
    {
       TColor Color=first->Canvas->Pixels[j][i];
       BYTE R=GetRValue(Color);
       p1[j][i] = R;
    }
 }     for (int i=0;iHeight;i   )
 {
    for (int j=0;jWidth; j   )
    {
       TColor Color=second->Canvas->Pixels[j][i];
       if ((Gx(j,i) Gy(j,i))>255)
       {
          Color=(TColor)RGB(255, 255, 255);        
          second->Canvas->Pixels[j][i]=Color;
       }
       else
       {
          Color=(TColor)RGB(Gx(j,i) Gy(j,i), Gx(j,i) Gy(j,i), Gx(j,i) Gy(j,i));
          second->Canvas->Pixels[j][i]=Color;
       } 
    }
 }
 Image2->Picture->Assign(second);
 delete second;
順心 發表人 -
gues
一般會員


發表:6
回覆:7
積分:2
註冊:2004-04-14

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