主题:请大家帮忙看看这个程序哪出错了~谢谢
procedure kuaisu(var oldbuf,newbuf:buf1);
var
a:TempAArray;
b:TempBArray;
u:TempUArray;
m:TempMArray;
i,j,k:Integer;
r:double;
ra:TemplateArray;
begin
initTemplate();
b[0]:=ta[0]+ta[4];
b[1]:=ta[1]+ta[5];
b[2]:=ta[2]+ta[6];
b[3]:=ta[3]+ta[7];
b[4]:=b[0]+b[2];
b[5]:=b[1]+b[3];
b[6]:=((-(ta[0]-ta[4])+(ta[2]-ta[6]))-((ta[1]-ta[5])-(ta[3]-ta[7])))/2;
b[7]:=((-(ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])+(ta[3]-ta[7])))/2;
b[8]:=(((ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])+(ta[3]-ta[7])))/2;
b[9]:=(((ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])-(ta[3]-ta[7])))/2;
b[10]:=(-(b[0]-b[2])+(b[1]-b[3]))/4;
b[11]:=((b[0]-b[2])+(b[1]-b[3]))/4;
b[12]:=(b[4]+b[5])/8;
b[13]:=(b[4]-b[5])/8;
b[14]:=((ta[0]-ta[4])-(ta[3]-ta[7]))/2;
b[15]:=((ta[0]-ta[4])+(ta[1]-ta[5]))/2;
b[16]:=(ta[0]-ta[4])/2;
b[17]:=((ta[0]-ta[4])+(ta[2]-ta[6]))/2;
b[18]:=(-(ta[0]-ta[4])+(ta[2]-ta[6]))/2;
b[19]:=(b[0]-b[2])/4;
for i:=1 to 254 do
begin
for j:=1 to 254 do
begin
r:=0;
a[0]:=oldbuf[i-1,j-1]+oldbuf[i+1,j+1];
a[1]:=oldbuf[i-1,j]+oldbuf[i+1,j];
a[2]:=oldbuf[i-1,j+1]+oldbuf[i+1,j-1];
a[3]:=oldbuf[i,j+1]+oldbuf[i,j-1];
a[4]:=a[0]+a[2];
a[5]:=a[1]+a[3];
a[6]:=oldbuf[i-1,j-1]-oldbuf[i+1,i+1];
a[7]:=oldbuf[i-1,j]-oldbuf[i+1,j];
a[8]:=oldbuf[i-1,j+1]-oldbuf[i+1,j-1];
a[9]:=oldbuf[i,j+1]-oldbuf[i,j-1];
a[10]:=a[0]-a[2];
a[11]:=a[1]-a[3];
a[12]:=a[4]+a[5];
a[13]:=a[4]-a[5];
a[14]:=a[7]+a[9];
a[15]:=a[6]+a[8];
a[16]:=a[15]-a[14];
a[17]:=a[8]-a[9];
a[18]:=a[6]-a[7];
a[19]:=a[10]+a[11];
for k:=0 to 13 do
m[k]:=a[k+6]*b[k+6];
u[0]:=m[8]+m[10];
u[1]:=m[9]-m[10];
u[2]:=m[8]+m[11];
u[3]:=m[11]-m[2];
u[4]:=m[1]+m[12];
u[5]:=m[0]-m[12];
u[6]:=m[13]-m[5];
u[7]:=m[13]+m[4];
u[8]:=m[7]+m[6];
u[9]:=m[6]-m[7];
u[10]:=u[0]-u[2];
u[11]:=u[6]+u[8];
u[12]:=u[1]+u[3];
u[13]:=u[7]+u[9];
u[14]:=u[0]+u[4];
u[15]:=-u[6]+u[8];
u[16]:=u[1]+u[5];
u[17]:=-u[7]+u[9];
ra[0]:=u[10]+u[11];
ra[1]:=u[12]+u[13];
ra[2]:=u[14]+u[15];
ra[3]:=u[16]+u[17];
ra[4]:=-u[10]+u[11];
ra[5]:=-u[12]+u[13];
ra[6]:=-u[14]+u[15];
ra[7]:=-u[16]+u[17];
newbuf[i,j]:=Round(GetMax(ra));
end;
end;
end;
procedure TSmthform1.Button1Click(Sender: TObject);
{This is the open_image procedure}
begin
OpenDialog1.InitialDir:=ExtractFilePath(Application.Name);
OpenDialog1.Filter:='BMP Files (*.bmp)|*.bmp';
if opendialog1.execute then
begin
Smthform2:=TSmthform2.Create(self);
Smthform2.open(opendialog1.filename);
Smthform2.Left:=Smthform1.left div 5;
Smthform2.Top:=Smthform1.Top div 3;
Smthform2.ClientHeight:=Imglenth;
Smthform2.ClientWidth:=Imgwidth;
end;
Button2.Enabled:=True;
Button3.Enabled:=True;
end;
procedure TSmthform1.Button2Click(Sender: TObject);
var
left,top:word;
lastTime:Integer;
begin
Button3.Enabled:=False;
left:=2;top:=3;
bitmap:=activeMDIChild.GetFormImage;
Smthform2.readimg(oldbuf);
LastTime:=GetTickCount;
juanji(oldbuf,newbuf);
LastTime:=GetTickCount-LastTime;
Smthform2.creat(left,top,imglenth,imgwidth);
Smthform2.caption:='卷积算法'+inttostr(MDIchildcount-1);
SmthForm2.StatusBar1.Panels[0].Text:='使用时间:'+IntToStr(lastTime)+'毫秒';
Smthform2.showimg(newbuf);
end;
procedure TSmthform1.Button3Click(Sender: TObject);
var
left,top:word;
lasttime:Integer;
begin
Button2.Enabled:=False;
left:=4;top:=3;
bitmap:=activeMDIChild.GetFormImage;
Smthform2.readimg(oldbuf);
lastTime:=GetTickcount;
kuaisu(oldbuf,newbuf);
lastTime:=GetTickCount-LastTime;
Smthform2.creat(left,top,imglenth,imgwidth);
Smthform2.caption:='快速算法'+inttostr(MDIchildcount-1);
SmthForm2.StatusBar1.Panels[0].Text:='使用时间:'+IntToStr(lastTime)+'毫秒';
Smthform2.showimg(newbuf);
end;
procedure TSmthform1.FormActivate(Sender: TObject);
begin
if MDIChildCount>0
then begin
Button2.Enabled:=True;
Button3.Enabled:=True;
end
else begin
Button2.Enabled:=False;
Button3.Enabled:=False;
end;
end;
procedure TSmthform1.Button4Click(Sender: TObject);
begin
Close;
end;
procedure InitTemplate;
var
i:Integer;
begin
for i:=0 to 2 do
ta[i]:=1/3;
for i:=3 to 7 do
ta[i]:=-1/5;
end;
function GetMax(ra:TemplateArray):double;
var
i:Integer;
begin
Result:=abs(ra[0]);
for i:=1 to 7 do
begin
ra[i]:=abs(ra[i]);
if Result<ra[i] then
Result:=ra[i];
end;
end;
var
a:TempAArray;
b:TempBArray;
u:TempUArray;
m:TempMArray;
i,j,k:Integer;
r:double;
ra:TemplateArray;
begin
initTemplate();
b[0]:=ta[0]+ta[4];
b[1]:=ta[1]+ta[5];
b[2]:=ta[2]+ta[6];
b[3]:=ta[3]+ta[7];
b[4]:=b[0]+b[2];
b[5]:=b[1]+b[3];
b[6]:=((-(ta[0]-ta[4])+(ta[2]-ta[6]))-((ta[1]-ta[5])-(ta[3]-ta[7])))/2;
b[7]:=((-(ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])+(ta[3]-ta[7])))/2;
b[8]:=(((ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])+(ta[3]-ta[7])))/2;
b[9]:=(((ta[0]-ta[4])+(ta[2]-ta[6]))+((ta[1]-ta[5])-(ta[3]-ta[7])))/2;
b[10]:=(-(b[0]-b[2])+(b[1]-b[3]))/4;
b[11]:=((b[0]-b[2])+(b[1]-b[3]))/4;
b[12]:=(b[4]+b[5])/8;
b[13]:=(b[4]-b[5])/8;
b[14]:=((ta[0]-ta[4])-(ta[3]-ta[7]))/2;
b[15]:=((ta[0]-ta[4])+(ta[1]-ta[5]))/2;
b[16]:=(ta[0]-ta[4])/2;
b[17]:=((ta[0]-ta[4])+(ta[2]-ta[6]))/2;
b[18]:=(-(ta[0]-ta[4])+(ta[2]-ta[6]))/2;
b[19]:=(b[0]-b[2])/4;
for i:=1 to 254 do
begin
for j:=1 to 254 do
begin
r:=0;
a[0]:=oldbuf[i-1,j-1]+oldbuf[i+1,j+1];
a[1]:=oldbuf[i-1,j]+oldbuf[i+1,j];
a[2]:=oldbuf[i-1,j+1]+oldbuf[i+1,j-1];
a[3]:=oldbuf[i,j+1]+oldbuf[i,j-1];
a[4]:=a[0]+a[2];
a[5]:=a[1]+a[3];
a[6]:=oldbuf[i-1,j-1]-oldbuf[i+1,i+1];
a[7]:=oldbuf[i-1,j]-oldbuf[i+1,j];
a[8]:=oldbuf[i-1,j+1]-oldbuf[i+1,j-1];
a[9]:=oldbuf[i,j+1]-oldbuf[i,j-1];
a[10]:=a[0]-a[2];
a[11]:=a[1]-a[3];
a[12]:=a[4]+a[5];
a[13]:=a[4]-a[5];
a[14]:=a[7]+a[9];
a[15]:=a[6]+a[8];
a[16]:=a[15]-a[14];
a[17]:=a[8]-a[9];
a[18]:=a[6]-a[7];
a[19]:=a[10]+a[11];
for k:=0 to 13 do
m[k]:=a[k+6]*b[k+6];
u[0]:=m[8]+m[10];
u[1]:=m[9]-m[10];
u[2]:=m[8]+m[11];
u[3]:=m[11]-m[2];
u[4]:=m[1]+m[12];
u[5]:=m[0]-m[12];
u[6]:=m[13]-m[5];
u[7]:=m[13]+m[4];
u[8]:=m[7]+m[6];
u[9]:=m[6]-m[7];
u[10]:=u[0]-u[2];
u[11]:=u[6]+u[8];
u[12]:=u[1]+u[3];
u[13]:=u[7]+u[9];
u[14]:=u[0]+u[4];
u[15]:=-u[6]+u[8];
u[16]:=u[1]+u[5];
u[17]:=-u[7]+u[9];
ra[0]:=u[10]+u[11];
ra[1]:=u[12]+u[13];
ra[2]:=u[14]+u[15];
ra[3]:=u[16]+u[17];
ra[4]:=-u[10]+u[11];
ra[5]:=-u[12]+u[13];
ra[6]:=-u[14]+u[15];
ra[7]:=-u[16]+u[17];
newbuf[i,j]:=Round(GetMax(ra));
end;
end;
end;
procedure TSmthform1.Button1Click(Sender: TObject);
{This is the open_image procedure}
begin
OpenDialog1.InitialDir:=ExtractFilePath(Application.Name);
OpenDialog1.Filter:='BMP Files (*.bmp)|*.bmp';
if opendialog1.execute then
begin
Smthform2:=TSmthform2.Create(self);
Smthform2.open(opendialog1.filename);
Smthform2.Left:=Smthform1.left div 5;
Smthform2.Top:=Smthform1.Top div 3;
Smthform2.ClientHeight:=Imglenth;
Smthform2.ClientWidth:=Imgwidth;
end;
Button2.Enabled:=True;
Button3.Enabled:=True;
end;
procedure TSmthform1.Button2Click(Sender: TObject);
var
left,top:word;
lastTime:Integer;
begin
Button3.Enabled:=False;
left:=2;top:=3;
bitmap:=activeMDIChild.GetFormImage;
Smthform2.readimg(oldbuf);
LastTime:=GetTickCount;
juanji(oldbuf,newbuf);
LastTime:=GetTickCount-LastTime;
Smthform2.creat(left,top,imglenth,imgwidth);
Smthform2.caption:='卷积算法'+inttostr(MDIchildcount-1);
SmthForm2.StatusBar1.Panels[0].Text:='使用时间:'+IntToStr(lastTime)+'毫秒';
Smthform2.showimg(newbuf);
end;
procedure TSmthform1.Button3Click(Sender: TObject);
var
left,top:word;
lasttime:Integer;
begin
Button2.Enabled:=False;
left:=4;top:=3;
bitmap:=activeMDIChild.GetFormImage;
Smthform2.readimg(oldbuf);
lastTime:=GetTickcount;
kuaisu(oldbuf,newbuf);
lastTime:=GetTickCount-LastTime;
Smthform2.creat(left,top,imglenth,imgwidth);
Smthform2.caption:='快速算法'+inttostr(MDIchildcount-1);
SmthForm2.StatusBar1.Panels[0].Text:='使用时间:'+IntToStr(lastTime)+'毫秒';
Smthform2.showimg(newbuf);
end;
procedure TSmthform1.FormActivate(Sender: TObject);
begin
if MDIChildCount>0
then begin
Button2.Enabled:=True;
Button3.Enabled:=True;
end
else begin
Button2.Enabled:=False;
Button3.Enabled:=False;
end;
end;
procedure TSmthform1.Button4Click(Sender: TObject);
begin
Close;
end;
procedure InitTemplate;
var
i:Integer;
begin
for i:=0 to 2 do
ta[i]:=1/3;
for i:=3 to 7 do
ta[i]:=-1/5;
end;
function GetMax(ra:TemplateArray):double;
var
i:Integer;
begin
Result:=abs(ra[0]);
for i:=1 to 7 do
begin
ra[i]:=abs(ra[i]);
if Result<ra[i] then
Result:=ra[i];
end;
end;