10 Oct

finding the points where two similar images overlap

Take a look at this:


So? It’s two photographs that overlap. What’s so special about that?

What’s special is that the overlapping was done by my computer. It’s the first step towards computer vision for my robots.

See, in order for my bots to know where they are visually, they must be able to compare a real-life camera view to a rendered internal model. The above overlap thing is a first step towards that internal model.

What happened to get the overlap coordinates, is that the two separate images were compared to each other at different points. The closest match (according to the algorithm I created) is the overlap you see above.

It is possible, with this method, to determine how far away most things are, making it possible to build up a 3D model of the world through photographs.

The script is written in PHP at the moment (available here). I want to do a bit more debugging and optimisation on it before porting it to C.

The next step will be to build up a simple 3D copy of a room based on photographs.

7 thoughts on “finding the points where two similar images overlap

  1. Do you think it is possible to create a script to compare an image to a collection of images for similarities based on your overlapping algorithm??
    Check this one out : http://www.crown-s-soft.com/sifinder.htm
    I wanted to do something like that but in PHP.

    I am running a pretty huge image gallery and there are lots of images submission everyday. Currently the only way to check for similar images is to recall from memory if the image is already in the collection or not. No matter how powerful the human brain is, some images slip by every now and then resultin gin duplicates. I hope to somehow use PHP to to facilitate the job of the approval. I have seen a script done in Perl and Imagemagick(http://www.stonehenge.com/merlyn/LinuxMag/col50.html&e=912) so I think it can be done in PHP too.

    What do you think? Please write to me.

  2. Roy, yes. I think it should be fairly simple to write a script which compares two photographs. Simply compare the RGB values separately for each pixel of the two images, and work out the mean square difference. Images that are similar will have very low MSD values. Images that are identical will have a value of 0.

  3. What a relief it is to have found your site.  I’ve been looking for this type of PHP script for a while, and am too much of a newbie to write it.  Whew!  Anyhow, I cant seem to get all the code when I click on the link to download it.  Would it be possible to get the complete source? Thanks!RobPS – Congrats on your marriage!  Pics are great :) 

  4. Rob, the link that says “available here” in the article links to the source. Unfortunately, I haven’t gone further with that script yet (working on a lot of stuff at the same time!), but just this week, I finished a preliminary build of my robot, so will probably take this a bit further soon.

  5. Thanks for the quick reply, sorry I didnt get back sooner, I was out of town.  Hmmm.  About the source, it starts with “=0) && ($x+$x_offset if you know what I mean :) ThanksRob 

  6. Boy did that message get messed up.  I was using Safari, now using firefox.  Sorry bout that.  What I meant to say was that the source doesnt seem to start from the beginning.  I’d like to study it from the opening .  Is that possible? ThanksRob 

Comments are closed.