Life is a game, take it seriously

SURF On Images: continue

In Computer Vision, Matlab on May 7, 2011 at 11:43 pm

written by Gooly

Continuing the last post, I will show how to actually work on SURF points using MATLAB. First download the SURFmex library; this is a second version released in 2008, which is simply a wrapper around the OpenCV dll. The good thing about OpenCV is that it’s open source and actively used, so you won’t get stuck in a dll which couldn’t move to another OS. Note that you have to fix the surfplot function bug in the common folder, see this explanation. Next, put the library in the project folder and remember to right click on it and add to path. Now, put 2 images, in my case img1.png and img2.png, in the same folder. Next step, download a small function I wrote to show the matching result like the image above from here (or search match_plot on Matlab Central); put the function in the same folder. Finally, add the following code and run.

function match_test()

close all;

% surfnum = 1:30;

left_img  = imread('./img1.png');
right_img = imread('./img2.png');

[spixels_l,descr_l,sign_l,info_l] = SurfPoints(rgb2gray(left_img));

hold on;
plot(spixels_l(1,:),spixels_l(2,:),'r*'); hold on

[spixels_r,descr_r,sign_r,info_r] = SurfPoints(rgb2gray(right_img));

hold on;
plot(spixels_r(1,:),spixels_r(2,:),'r*'); hold on

matches = surfmatch(descr_l,descr_r);

surfnum = randi(size(matches,2),1,30);


hold on;

hold on;


You will get 2 image which have all of the SURF points marked, and an image like the one above which matches 30 random SURF points, and 2 images showing the orientation and size of the SURF points like the image below.

On the next post, I’ll show how to do simple object recognition using SURF points. By the way, if you work on stereo vision, these images must look familiar; for those who don’t know, search for middlebury 

  1. Thank you for the great tutorial!!
    Actually I got error while running the above code.
    Error message:
    “Error at match_test (line 11)
    [spixels_l,descr_l,sign_l,info_l] = SurfPoints(rgb2gray(left_img));”

    I think you need to change the “SurfPoints(rgb2gray(left_img));” to “surfpoints(rgb2gray(left_img));”

    And then, the problem will be solved.

  2. rror in Demo (line 22)
    targetModel = createTargetModel(targetImage, targetModelImage);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: