Solved

An algorithm to compare two bitmaps

Posted on 2002-03-26
9
1,452 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
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
 
LVL 3

Expert Comment

by:lopem
ID: 6897283
listening...
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now