[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] comparing image files



At 8:07 AM -0700 9/10/99, Rich Morin wrote:
>I'm interested in comparing image files, in order to find duplicates.
>Because there are several thousand files, an NxN comparison is out of
>the question.  Also, it is quite possible that some of the images may
>have been resized or tweaked in other manners, so the comparison will
>not be an exact one.
<snip>

>   *  expanding JPEGs into pixmaps
>   *  signature creation
>   *  non-exact signature comparisons

I can't really help you with expanding into pixmaps, but I have a feeling
that gd might be able to do it?

As for signature creation, and non-exact comparisons, here's my thinking.

If all of your images were the *same* size, it would be much easier.  You
could just compute a pix by pix difference between each image, and decide
if the difference fell into an equality range (i.e., is less than some
amount).

Since the images are potential completely different, you are going to have
to create some sort of normalized signature.  My suggestion is:
1) figure out how big your biggest image is, and how big your smallest image is
2) for each image, figure out where it falls into that range
3) divide the image up into p by p sections, with the size of each section
determined by the result from 2
4) compute an aggregate function (like average brightness) for all pixels
in each section.
5) This will give you a signature of p^2 values.
6) Do the same kind of comparison for each value that I suggested for
images of the same size.
       if ($image1{'key'}[x][y] - $image2{'key'}[x][y] < $threshold) then {
            #images are the same
	}

I'd pick an aggregating function that has some "knowledge" about what makes
an image "the same".  Average brightness is a very poor choice for most
things (starfields being a potential exception).  You could do edge
detection, and use the number of edges in a section as a key.  You could do
a count of all pixels that are "flesh toned", for comparing images of
questionable morality.

-Jeff Lowrey



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org