[Gambas-user] Comparing 2 pictures

Doriano Blengino doriano.blengino at ...1909...
Mon Aug 10 14:42:56 CEST 2009


richard terry ha scritto:
> Hi all,
>
> i wondered if anyone could tell me how to comparea picture1 to picture 2 and 
> tell if they were different (ie one had been changed in some way?
>   
This is very difficult, if your images are slightly different but a 
human would say they are the same.

I explain better. If two images differ by only one pixel, then a binary 
comparison fails. So a binary comparison can not work, unless you know 
your two images should be *exactly* the same (I think no...)

There is a program called GQView (and probably others) which have 
algorithms to compare two images in the right way - ie scale them to 
same size, compress colors and normalize them, then compare pixel by 
pixel using a good tolerance.
I did something similar, it is  a pascal source (if I only remember 
where I put it); or you can download those sources and look into them (C 
sources, I suppose).

My algorithm works well enough if the images are about the same, but it 
is fooled if one image has a colored frame around and the other not, or 
if one image is contained in the other, or one is a shifted version of 
the other, and so on. May be that GQView has better way to recognize. 
But I repeat, it is difficult and CPU demanding, perhaps too much for an 
interpreted language.

Regards,
Doriano





More information about the User mailing list