views:

228

answers:

3
+1  A: 

I'd have thought your approach seems reasonable, but reducing an entire image to 1x1 pixel in size is probably a step too far.

However, if you converted each image to the same size and then computed the average colour in each 16x16 (or 32x32, 64x64, etc. depending on how much processing time/power you wish to use) cell you should be able to form some kind of sensible(-ish) comparison.

middaparka
Ended up using my code and since you said it was reasonable, then hey, you get the accepted answer
johnnyArt
A: 

Using middparka's methods, you can transform each image into a sequence of numeric values and then use the Levenshtein algorithm to find the closest match.

Bart van Heukelom
How can Levenshtein's algorithm help here? Quoting "The Levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other" and since all sequences are going to be formed by three 2digit numbers the number of operations is always going to be 3. Unless they have identical red, green or blue values, which doesn't necessarily mean it's the closest colour and whatsmore the similar-est image.
johnnyArt
And as a bonus, PHP already has a levenshtein function: http://php.net/manual/en/function.levenshtein.php
Marko
A: 

I would suggest, like middaparka, that you do not downsample to a 1 pixel only image, because you loose all the spatial information. Downsampling to 16x16 (or 32x32, etc.) would certainly provide better results.

Then it also depends on whether color information is important or not to you. From what I understand you could actually do without it and compute a gray-level image starting from your color image (e.g. luma) and compute the cross-correlation. If, like you said, there is a couple of images that matches exactly (except for color information) this should give you a pretty good reliability.

NeXuS