residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
(又要麻煩版大 ![]() ) 請問版大
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
引言:
(又要麻煩版大) 請問版大
1.影像通常由CCD擷取進來image時圖都問變形請問應如何補償呢??
2.若小弟要量測一實體的大小應如何做??
例如一個3乘3的正方形要怎樣才能用程式去判別他是3乘3的正方形!!
先聲明一下,我沒有那那麼厲害啦
> <>~我也是在學習的階段,回答的不好請您多多見諒與指教~>
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
謝謝大大的回應!!
真對不起喔!!小弟的的發言太籠統模糊了!!
1 小弟所謂的變形是指 從CCD擷取進來的影像常常為有彎曲 如下圖
請問如何校正回來!!
 2 小弟的3乘3的正方形單位是公分(忘了打上去 ![]() ) 謝謝大大!!請指教!!
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
1. 這部分可能要請您去看影像處理相關書籍了(我沒有矯正這方面的經驗)
2. 試試用垂直投影與水平投影,下面的code是重直投影,水平投影就交給您了
[程式碼]
Series1->Clear();
int DistributionX[160]={0};
Graphics::TBitmap*Bmp1=new Graphics::TBitmap();
Bmp1->LoadFromFile("test.bmp");
Image1->Picture->Assign(Bmp1);
byte* ptr1;
for (int y=0;yHeight;y++)
{
ptr1=(byte*)Bmp1->ScanLine[y];
for (int x=0;xWidth;x++)
{
if (ptr1[x*3]==255)
{
DistributionX[x]+=1;
}
}
}
Image1->Canvas->Pen->Color=clYellow;
for (int x=0;xWidth;x++)
{
Series1->Add(DistributionX[x],x,TColor(clBlue));
if (DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x-1]==0
||DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x+1]==0
)
{
Image1->Canvas->MoveTo(x,0);
Image1->Canvas->LineTo(x,Image1->Height);
}
}
delete Bmp1;
結果如圖示:
 便可藉由邊界來知道圖形大小為何 順心 ![]() <>~我也是在學習的階段,回答的不好請您多多見諒與指教~>
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
謝謝版大的回覆!!
那小弟在想若要偵測此方形是否有移動那也可用此類似之方法嗎?? 謝謝大大指教!!
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
引言:那小弟在想若要偵測此方形是否有移動那也可用此類似之方法嗎?? 若只是要知道[是否]有移動的話,那直接求差量影像(設一臨界值)
變化夠大的話(即大於此臨界值,便表示有移動)... 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~>
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
感謝版大的回覆!! 但小弟有個問題那就是小弟拿版大的程式碼去Try!!發現Series1此元件並不是BCB中的元件而經由本站文章中的參考才得知是Chart所改的!!
那請問版大如何更改呢?? 謝謝!!
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
引言:發現Series1此元件並不是BCB中的元件而經由本站文章中的參考才得知是Chart所改的!!那請問版大如何更改呢?? 不用改,只是您沒有設定好,當您拉了一個Chart到Form上後,滑鼠點兩下
選[add]選[Area]再按下[OK]就會出現Series1 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~> 發表人 -
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
真不好意思 由於小弟天資不聰的關係又來麻煩版大您了!! ![]()
版大給小弟的程式小弟嘗試去改成可測水平和垂直的尺寸!!
但發現有 class="code">
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (OpenPictureDialog1->Execute())
Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
Series1->Clear();
Series2->Clear();
int DistributionX[160]={0};
int DistributionY[260]={0};
Graphics::TBitmap*Bmp1=new Graphics::TBitmap();
Bmp1->LoadFromFile("test.bmp");
Image1->Picture->Assign(Bmp1);
byte* ptr1;
for (int y=0;y Height;y++)
{ ptr1=(byte*)Bmp1->ScanLine[y]; if (ptr1[y*3]==255)
{
DistributionY[y]+=1; }
for (int x=0;xWidth;x++)
{
if (ptr1[x*3]==255)
{
DistributionX[x]+=1; }
}
}
Image1->Canvas->Pen->Color=clYellow;
for (int x=0;xWidth;x++)
{
Series1->Add(DistributionX[x],x,TColor(clBlue));
if (DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x-1]==0 //看不太懂
||DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x+1]==0 ) //看不太懂
{
Image1->Canvas->MoveTo(x,0);
Image1->Canvas->LineTo(x,Image1->Width ); }
}
Image1->Canvas->Pen->Color=clBlue;
for (int y=0;yHeight ;y++)
{
Series2->Add(DistributionY[y],y,TColor(clBlue));
if (DistributionY[y]>0&&DistributionY[y]<70&&DistributionY[y1==0 //看不太懂
||DistributionY[y]>0&&DistributionY[y]<70&&DistributionY[y+1]==0 )//看不太懂
{
Image1->Canvas->MoveTo(0,y);
Image1->Canvas->LineTo(y,Image1->Height );
}
}
delete Bmp1;
}
執行結果為下圖
請問哪裡出錯了??
請版大指教!! 謝謝
residue
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
1. 沒錯,是以像素為單位 ![]()
> <>~我也是在學習的階段,回答的不好請您多多見諒與指教~>
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
感謝大大的回應!!
小弟回去有努力的想過但還是看不懂得地方是為何下面紅色程式範圍要這麼定義??
Series1->Add(DistributionX[x],x,TColor(clBlue));
if (DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x-1]==0
||DistributionX[x]>0&&DistributionX[x]<60&&DistributionX[x 1]==0
)
請指教
謝謝大大!!
|
taishyang
站務副站長
    
 發表:377 回覆:5490 積分:4563 註冊:2002-10-08
發送簡訊給我
|
residue您好:
改成下面這樣也可以
if (DistributionX[x]>0&&DistributionX[x-1]==0 //左界
||DistributionX[x]>0&&DistributionX[x 1]==0 //右界
)
目的其實就是要找出邊界的地方< > 順心< > ~我也是在學習的階段,回答的不好請您多多見諒與指教~
|
residue
中階會員
 
 發表:90 回覆:153 積分:53 註冊:2003-07-02
發送簡訊給我
|
感謝大大的指導!!
小弟問題以解決了下圖示是秀出的結果
 問題是出在只要把下面這行程式
Image1->Canvas->LineTo(y,Image1->Height );
改成下面這行程式就OK!!
Image1->Canvas->LineTo(Image1->Height ,y);
現在再朝若是菱形或不規則的四邊行計算邊長作修改為目標作修改 謝謝版大!!
[/code]
|