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

Thresholding的功能怪怪

尚未結案
小蛋
一般會員


發表:6
回覆:2
積分:1
註冊:2004-09-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-09-21 21:51:25 IP:218.171.xxx.xxx 未訂閱
void __fastcall TForm1::Thresholding1Click(TObject *Sender) {   int Threshold;   Graphics::TBitmap *TheBitmap;   Byte *ptr;        TheBitmap=Image1->Picture->Bitmap;     ThresholdDlg->Image1->AutoSize=false;     ThresholdDlg->Image1->Stretch=true;     ThresholdDlg->Image1->Picture->Bitmap->Assign(TheBitmap);     ThresholdDlg->ShowModal();  //--------------------     if(ThresholdDlg->ModalResult==mrOk)     {       Threshold=ThresholdDlg->ScrollBar1->Position;       for (int y=0; y < TheBitmap->Height; y++)       {        ptr = (Byte*)TheBitmap->ScanLine[y];        for (int x=0; x < TheBitmap->Width; x++)        {         if (ptr[x] < Threshold) ptr[x]=0;         else ptr[x]=255;         }        }       OrgBitmap->Assign(TheBitmap);     }  //------------------------------------------------------     Repaint();         }    以上是Thresholding的程式~但是因為Run出來~有動作的只有圖的三分之一~ 我感覺是"else ptr[x]=255;"這行有問題但是改很久都改不出來~請問一下~我是該改那ㄋ? 發表人 - taishyang 於 2004/09/21 22:34:26
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-09-21 22:22:02 IP:218.168.xxx.xxx 未訂閱
您好: 
void __fastcall TForm1::Thresholding1Click(TObject *Sender)
{
  int Threshold;
  Graphics::TBitmap *TheBitmap;
  Byte *ptr;        TheBitmap=Image1->Picture->Bitmap;
    ThresholdDlg->Image1->AutoSize=false;
    ThresholdDlg->Image1->Stretch=true;
    ThresholdDlg->Image1->Picture->Bitmap->Assign(TheBitmap);
    ThresholdDlg->ShowModal();
 //--------------------
    if(ThresholdDlg->ModalResult==mrOk)
    {
       Threshold=ThresholdDlg->ScrollBar1->Position;
       for (int y=0; y < TheBitmap->Height; y  )
       {
          ptr = (Byte*)TheBitmap->ScanLine[y];
          for (int x=0; x < TheBitmap->Width; x  )
          {
             if (ptr[x] < Threshold)
             {
                ptr[x*3  ] = 0;
                ptr[x*3 1] = 0;
                ptr[x*3 2] = 0;
             }
             else 
             {
                ptr[x*3  ] = 255;
                ptr[x*3 1] = 255
                ptr[x*3 1] = 255
             } 
          }
       }
       OrgBitmap->Assign(TheBitmap);
    }
 //------------------------------------------------------
    Repaint();        
}
先加入紅色部分看看
小蛋
一般會員


發表:6
回覆:2
積分:1
註冊:2004-09-21

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-09-21 22:49:34 IP:218.171.xxx.xxx 未訂閱
^^謝謝你的解答~ 不過我用同一張圖Test過後~得到的結果是 所以~^^
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-09-21 23:41:49 IP:140.129.xxx.xxx 未訂閱
小蛋 您好: 插個花,好像taishyang大大已經解決了問題。 如果還有可能加強的部分,或許在處理前先設定一下: TheBitmap->PixelFormat = pf24bit; 試試看。 RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
系統時間:2024-05-21 11:15:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!