Code covered by the BSD License  

Highlights from
OpenSURF (including Image Warp)

4.10526

4.1 | 19 ratings Rate this file 210 Downloads (last 30 days) File Size: 706 KB File ID: #28300
image thumbnail

OpenSURF (including Image Warp)

by

 

26 Jul 2010 (Updated )

SURF (Speeded Up Robust Features) image feature point detection / matching, as in SIFT

| Watch this File

File Information
Description

Description:
This function OPENSURF, is an implementation of SURF (Speeded Up Robust Features). SURF will detect landmark points in an image, and describe the points by a vector which is robust against (a little bit) rotation ,scaling and noise. It can be used in the same way as SIFT (Scale-invariant feature transform) which is patented. Thus to align (register) two or more images based on corresponding points (see example3.m), or make 3D reconstructions.

Implementation:
This Matlab implementation of Surf is a Matlab optimized translation of the OpenSurf C# code of Chris Evans, and gives exactly the same answer. Chris Evans wrote one of the best, well structured all inclusive SURF implementations. On his site you can find Evaluations of OpenSURF and the C# and C++ code. http://www.chrisevansdev.com/opensurf/
Chris Evans gave me permisson to publish this code under the (Mathworks) BSD license.

.
Usage :
  Ipts = OpenSurf(I, Options)

  inputs,
    I : The 2D input image color or greyscale
    (optional)
    Options : A struct with options (see below)

.
Examples:
Type "help OpenSurf" or "doc OpenSurf" for a basic surf example, and try the example2.m and example3.m for more advanced point matching and affine registration examples.

.
Note:
If you want to use opensurf for nonrigid registration, see "B-spline Grid, Image and Point based Registration" on Mathworks.

.
Please leave a comment if you find a bug, like the code, or have a question. Visit the page of Chris Evans if you want more detailed information about the algorithm.

Acknowledgements

This file inspired 2 D 2 D Projective Homography (3x3) Estimation.

MATLAB release MATLAB 7.10 (R2010a)
Other requirements Updated examples
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (57)
20 Jun 2014 Peter Bone  
10 Jun 2014 Hardian

Dear Dirk-Jan Kroon,

could you help me how to count correspondence points in example2.m so we could determine percentage of it's match? Thanks

best regards,

Hardian O.

20 Feb 2014 SURENDRA KUMAR

Nice Job..
After Getting the Interest Points how we use that... Please tell all available ways u know?

12 Dec 2013 Darya

Great Job ! It;s been really helpful ! thanks !
I am trying to modify the code for use in 3D . I have a problem understanding the function fastHessian_getResponse . Could you please give a little description on it so i would know what should be expected from this part so I would know how to change it for 3D ?
Thanks

11 Dec 2013 Nate

Should line 58 in SurfDescriptor_GetOrientation be corrected as follows? (change pi to 2*pi)

check2= (ang2 < ang1) & ( ((Ang > 0) & (Ang < ang2)) | ((Ang > ang1) & (Ang < pi)) );

to:

check2= (ang2 < ang1) & ( ((Ang > 0) & (Ang < ang2)) | ((Ang > ang1) & (Ang < 2*pi)) );

06 Jul 2013 Mohammed Ziad

Good job I have benefited it a lot

But I have a question:

How to Calculate the time of matching?

How to Calculate the number of features?

How to Calculate the percentage of matching?

Please help me, I worked on the graduation project comparison between two algorithm ( SURF AND SIFT)

29 May 2013 Parul Mishra

opensurf gives us keypoints and features .i generate code for matching these features in an image for duplication detection. but my code is not working properly in all images of my dataset. it gives result in some images .what can i do ?please reply

08 Apr 2013 Adi Zholkover

I found a solution. I just used MATLABs tranformation functions from Image Processing Toolbox

my_M = cp2tform(Pos1(:,1:2) ,Pos2(:,1:2),'affine');
my_warped = imtransform(I1,my_M);

08 Apr 2013 Adi Zholkover

Hi,

I tried to run example 3 with a re-sized source image (scaled 0.5 time).
After fixing some of the plotting issues, openSURF seems to find correct features, but the warped image is "cropped" at the top-left corner (but upright).
I then un-commented the following lines in affine_warp.m:
mean= size(Iin)/2;
xd=x-mean(1);
yd=y-mean(2);

now the warped image is cropped around the center of the image (and upright).

any hints?

18 Dec 2012 ENIT

I want to search for similarities in one image using OpenSURF implementation. would you please help me how I can group identical SURF features (matching them) and display the resulting imge with matched regions? Please give me any suggestions

07 Nov 2012 Pan Ou  
02 Nov 2012 e3sdsdf

ddd

29 Jul 2012 Stas

Dear Dirk-Jan Kroon,

While getting into your code, I got an impression that Gasp below (26 May 2011 ) is correct:
"I'm quit sure there is a little mistake in FastHessian_buildResponseLayer line 31-32 : instead of "b" I think it should be "b-1" ; could someone confirm or invalidate?"
I would like to clarify, that on my oppinion, "r - b" should be replaced with "r-b+1", and "c-b" should be replaced with "c-b+1"
Thank you.
Stas

09 Jul 2012 karthik

May i know how to get the x-y coordinates for the feature points detected using OPENSURF.

i Need to store in a array

20 Jun 2012 Amateuromania

hi, i'm having a trouble with the code; it's detecting points which lie on the background of a logical image. Can you tell why?

01 Jun 2012 Royi Avital

@Youssra, 'row' and 'col' are the row and column index of the top left corner of a rectangle.
'rows' and 'cols' are the number of rows / columns in the rectangle.

28 May 2012 Youssra

any one know??!!

28 May 2012 Youssra

hi, thank you Mr Kroon for the code, but i have a question!! what it is the difference between row , col and rows , cols in the function IntegralImage_BoxIntegral..??
thank's again

25 May 2012 Royi Avital

Are there any updates which follows Chris's code?

23 May 2012 Chin San Yeoh

hi all, do anyone know that in the function orientation=SurfDescriptor_Getorientation, the gauss25 is come from where?do anyone know it?urgent need the information...thx a lot..

17 May 2012 shitala prasad  
09 May 2012 Pantelis

Great code, thank you a lot Mr Kroon.
I have one problem with the function affine_warp.m :
When I choose a different size for the output image of the image_interpolation.m function I get the error
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> affine_warp>image_interpolation at 241
Iout(:,:,i)=reshape(Iout_one, ImageSize);

Error in ==> affine_warp at 64
Iout=image_interpolation(Iin,Tlocalx,Tlocaly,Interpolation,Boundary,[200 200]);

Is it something that can be solved? I want to display the whole transformed image. In case I use the original size, I loose part of the transformed image.

Thank you in advance,
P

13 Apr 2012 KT

Your Code is very Good! but can you tell me that i have different dimension images and i want to apply surf on that, and if i do it gives me the following error--> ??? Subscripted assignment dimension mismatch.

Error in ==> example2 at 27
I(:,1:size(I1,2),:)=I1; I(:,size(I1,2)+1:size(I1,2)+size(I2,2),:)=I2;
can you resolve this for me?

23 Mar 2012 Anna

is it possible to limit somehow the number of feature points to be extracted by OpenSURF, I mean is it possible to extract e.g. at most 50 points or so? how to do that?

18 Mar 2012 Yannis Mantzouratos

Hi all.

Dirk-Jan, thanks very much for your work on this. It was very useful for me, but I would like to point out a design flaw I encountered. In case someone just needs to use U-Surf (the upright version of surf), you still compute the orientation of each point prior to producing the descriptor, although it is not needed at all - and the computational overhead is somewhat significant.

So, I would suggest the following change to whoever is interested.

In file SubFunctions/SurfDescriptor_DescribeInterestPoints at line 32, I changed

ip.orientation=SurfDescriptor_GetOrientation(ip,img,verbose);

to

if ~upright ip.orientation=SurfDescriptor_GetOrientation(ip,img,verbose);
ipts(i).orientation=ip.orientation;
end

and then I also removed

ipts(i).orientation=ip.orientation;

from line 38.

Best,
y

15 Mar 2012 Bronislav Pribyl

To Sarhat: You simply work with too big images. Read http://www.mathworks.co.uk/support/tech-notes/1100/1107.html. You might try to optimize the code by deleting big variables as soon as possible by the command "clear('varName')", but it's probably not worth the effort.

15 Feb 2012 Sarhat

Hello Everyone

I am new to Matlab and I used Opensurf for feature matching between two images. the original image is (4064x2704)pixels. I used resize the images to lower resolution and OpenSurf perfectly working (Thanks for the Author) but when I used the original images size I got the following errors...
'''''''''''
??? Out of memory. Type HELP MEMORY for your options.

Error in ==> IntegralImage_IntegralImage at 31
I=I(:,:,1)*cR+I(:,:,2)*cG+I(:,:,3)*cB;

Error in ==> OpenSurf at 82
iimg=IntegralImage_IntegralImage(img);
''''''''''''''
is there ant idea please or suggestion...
Regards

03 Feb 2012 Martin cho

lovely good!! thanks.

30 Oct 2011 Onkar Singh Gujral

could'nt understand

27 Oct 2011 tito

Hi , i am trying to implement SURF 36 , can i have any help to get this through this code

08 Oct 2011 saima

this matlab code takes 2.98 seconds for the example picture.kindly sufggest how to minimze the time

30 Sep 2011 suxing

Good,thanks

26 Jul 2011 km g

sorry there is something i could not understand. During the descriptor part we need to extract 25 sample points for each region right?but is one sample point equals to one pixel?how if the scale is getting bigger?can anyone who is very familiar with SURF can answer my question?i really feel confused about that. Hope to get ur reply in my email address kenneth86gkm@yahoo.co.uk

31 May 2011 Kyle

Thanks

29 May 2011 Petter

Kyle: use ransac with a similarity transform.

28 May 2011 Kyle

Hi every1,

Does any1 know how to extract the scale n rotation translation between 2 image from opensurf?

Thanks

26 May 2011 Gasp

Hi evryone,

I'm quit sure there is a little mistake in FastHessian_buildResponseLayer line 31-32 : instead of "b" I think it should be "b-1" ; could someone confirm or invalidate?

ty

22 May 2011 Peng Li

Dear Kroon, I am using it for object detection, however, it doesn't work because the object is small (e.g. 30 * 50). In contrast, the SIFT can works well. So I think there are some places of improment

22 May 2011 Peng Li

Athough there are some limitations, i think it's useful for me, as a counterpart to SIFT.

24 Apr 2011 piet fue  
17 Apr 2011 tan0525

I need to extract only feature vectors, how can I do this using SURF?

01 Apr 2011 Cruiser

pls assist me in working with SURF...

24 Nov 2010 PP

sorry, why u use 30 best matches points and if i want to use ratio divide matches points ex. err< 0.5 <<<< ratio
how to modifier

thx

19 Nov 2010 Nam Le

Great implementation

06 Sep 2010 Dirk-Jan Kroon

*Evgeny
Thank you for your code-hint! I can use it in almost all my code to speed up :-) .

02 Sep 2010 Evgeny

In Example 2 you can write shortly
This 2 rows
D1 = zeros([64 length(Ipts1)]);
for i=1:length(Ipts1), D1(:,i)=Ipts1(i).descriptor; end
Equivalent
D1 = reshape([Ipts1.descriptor],64,[]);

02 Sep 2010 Dirk-Jan Kroon

*worker_matlab Ness,
Yes, there is documentation on the website of chrisevansdev.com.

Implementation description in, "Notes on the OpenSURF Library". Also a view papers with reviews of OpenSurf are available there.

02 Sep 2010 worker_matlab Ness

Hello,
wonderful work, there is a complete documentation?

02 Sep 2010 worker_matlab Ness  
30 Aug 2010 eric

Hello,
Still same error code. Would you please tell me how to run this?
Thank you very much.

19 Aug 2010 Dirk-Jan Kroon

*eric,
Strange error. I don't think it is a bug in OpenSurf.

Maybe you can solve this by using
I = imread(('example.jpg','jpg') instead of I=imread('example.jpg') in your code.

18 Aug 2010 eric

Sorry, the error code as below. I don't know why?
Matlab version:2008a

?? Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack
space can
crash MATLAB and/or your computer.

Error in ==> imformats>find_in_registry

04 Aug 2010 Peter Torrione

Ah. thanks

30 Jul 2010 Dirk-Jan Kroon

*Peter
Thank you for your comment. With the default option setting, the minimum size of the image is 256 x 256.
If you reduce the octaves you can use a smaller size, minsize = 2^Options.octaves*8 .
I will build a check in a new version.

29 Jul 2010 Peter

Hello,

Toolbox looks nice, but

feats = openSurf(randn(49,285));

errors:

??? Index exceeds matrix dimensions.

Error in ==> FastHessian_isExtremum>FastHessian_getResponse at 44
an=a.responses(fix(scale*row) * a.width + fix(scale*column)+1);

Error in ==> FastHessian_isExtremum at 25
candidate = FastHessian_getResponse(m,r,c,t);

Any ideas?

29 Jul 2010 Dirk-Jan Kroon

*Petter
I have optimized the Matlab code, replacing all for-loops by 1D and 2D indexing. This version takes less then 1 sec for the example picture.
The original C# version is only 2x as fast for large images.
Of course a mex file is faster, but this Matlab code is easier to study, debug, and doesn't need external libraries or compilers.

(Tomorrow a new version wil be online were I fixed a small bug in the image display function)

28 Jul 2010 Petter

Using the example image test.png I got

>> tic; Ipts=OpenSurf(I); toc;
Elapsed time is 11.341135 seconds

This is way too slow to be useful. The whole point of SURF is its speed, so a MEX interface is essential.

Updates
29 Jul 2010

Speed Up 10x ...

29 Jul 2010

Fixed small bug in paint function

30 Jul 2010

Now always works for small images. Added verbose information option.

06 Sep 2010

Updated example see comment "Evgeny". Added Affine image transformation example.

Contact us