Page 1 of 1

Generate scale and colour invariant image hash

Posted: 2012-06-26T13:09:48-07:00
by raoh
Hi,

I'm new to image processing. I need to generate a hash for each image to group the similar images together. The hash needs to be:

- Scale invariance - an image must have the same hash as a resized version of itself
- Artifact tolerance - a PNG image recompressed as a JPEG must have the same hash
- Colour tolerance - a true colour PNG saved as a GIF must have the same hash

How can I do that using ImageMagick or I should look somewhere else?

Many thanks

Re: Generate scale and colour invariant image hash

Posted: 2012-06-26T17:57:23-07:00
by anthony
'Hash' is also, not a good term for this. A 'hash' is generally designed to become VERY DIFFERENT on small changes, as a test for such changes. A 'signature' on the other hand is the opposite, it should be similar or better still the same for images with only a few changes.

Getting exactly matching 'signatures' is also not really possible. You can try to make them close if the image is close, but any sort of image processing (like resize or jpg compression) will generally produce some changes, resulting in minor signature changes (or major hash changes :-) )

Image 'metrics' is usually better as a 'multi-valued' signature. But then 'closeness' is measured in a N-dimentional space, and specialised 'closeness' measuring routines is needed.

Some methods of grouping images (by metrics) are talked about in IM examples, Comparing Images, Image Metrics
http://www.imagemagick.org/Usage/compare/#metrics

The last metric 'Difference of Neighbours' is probably the best signature generation method I have found, though it is still multi-valued. Comparisions of the signature however can be devolved to 'how many metric bits are different'

The other technique is to look for 'basic color ellipses' in the image and not the general color size and position of those ellipses. any ime that is similar will have a similar grouping of ellipses. I have not tried to implement this technique so have no esperience with it.

Re: Generate scale and colour invariant image hash

Posted: 2012-06-26T18:00:51-07:00
by fmw42
Some or all of the image metrics reported by -feature might possibly do what you want. Otherwise, image moments can be scale and rotation invariant. see http://en.wikipedia.org/wiki/Image_moment

At some future time it would be nice get these moments added to the -feature metrics.

Re: Generate scale and colour invariant image hash

Posted: 2012-06-27T06:47:22-07:00
by raoh
Thank you all!

As I'm just started to do this, there are quite a lot to learn. I'll do some researches based on your suggestions and hopefully come back with a solution (or more questions).

Re: Generate scale and colour invariant image hash

Posted: 2012-06-28T06:57:49-07:00
by raoh
Btw, what I need to do is to be able to create a same signature for images like these 2:

http://creative.ak.fbcdn.net/v565063/fl ... 7c9eb5.jpg

http://creative.ak.fbcdn.net/v565063/fl ... 734d28.jpg

Keep researching...