Generate scale and colour invariant image hash

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
raoh
Posts: 3
Joined: 2012-06-26T09:39:06-07:00
Authentication code: 13

Generate scale and colour invariant image hash

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Generate scale and colour invariant image hash

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Generate scale and colour invariant image hash

Post 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.
Last edited by fmw42 on 2012-06-27T09:52:55-07:00, edited 2 times in total.
raoh
Posts: 3
Joined: 2012-06-26T09:39:06-07:00
Authentication code: 13

Re: Generate scale and colour invariant image hash

Post 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).
raoh
Posts: 3
Joined: 2012-06-26T09:39:06-07:00
Authentication code: 13

Re: Generate scale and colour invariant image hash

Post 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...
Post Reply