Thresholding的功能怪怪 |
尚未結案
|
小蛋
一般會員 發表:6 回覆:2 積分:1 註冊:2004-09-21 發送簡訊給我 |
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 發送簡訊給我 |
您好:
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 發送簡訊給我 |
|
richtop
資深會員 發表:122 回覆:646 積分:468 註冊:2003-06-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |