Solved

An algorithm to compare two bitmaps

Posted on 2002-03-26
9
1,455 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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