📄 unit4.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "time.h"
#include "math.h"
#include "Ant.h"
#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
extern AntTool AT;
short **contour_x_coordinate_3 = new short*[10];//Setting 10 candidates of contour at most in an image.
short **contour_y_coordinate_3 = new short*[10];//Setting 10 candidates of contour at most in an image.
short *total_number_3 = new short(0);//count the total points of the contour
short *chain_code_3;
short *break_point_x_coordinate_3;
short *break_point_y_coordinate_3;
short *number_of_break_point_3 = new short(1);
//---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm4::EthlonBoundE1Click(TObject *Sender)
{
Form1->Show();
Form3->Hide();
Form4->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm4::SegmentBoundS1Click(TObject *Sender)
{
Form3->Show();
Form1->Hide();
Form4->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm4::OpenImage1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm4::SaveFileS1Click(TObject *Sender)
{
if(SavePictureDialog1->Execute())
Image1->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm4::Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
StatusBar1->Panels->Items[0]->Text="Coordinate: X: "+IntToStr(X)+" Y: "+IntToStr(Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm4::Image2MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
StatusBar1->Panels->Items[0]->Text="Coordinate: X: "+IntToStr(X)+" Y: "+IntToStr(Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm4::ContourTrackingC1Click(TObject *Sender)
{
Form4->Hide();
Form2->Show();
Form2->ProgressBar1->Min=0;
Form2->ProgressBar1->Max=10;
Image1->Picture->Bitmap->PixelFormat=pf24bit;
TImage* temp= new TImage(0);
temp->Picture->Bitmap->PixelFormat=pf24bit;
TRect TheRect=Rect(0,0,Image1->Width-1,Image1->Height-1);
temp->Picture->Bitmap->Height=Image1->Height;
temp->Picture->Bitmap->Width=Image1->Width;
Image2->Picture->Bitmap->Height=Image1->Height;
Image2->Picture->Bitmap->Width=Image1->Width;
chain_code_3 = new short[Image1->Height*Image1->Width]; //globe value
double start,end,tol_time;
start=clock();
int *count=new int(0);
short *count1=new short(0);
int *count2=new int(0);
int *data=new int [8];
int *range=new int(2*(Image1->Width+Image1->Height));
int *x_coordinate=new int[*range];
int *y_coordinate=new int[*range];
int *now_x_coor=new int(0);
int *now_y_coor=new int(0);
int *new_coor=new int[2];
int *the_s_x=new int(0);
int *the_s_y=new int(0);
int *the_l_x=new int(0);
int *the_l_y=new int(0);
short *contour_number = new short(0);
Form2->ProgressBar1->Position=2;
for(int y=1;y<Image1->Height-1;y++)
{
for(int x=1;x<Image1->Width-1;x++)
{
*count=0;
*count1=0;
byte *y_ptr =(byte*) Image1->Picture->Bitmap->ScanLine[y];
byte *x_ptr =y_ptr +3*x;
if(x_ptr[0]==0) //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -