views:

4683

answers:

13

I need an algorithm that can determine whether two images are 'similar' and recognizes similar patterns of color, brightness, shape etc.. I might need some pointers as to what parameters the human brain uses to 'categorize' images. ..

I have looked at hausdorff based matching but that seems mainly for matching transformed objects and patterns of shape.

edit

thanks a lot guys, the input should help me greatly!

+1  A: 

You could perform some sort of block-matching motion estimation between the two images and measure the overall sum of residuals and motion vector costs (much like one would do in a video encoder). This would compensate for motion; for bonus points, do affine-transformation motion estimation (compensates for zooms and stretching and similar). You could also do overlapped blocks or optical flow.

Dark Shikari
+1  A: 

You could use Perceptual Image Diff

It's a command line utility that compares two images using a perceptual metric. That is, it uses a computational model of the human visual system to determine if two images are visually different, so minor changes in pixels are ignored. Plus, it drastically reduces the number of false positives caused by differences in random number generation, OS or machine architecture differences.

Alejandro Bologna
+1  A: 

As a first pass, you can try using color histograms. However, you really need to narrow down your problem domain. Generic image matching is a very hard problem.

Dima
+3  A: 

It's a difficult problem! It depends on how accurate you need to be, and it depends on what kind of images you are working with. You can use histograms to compare colours, but that obviously doesn't take into account the spatial distribution of those colours within the images (i.e. the shapes). Edge detection followed by some kind of segmentation (i.e. picking out the shapes) can provide a pattern for matching against another image. You can use coocurence matrices to compare textures, by considering the images as matrices of pixel values, and comparing those matrices. There are some good books out there on image matching and machine vision -- A search on Amazon will find some.

Hope this helps!

Ben
A: 

There are some good answers in the other thread on this, but I wonder if something involving a spectral analysis would work? I.e., break the image down to it's phase and amplitude information and compare those. This may avoid some of the issues with cropping, transformation and intensity differences. Anyway, that's just me speculating since this seems like an interesting problem. If you searched http://scholar.google.com I'm sure you could come up with several papers on this.

dbrien
spectral analysis is wth Fourier Transform, there isn't a color-histogram since you can reconstruct the image from the two parts --imaginary and real. (don't know if it'll work, just letting you know it isn't in that category).
nlucaroni
Yes, a Fourier Transform is what I meant.
dbrien
A: 

It's been awhile since I did computer vision, but check out Matlab, there are some good functions in there for analyzing images and then comparing the similarity of the resulting matrices, based on various metrics for your comparison.

Mason
+2  A: 

This sounds like a vision problem. You might want to look into Adaptive Boosting as well as the Burns Line Extraction algorithm. The concepts in these two should help with approaching this problem. Edge detection is an even simpler place to start if you're new to vision algorithms, as it explains the basics.

As far as parameters for categorization:

  • Color Palette & Location (Gradient calculation, histogram of colors)
  • Contained Shapes (Ada. Boosting/Training to detect shapes)
Abyss Knight
A: 

Depending on how much accurate results you need, you can simply break the images in n x n pixels blocks and analyze them. If you get different results in the first block you can't stop processing, resulting in some performance improvements.

For analyzing the squares you can for example get the sum of the color values.

+1  A: 

Some image recognition software solutions are actually not purely algorithm-based, but make use of the neural network concept instead. Check out http://en.wikipedia.org/wiki/Artificial_neural_network and namely NeuronDotNet which also includes interesting samples: http://neurondotnet.freehostia.com/index.html

petr k.
+13  A: 

I have done something similar, by decomposing images into signatures using wavelet transform.

My approach was to pick the most significant n coefficients from each transformed channel, and recording their location. This was done by sorting the list of (power,location) tuples according to abs(power). Similar images will share similarities in that they will have significant coefficients in the same places.

I found it was best to transform in the image into YUV format, which effectively allows you weight similarity in shape (Y channel) and colour (UV channels).

You can in find my implementation of the above in mactorii, which unfortunately I haven't been working on as much as I should have :-)

Another method, which some friends of mine have used with surprisingly good results, is to simply resize your image down to say, a 4x4 pixel and store that are your signature. How similar 2 images are can be scored by say, computing the Manhattan distance between the 2 images, using corresponding pixels. I don't have the details of how they performed the resizing, so you may have to play with the various algorithms available for that task to find one which is suitable.

Cheers,
Steve

freespace
hey that's a nice project of yours, thanks for the link!
kitsune
The resize to 4x4 method is a awesome idea (not that your method isn't great too) but the first is simpler.
Alix Axel
+1  A: 

There is related research using Kohonen neural networks/self organizing maps

Both more academic systems (Google for PicSOM ) or less academic
( http://www.generation5.org/content/2004/aiSomPic.asp , (possibly not suitable for all work enviroments)) presentations exist.

EPa
+3  A: 

I've used SIFT to re-detect te same object in different images. It is really powerfull but rather complex, and miht be overkill. If the images are supposed to be pretty similar some simple parameters based on the difference between the two images can tell you quite a bit. Some pointers:

  • Normalize the images i.e. make the average brightness of both images the same by calculating the average brightness of both and scaling the brightest down according to the ration (to avoid clipping at the highest level)) especially if you're more interested in shape than in colour.
  • Sum of colour difference over normalized image per channel.
  • find edges in the images and measure the distance betwee edge pixels in both images. (for shape)
  • Divide the images in a set of discrete regions and compare the average colour of each region.
  • Threshold the images at one (or a set of) level(s) and count the number of pixels where the resulting black/white images differ.
jilles de wit
+6  A: 

pHash might interest you.

perceptual hash n. a fingerprint of an audio, video or image file that is mathematically based on the audio or visual content contained within. Unlike cryptographic hash functions which rely on the avalanche effect of small changes in input leading to drastic changes in the output, perceptual hashes are "close" to one another if the inputs are visually or auditorily similar.

Alvis