Comparar imagens

Delphi

08/06/2006

Boa tarde a todos...

Amigos... eh possivel comparar dois bitmaps???

Bem, gostaria de compara-los, mas permitir um grau de relevância, afinal gostaria de saber se eles são semelhantes....

Alguem pode ajudar-me nesta missão??

Abraço a todos :wink:


Aloizio Castro

Aloizio Castro

Curtidas 0

Respostas

Aloizio Castro

Aloizio Castro

08/06/2006

Pessoal, cheguei a seguint conclusao:

function TFSenhaVisual.CompImagens(img1, img2: TBitmap): Integer;
var
  i, j : Integer;
begin
  if (img1.Width <> img2.Width) or (img1.Height <> img2.Height) then
    begin
      Result := 100;
      Exit;
    end;

  Result := 0;

  for i := 0 to img1.Height-1 do
    for j := 0 to img1.Width-1 do
    if img1.Canvas.Pixels[j,i] <> img2.Canvas.Pixels[j,i] then
      begin
        Inc( Result );
        //Break;
      end;

  //-- Converte Qtde para porcentagem
  Result := Result * 100 div (img1.Width * img1.Height);

end;


Obrigado ateh mesmo a quem somente olhou o topico :D


GOSTEI 0
POSTAR