#include <vcl.h>
#pragma hdrstop
#include "SetThresholdValue.h"
#include "Unit1.h"
#include "SetThresholdValue.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Graphics::TBitmap *TheBitmap;
int OriW,OriH,y,x,q,Ty,Tx,Binary[480][640],Original[480][640],Original_Sobel[480][640];
int mask[3][3],Sobel_0[480][640],Sobel_45[480][640],Sobel_90[480][640],Sobel_135[480][640],Sobel[480][640];
int Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value[8];
int distance1,distance2,distance3,FMFED[480][640],Temp1[480][640];
int a;
void __fastcall TForm1::Open1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Form1->Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
TheBitmap=Form1->Image1->Picture->Bitmap;
OriW=TheBitmap->Width;
OriH=TheBitmap->Height;
}
Image1->Refresh();
}
void __fastcall TForm1::Save1Click(TObject *Sender)
{
if(SavePictureDialog1->Execute())
{
Form1->Image2->Picture->SaveToFile(SavePictureDialog1->FileName);
}
}
void __fastcall TForm1::Binary1Click(TObject *Sender)
{
a=Form1->ScrollBar1->Position;
for(y=0;y<=OriH;y++)
{
for(x=0;x<=OriW;x++)
{
if(Original[y][x]<=a)
{
Binary[y][x]=255;
}
else
{
Binary[y][x]=0;
}
::SetPixel(Form1->Image2->Canvas->Handle,x,y,RGB(Binary[y][x],Binary[y][x],Binary[y][x]));
}
}
Image2->Refresh();