Alogorithim to compare two pictures
-
public static bool ImagesEqual(image1, image2) {
if (wid1!=wid2) return false;
if (hei1!=hei2) return false;
if (crc1!=crc2) return false;
foreach(PixelPair p1,p2 in image1,image2) if (p1!=p2) return false;
return true;
}Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Would use XOR functions ( blend with XOR , I think its possible with GDI images ... I used it some time ago to overlay two biztmaps to see where tehre is a differnce )
-
Hi, it depends what you like to match. If the pictures need to be exactly == binary identical, you could just use a md5 checksum, or something like this. If you want to search for "similar" pictures e.g. showing the same thing but scaled (image for email, etc. ) then you could use a cooccourence matrix over the colors in the image. If you want to check also if the contrast was changed then you need an even more elaborate algorithm, maybe doing a color histogram and then do a cross correllation. But these are only ideas... Regards, Tobias