| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1088 人关注过本帖
标题:[求助]请大家看看这个程序哪出错了?该怎么改~~谢谢
取消只看楼主 加入收藏
waityou05
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-6-9
收藏
 问题点数:0 回复次数:3 
[求助]请大家看看这个程序哪出错了?该怎么改~~谢谢

unit SmthMain;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls,SmthChd;

type
TSmthform1 = class(TForm)
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
Button3: TButton;
Button4: TButton;

procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }
end;

type
TemplateArray = array [0..7] of double;
TempAArray = array [0..19] of double;
TempBArray = array [0..19] of double;
TempUArray = array [0..17] of double;
TempMArray = array [0..13] of double;

var

oldbuf,newbuf:buf1;
winbuf:winarray;
Smthform1: TSmthform1;
CurrentFile,currentcaption:string;
Imgwidth,Imglenth:word;
ta:TemplateArray;
procedure InitTemplate();
function GetMax(ra:TemplateArray):double;


implementation

uses CommFunction;

{$R *.DFM}

procedure juanji(var oldbuf,newbuf:buf1);
var
i,j,k:Integer;
r:double;
x:Integer;
ra:TemplateArray;
filename:String;
begin
InitTemplate();
for i:=1 to 254 do
begin
for j:=1 to 254 do
begin
for k:=0 to 7 do
begin
r:=0;

r:=r+(oldbuf[i-1,j-1])*(ta[k mod 8]);
r:=r+(oldbuf[i-1,j])*(ta[(1+k) mod 8]);
r:=r+(oldbuf[i-1,j+1])*(ta[(2+k) mod 8]);
r:=r+(oldbuf[i,j+1])*(ta[(3+k) mod 8]);
r:=r+(oldbuf[i+1,j+1])*(ta[(4+k) mod 8]);
r:=r+(oldbuf[i+1,j])*(ta[(5+k) mod 8]);
r:=r+(oldbuf[i+1,j-1])*(ta[(6+k) mod 8]);
r:=r+(oldbuf[i,j-1])*(ta[(7+k) mod 8]);

ra[k]:=r;
end;
newbuf[i,j]:=Round(GetMax(ra));
end;
end;


end;


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;

搜索更多相关主题的帖子: Sender procedure TButton TObject 
2006-06-09 12:36
waityou05
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-6-9
收藏
得分:0 

[Error] Unit1.pas(1): Unit identifier 'SmthMain' does not match file name
[Fatal Error] Unit1.pas(7): File not found: 'SmthChd.dcu'



就这两错误

2006-06-09 15:56
waityou05
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-6-9
收藏
得分:0 

没有修改的可能吗?

2006-06-09 17:24
waityou05
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-6-9
收藏
得分:0 
基于数论变换(NTT)的旋转模板操作改进算法(图像处理中的)
2006-06-09 18:16
快速回复:[求助]请大家看看这个程序哪出错了?该怎么改~~谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019340 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved