Jump to content
  • Advertisement
Sign in to follow this  

Compare two images

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, This is the problem: I have a list of images and I must find which of these images match another image or is the most similar. I tried to find a library to compare two images without results. Maybe one of you can help me. Thanks. [Edited by - proglore on July 7, 2006 5:14:22 AM]

Share this post


Link to post
Share on other sites
Advertisement
I seem to remember something called xdelta which does binary comparison of files. You could get the output from that to find out which files are most/least different.

xdelta is open source though so you would of course have to open your entire program.

A possibly slow option is to subtract one image from another. The one that results in an image closest to black would be the closest match.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use self-organizing maps, such as Kohonen maps. An overview / example of the process can be found here: http://www.generation5.org/content/2004/aiSomPic.asp
When implemented correctly, this approach usually provides excellent results.

There's plenty of material online, documenting the properties and use of SOMs, so look that stuff up in your favourite search engine...

Share this post


Link to post
Share on other sites
You need to consider a lot of other transformations to get reasonably close to the usual meaning of "similar" wrt images.

Rotation, translation, cropping, scaling result in similar images most of the time, but a simple delta always classifies them as very different.

Share this post


Link to post
Share on other sites
The various definitions of "similar" images can mean different things.

Finding the similarity of images is a very hard problem for computers, with a lot of active research. Right now, that research makes a good masters or Ph.D. thesis.

As a simple example, imagine the Cornell Box (good example) of a square room, a light on the ceiling, and two objects -- each can be a box or a sphere.

Would you consider the image 'similar' if the lighting levels are different? Are they similar if the color is different? Are they similar if an object is moved a little bit? Are they similar if the scene is rotated? Are they similar if the rendering algorithms are changed so they produce different inter-object lighting effects or adding soft shadows? Are they similar if the sphere is made out of different materials, such as refractive glass, reflective steel, or a matte texture? Are they similar if the image has been processed by a simple convolution filter? Are they similar if they are rendered as a pen-and-ink drawing?

More complicated definitions of 'similar' can involve the incredibly difficult problems of object recognition, feature tracking, feature extraction, and image registration, just to name a few.

Good luck on your project.

Share this post


Link to post
Share on other sites
Hi, I'd recommend the opensource OpenCV library, which stands for Computer Vision.

It's a full-blown library which I used for a facial recognition app.

Site:
OpenCV

Google discussion (opencv answer):
Link

I admit it's probably to much for your needs, but it's capable of comparing two images using the following code:


CvArr* result = cvCreateImage(cvSize(1, 1), IPL_DEPTH_32F, 1);

cvMatchTemplate(img, img, result, CV_TM_CCORR_NORMED);

fprintf(stderr,"\n result: %lf \n", cvGetReal1D(result, 0));





I guess you should have no difficulty adjusting it for multiple images.

Greetings,

Starik

Share this post


Link to post
Share on other sites
Quote:
cvMatchTemplate(...CV_TM_CCORR_NORMED);


Nope. It would fail for the examples I gave above, unless you could take steps to identify a suitable template region. It would also fail when the template region (even though it is color-normalized) and all parts of the compared image are substantially different in terms of rendered elements.

What might work with intel's library would be an attempt to back-project in order to regenerate the object, but that goes back to an object recognition system.

Without a precise definition of "similar", everything we mention is a wild guess anyway.

Besides, what does "most similar" to a reference image really mean? If we changed a matte black sphere to each of a horizontally striped texture, a vertically striped texture, and a diagonally striped texture, which is most similar?

Share this post


Link to post
Share on other sites
Thanks to all for the replies.

I only know that the program must compare a image with a list of images and find which have the same shape but I don't know the complexity of the shape, only the next week I will have more information about the problem. Before the meeting I'd like to study the argument and with your advice I have a good point to start.

Sorry for my poor English. I must also study English.

Thanks again.
Lorenzo.



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!