Code covered by the BSD License  

Highlights from
OpenSURF (including Image Warp)

4.09091

4.1 | 11 ratings Rate this file 332 Downloads (last 30 days) File Size: 705.62 KB File ID: #28300
image thumbnail

OpenSURF (including Image Warp)

by Dirk-Jan Kroon

 

26 Jul 2010 (Updated 06 Sep 2010)

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.

MATLAB release MATLAB 7.10 (2010a)
Other requirements Updated examples
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (37)
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.

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)

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?

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.

04 Aug 2010 Peter

Ah. thanks

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

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.

30 Aug 2010 eric

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

02 Sep 2010 worker_matlab Ness  
02 Sep 2010 worker_matlab Ness

Hello,
 wonderful work, there is a complete documentation?

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 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,[]);

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 :-) .

19 Nov 2010 Nam Le

Great implementation

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

01 Apr 2011 Cruiser

pls assist me in working with SURF...

17 Apr 2011 tan0525

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

24 Apr 2011 piet fue  
22 May 2011 Peng Li

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

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

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

28 May 2011 Kyle

Hi every1,

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

Thanks

29 May 2011 Petter

Kyle: use ransac with a similarity transform.

31 May 2011 Kyle

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

30 Sep 2011 suxing

Good,thanks

08 Oct 2011 saima

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

27 Oct 2011 tito

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

30 Oct 2011 Onkar Singh Gujral

could'nt understand

03 Feb 2012 Martin cho

lovely good!! thanks.
 

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

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.

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

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?

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?

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

17 May 2012 shitala prasad  
Please login to add a comment or rating.
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.

Tag Activity for this File
Tag Applied By Date/Time
registration Dirk-Jan Kroon 26 Jul 2010 12:54:56
surf Dirk-Jan Kroon 26 Jul 2010 12:54:56
opensurf Dirk-Jan Kroon 26 Jul 2010 12:54:56
speeded up robust features Dirk-Jan Kroon 26 Jul 2010 12:54:56
sift Dirk-Jan Kroon 26 Jul 2010 12:54:56
scaleinvariant feature transform Dirk-Jan Kroon 26 Jul 2010 12:54:56
scale Dirk-Jan Kroon 26 Jul 2010 12:54:56
rotation Dirk-Jan Kroon 26 Jul 2010 12:54:56
landmark Dirk-Jan Kroon 26 Jul 2010 12:54:56
automatic Dirk-Jan Kroon 26 Jul 2010 12:54:56
image Dirk-Jan Kroon 26 Jul 2010 12:54:56
2d Dirk-Jan Kroon 26 Jul 2010 12:54:56
chris evans Dirk-Jan Kroon 26 Jul 2010 12:54:56
distance Dirk-Jan Kroon 26 Jul 2010 12:54:56
haar wavelet Dirk-Jan Kroon 26 Jul 2010 12:54:56
blob Dirk-Jan Kroon 26 Jul 2010 12:54:56
detector Dirk-Jan Kroon 26 Jul 2010 12:54:56
point matching Dirk-Jan Kroon 26 Jul 2010 12:54:56
feature Dirk-Jan Kroon 26 Jul 2010 12:54:56
affine Dirk-Jan Kroon 26 Jul 2010 12:54:56
rigid Dirk-Jan Kroon 26 Jul 2010 12:54:56
evans Dirk-Jan Kroon 26 Jul 2010 12:54:56
scale invariant feature transform Dirk-Jan Kroon 30 Jul 2010 10:23:18
scale in Dirk-Jan Kroon 07 Sep 2010 09:56:04
scale invariant feature transform Inderpreet kaur 04 Dec 2011 03:53:23
feature Mohammad 20 Jan 2012 12:47:33

Contact us at files@mathworks.com