[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:
>>>   *  expanding JPEGs into pixmaps
>
>>I can't really help you with expanding into pixmaps, but I have a feeling
>>that gd might be able to do it?
>
>Only with GIFs (or PNGs, if you have the new one).  There is ImageMagick
>that does JPEGs I think, but I don't know much about it.  And I really
>don't have any ideas about comparing nonexact images, so I'll shut up now.
>:)

You don't really need GD, or ImageMagick or any image-handling software 
to do the actual comparison.  What this boils down to is a "nearest 
neighbor" problem.  You want to look for images that have similar 
patterns, so you need an algorithm to do some sort of similarity mapping. 
 Try looking for info on "k-d trees".  The new O'Reilly book "Mastering 
Algorithms with Perl" has some interesting items in Chapter 10 (available 
online in PDF form even!):

http://www.oreilly.com/catalog/maperl/chapter/ch10.pdf

Another idea is to use bit-interleaving to create a unique key based on 
the internal structure of the file.  Treat the file as a string of bits.  
Find the mid-point in the string, and fold the string back on itself.  
Bits from the front half of the file become the odd-numbered bits of the 
key, and bits from the back half become the even-numbered bits of the 
key.  Files that are similar will have similar keys, so performing a sort 
of the keys, gives you a list of files sorted by similarity!  You could 
even truncate the key to it's first few (oh about 32) bits, and it should 
still work.

Don't ask me exactly how to do this in Perl.

--B

# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


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