10

in my project i need to compare to images. One image shows a render-model and the other image is a photo, in which the real object, which is represented in the model, is shown. What i exactly want:

  • The algorithm has to compare the two images and return a number, that describes the similarity. Let's say the lower the number is, the better the images fit together.
  • Both images are represented as binary images which only contain the contours / edges of the real render-image / photo.
  • The photo has a lot more objects in it than the render-image. So i only want to check if the viewpoint to the render-object is nearly the same than the viewpoint to the real object in the photo. (Example: A car is modelled so it approximates a real car. I take a photo of the real car from a special position and orientation. Now i want to check, if the position and orientation of my virtual camera looking at the render-car is nearly the same, than the position and orientation of my real-life-camera). The solution is only to compare the white pixels of the render image to the pixels of the photo (as edge-image). The other pixels are not interesting.
  • The returned value of the image-comparision should decrease the better my orientation and position of the virtual camera fits to the real camera's orientation and position.

I tried to calculate the euclidian distance of the two images but the result is only good, when the pixels exactly fit to each other. Now i am searching for alterantives.

Until now i considered to use the normalized cross-correlation, but i really dont know if it fits to my task.

The question is, if the normalized cross-correlation is worth a try or if there are better methods of solving my problem!

The algorithm should be as fast as possible, because i compare a lot of images.

Thanks a lot


Thanks for your suggestions. I am a little confused due to the fact that the normalized cross-corellation and Haussdorff distance seem to be good for finding a small pattern in a big picture.

The question is: Are the two algorithms also good for comparing 2 pictures of the same size?

Here is an example of 2 images that have to be compared. At the moment i am comparing around 120 pictures-paires a second.

Too bad that i cannot post images as a new user. So here is the direct link: http://s14.directupload.net/file/d/2674/t8qzbq9i_png.htm

user987979
  • 111
  • 1
  • 1
  • 8
  • Link to an example has been posted. – user987979 Oct 11 '11 at 13:24
  • +1 for interesting question. Can you post the images before you edge-detect them, as well? It would help add some context to your question. – mpenkov Oct 11 '11 at 15:32
  • Well in general the upper image shows only a rendered model of the building that is shown in the second image. Both images are 8-bit grayscale images. The task now is to set the virtual camera at the same position and orientation than the real-life camera. This has to be realized by comparing a lot of renderings (with different camera poses) with the real photo. – user987979 Oct 11 '11 at 20:23

2 Answers2

4

How about experimenting with the Haussdorff distance as a starting point? General idea and c implementation here. Article here:

Comparing images using the Hausdorff distance, by DP Huttenlocher - 1993.

Erdogan Kurtur
  • 3,630
  • 21
  • 39
Maurits
  • 2,082
  • 3
  • 28
  • 32
1

You could also check-out cosine similarity. I used it with great success on detecting cut-scenes in a video stream. Essentially, you treat the entire image as a 1D vector, and proceed with the cosine similarity measure. Basically, small angles mean a close match, and large values mean there is a mismatch. The thresholds would need some tuning for your dataset, but it might work, and it's very fast.

Normalized cross-correlation should be more robust, but it will take a bit more time. Since you mentioned needing to handle different poses you should also look at a feature detection and extraction solution. Have a look at opencv's matcher_simple.cpp and matching_to_many_images.cpp samples. These techniques have some tolerance for scale and rotation differences.

Hope that's helpful!

mevatron
  • 13,911
  • 4
  • 55
  • 72
  • 1
    For high dimensional data, such as an image, I would not expect any significant difference between the euclidean distance and cosine similarity. – Maurits Oct 10 '11 at 22:21