⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.cpp

📁 利用蚂蚁演算法侦测物件支配点研究之原始码
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
#include "time.h"
#include "math.h"
#include "Ant.h"
#include "Genetic algorithm tool.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
extern AntTool AT;
Genetic_algorithm_tool GA;
//extern short *tryextern; //global variable
TImage* global_temp= new TImage(0);
short **contour_x_coordinate_2 = new short*[10];//Setting 10 candidates of contour at most in an image.
short **contour_y_coordinate_2 = new short*[10];//Setting 10 candidates of contour at most in an image.
short *total_number_2 = new short(0);//count the total points of the contour
short *chain_code_2;
short *break_point_x_coordinate_2;
short *break_point_y_coordinate_2;
short *number_of_break_point_2 = new short(0);
short *supporting_region_2;
double *K_cosine_2;
short *number_of_initial_point_2 = new short(0);
short *initial_solution_x_coordinate_2;
short *initial_solution_y_coordinate_2;
short *scaled_x_coordinate;
short *scaled_y_coordinate;
bool *open_chain_code = new bool (false);
TImage *chain_code_IMG = new TImage(0);
TRect chain_code_source;
short *Coordinate; 

//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm3::EthlonBoundE1Click(TObject *Sender)
{
   Form1->Show();
   Form3->Hide();
   Form4->Hide();
}
//---------------------------------------------------------------------------

void __fastcall TForm3::CharacterC1Click(TObject *Sender)
{
   Form4->Show();
   Form3->Hide();
   Form1->Hide();

}
//---------------------------------------------------------------------------





void __fastcall TForm3::Image1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
     StatusBar1->Panels->Items[0]->Text="Coordinate:  X: "+IntToStr(X)+" Y: "+IntToStr(Y);

}
//---------------------------------------------------------------------------


void __fastcall TForm3::ContourTrackingC1Click(TObject *Sender)
{
  Form3->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;
  global_temp->Picture->Bitmap->Height=Image1->Height;
  global_temp->Picture->Bitmap->Width=Image1->Width;
//  Image2->Picture->Bitmap->Height=Image1->Height;
//  Image2->Picture->Bitmap->Width=Image1->Width;
   chain_code_2 = new short[Image1->Height*Image1->Width]; //global variable
   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);
   short replace;
   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 + -