Solved

An algorithm to compare two bitmaps

Posted on 2002-03-26
9
1,459 Views
Last Modified: 2009-12-16
Hello,
I want to compare two bitmaps (Which are supposed to be similar or almost similar) . I could have done it with a loop that checks the diffrences of every two pixels, but it takes a very long time....
Does anybody knows of an algorithm or an API function that does this?
Thanks,   Libby
0
Comment
Question by:libbysharf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6896024
Have a look at the help for TBitmap.Scanline
It gives you fast access to a whole line of the bitmap.
0
 
LVL 9

Accepted Solution

by:
ginsonic earned 100 total points
ID: 6896362
procedure TForm1.Button1Click(Sender: TObject);
var MemStream:TMemoryStream;
    S1,S2:string;
begin
  MemStream := TMemoryStream.Create;
  try
    Image1.Picture.Bitmap.SaveToStream(MemStream);
    MemStream.Position := 0;
    SetLength(S1, MemStream.Size);
    MemStream.Read(S1[1], Length(S1));
    MemStream.Clear;
    Image2.Picture.Bitmap.SaveToStream(MemStream);
    MemStream.Position := 0;
    SetLength(S2, MemStream.Size);
    MemStream.Read(S2[1], Length(S2));
  finally
    MemStream.Free;
  end;
  if S1 = S2 then
   ShowMessage('are identically')
  else
   ShowMessage('not');
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6897155
Strange thing . I was notified that someone have input an answer here .

Anybody have received same notification ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:lopem
ID: 6897283
listening...
0
 
LVL 6

Expert Comment

by:edey
ID: 6897433
one method that has worked pretty well for me, if and _ONLY_IF_ both bitmaps are the same size (ie, one is an edited copy of the other), is to simply XOR one bmp over the other & then compress it. The smaller the resulting compressed stream, the more zeros there were in the XOR'ed stream and hence, the more similar the original streams should have been.

GL
Mike
0
 
LVL 1

Expert Comment

by:MBo
ID: 6897584
I've written short answer. It looks like some trouble
(Just registered ;( )
I proposed to use GetDIBits to compare arrays in memory
and Intel Image Processing Library for the fastest treatment
0
 
LVL 6

Expert Comment

by:edey
ID: 6897742
i guess, in order to be of more help, we need to know more about the images you're comparing & what you would consider "similar" to mean. Without that all we can do is sugest special case solutions, or hints towards implementations without really touching the problem of a specific algo at all.

GL
Mike
0
 
LVL 15

Expert Comment

by:simonet
ID: 6898665
peeking...
0
 

Author Comment

by:libbysharf
ID: 6898729
Hello,
Thanks for your answers, I finally managed to do it with the help of this site:
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm
it explains everything about scanline
I'll give the points to ginsonic for the effort :)
Libby
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 119
Find and Replace Stream with 0s 8 73
Twebbrowser add css to the header 3 39
delphi popmenu non latine charcters 3 35
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question