jlvjlv
一般會員
發表:10 回覆:7 積分:3 註冊:2004-12-25
發送簡訊給我
|
我現在要撰寫一個兩張圖ㄉ配對~~ 大張為320*200
小張為40*40 因為是最簡單ㄉ配對~~~所以小張ㄉ影像是從大張ㄉ影像中切割出來ㄉ 我ㄉ想法是以小張ㄉ影像為一單位~~在大張ㄉ影像上一一搜尋比對
找到後把小張ㄉ影像放到大張影像上配對成功ㄉ位置 判斷ㄉ依據~~因為是一模一樣ㄉ圖~~所以我是想說~~在每一次每一ㄍ小張影像比較時~~大張影像和小張影像ㄉ每ㄍ像素相減~~然後把相減ㄉ值相加~~若等於零~~則配對成功~~ 不過我現在~~~不知道我ㄉ程式哪裡有問題~~因為程式在runㄉ時候都沒有bug
不過結果卻不是我想要ㄉ~~~所以想麻煩程式厲害ㄉ大大幫幫我~~~
感謝~~~!! 以下我附上我所寫ㄉ程式碼
-------------------------------------------
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics:: TBitmap *TheBitmap , *TheBitmap1;
Byte *ptr;
int x,y,a,b;
int sum;
TheBitmap=Image1->Picture->Bitmap;
TheBitmap=Image2->Picture->Bitmap;
for (y=0;yHeight-TheBitmap1->Height*/
{
ptr=(Byte*)TheBitmap->ScanLine[y];
for (x=0;x<(x-b);x=x+b) /*TheBitmap->Width-TheBitmap1->Width*/
{
ptr=(Byte*)TheBitmap->ScanLine[x];
for (a=0;aHeight;a++)
{
ptr=(Byte*)TheBitmap1->ScanLine[a];
for (b=0;bWidth;b++)
{
sum=(ptr[y*3]-ptr[a*3])+ (ptr[y*3+1]-ptr[a*3+1])+
(ptr[y*3+2]-ptr[a*3+2]);
sum=(ptr[x*3]-ptr[b*3])+ (ptr[x*3+1]-ptr[b*3+1])+
(ptr[x*3+2]-ptr[b*3+2]);
}
}
}
}
if(sum=0)
{
ptr[a*3]=ptr[y*3];
ptr[a*3+1]=ptr[y*3+1];
ptr[a*3+2]=ptr[y*3+2];
ptr[b*3]=ptr[x*3];
ptr[b*3+1]=ptr[x*3+1];
ptr[b*3+2]=ptr[x*3+2];
}
Repaint();
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Image1Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------
以下ㄉ圖示我ㄉ介面:
|