有两张相像的图片,请问怎样比较这两张图片的相似程度??谢谢
解决方案 »
- 最近升级IE浏览器怎么都升级不了,不怎么什么原因????
- indy10 的 Idtcpserver 使用造成内存泄漏问题
- 怎样通过ado接口再不同数据库之间转换数据?
- 急手问题
- 谁知道[email protected]是谁,我出1000分!
- 有点难度的DBGrid问题。急。。。。。在线等待。。。
- 请问THeapStatus有意思是什么啊
- 程序里面如何从Internet上面获得实时的外汇牌价信息?
- 怎么样在edit里写入一个小数?
- TommyTong(童童) chechy(chechy) kevin_gao(困了!累了!睡觉了!)
- 如何可以判断两个label重叠了
- 初学网络编程卡主了!自动登录的问题
procedure TFrm_test.initList;
var
idx, i, k, x, y, l: integer;
p, fn: string;
bmp: TBitmap;
BColor, NowColor: TColor;
begin p := ExtractFilePath(Application.ExeName);
bmp := TBitmap.Create;
for i := 0 to 9 do
begin
fn := p + '\CodeBmp\' + IntToStr(i) + '.bmp';
if not FileExists(fn) then
Continue; idx := length(PointRecList);
SetLength(PointRecList, idx + 1);
PointRecList[idx].Code := inttostr(i); bmp.LoadFromFile(fn);
BColor := bmp.Canvas.Pixels[0, bmp.Height - 1]; for x := 0 to bmp.Width - 1 do
for y := 0 to bmp.Height - 1 do
begin
NowColor := bmp.Canvas.Pixels[x, y];
if NowColor <> BColor then
begin
l := length(PointRecList[idx].PointList);
SetLength(PointRecList[idx].PointList, l + 1);
PointRecList[idx].PointList[l].X := x;
PointRecList[idx].PointList[l].y := y;
end;
end;
end; FreeAndNil(bmp);
//
end;
function getCode_Bmp(const bmp: TBitmap; strLen: integer; PointRecList: array of TPointRec): string;
var
j, i, l, x, y, x0, xS, beginx: integer; BColor, NowColor: TColor;
PointList: array of TPoint;
function getCode: string;
var
maxCount, k, m, j, i: integer; begin
Result := '?';
if length(PointList) < 3 then
exit; maxCount := 0;
for i := 0 to high(PointRecList) do
begin if length(PointRecList[i].PointList) < 3 then
Continue; m := 0; for K := 1 to high(PointList) do
begin for j := 1 to high(PointRecList[i].PointList) do
if
((PointList[k].X - PointList[0].X) = (PointRecList[i].PointList[j].X - PointRecList[i].PointList[0].X))
and
((PointList[k].y - PointList[0].y) = (PointRecList[i].PointList[j].y - PointRecList[i].PointList[0].y)) then
begin
inc(m);
Break;
end; end; m := m * 100 div (length(PointList) - 1);
if m > maxCount then
begin
Result := PointRecList[i].Code;
maxCount := m;
end;
end;
end;begin
Result := ''; BColor := bmp.Canvas.Pixels[0, bmp.Height - 1];
x0 := 0;
xS := bmp.Width div strLen;
for i := 0 to strLen - 1 do
begin
beginx := x0 + xS * i;
SetLength(PointList, 0);
for j := 0 to xS - 1 do
begin
x := beginx + j;
for y := 0 to bmp.Height - 1 do
begin
NowColor := bmp.Canvas.Pixels[x, y];
if NowColor <> BColor then
begin
l := length(PointList);
SetLength(PointList, l + 1);
PointList[l].X := x;
PointList[l].y := y;
end;
end;
end;
Result := Result + getCode;
end;
end;