[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

An algorithm to compare two bitmaps

Posted on 2002-03-26
9
Medium Priority
?
1,469 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

873 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