图象差分算法
RGBMAP : Array [0..639,0..479,0..2] of byte;
//清晰度的算法
Function AF_Definition(StartX, StartY, Width, Height:integer):single;
Var
Result_Y: double;
X1,Y1 :integer;
Y_C,Y_U,Y_D,Y_R,Y_L: double;
begin
Result_Y:=0;
IF (StartX=0) OR (StartY=0) then
begin
StartX:=1;
StartY:=1;
end;
For X1 :=StartX to (StartX+Width-2) do
begin
For Y1 :=StartY to (StartY+Height-2) do
begin
Y_C :=0.299*RGBMAP[X1][Y1][2]+0.578*RGBMAP[X1][Y1][1]+0.114*RGBMAP[X1][Y1][0];
Y_L :=0.299*RGBMAP[X1-1][Y1][2]+0.578*RGBMAP[X1-1][Y1][1]+0.114*RGBMAP[X1-1][Y1][0];
Y_R :=0.299*RGBMAP[X1+1][Y1][2]+0.578*RGBMAP[X1+1][Y1][1]+0.114*RGBMAP[X1+1][Y1][0];
Y_U :=0.299*RGBMAP[X1][Y1-1][2]+0.578*RGBMAP[X1][Y1-1][1]+0.114*RGBMAP[X1][Y1-1][0];
Y_D :=0.299*RGBMAP[X1][Y1+1][2]+0.578*RGBMAP[X1][Y1+1][1]+0.114*RGBMAP[X1][Y1+1][0];
Result_Y:=Abs(Y_C-Y_L)+Abs(Y_C-Y_R)+Abs(Y_C-Y_U)+Abs(Y_C-Y_D)+Result_Y;
end;
end;
Result:=Result_Y/1000;
end;
procedure FillRGBMAP(D:integer);
var
X1,Y1,i,R,G,B: integer;
C: longint;
StrTmp : string;
Mybmp :Tbitmap;
begin
Mybmp := Tbitmap.Create ;
StrTmp:=IntToStr(D);
StrTmp:=format('%0.3d',[StrToInt(StrTmp)]);
try
Mybmp.LoadFromFile('c:\test\test('+ StrTmp +').bmp');
for i :=0 to 255 do
Gray[i]:=0;
For Y1 := 0 to BMPHeight-1 do
begin
For X1 := 0 to BMPWidth-1 do
begin
C := Mybmp.Canvas.Pixels[X1,Y1];
R := C and $FF;
G := ((C and $FF00) div $100);
B := ((C and $FF0000) div $10000);
RGBMAP[X1][Y1][0]:= B;
RGBMAP[X1][Y1][1]:= G;
RGBMAP[X1][Y1][2]:= R;
end;
end;
except
MessageDlg('Image File Format Error , RePlugin Again!!',mtConfirmation, [mbOK], 0);
end;
end;