File Exchange

image thumbnail

SIFT feature computation

version (833 KB) by I Chieh Chen
An testing version of SIFT feature detection and calculation


Updated 10 Apr 2014

View License

Each block of the code corresponds to a part of the SIFT feature algorithm by the original paper :
and the sketch note:
I'm trying my best to do exactly the same as the original paper does, but the results are not perfect (or can be a few bugs or miscalculations there).
Please be free using my code, and I will be appreciated if bugs or miscalculations found and replied :)

Comments and Ratings (18)


Jipnd (view profile)


xxxx (view profile)

how to run this file?

pa bl

pa bl (view profile)

Hello I am new in matlab.
I wanted torun the file and got this error:
Out of memory. Type HELP MEMORY for your options.
Error in SiftMain (line 44)
CompareDiffImg =zeros(size(OctaveImage{Octave,1},1)-2,size(OctaveImage{Octave,1},2)-2,27);
Does anybody know why?

anmol gupta

The size of extracted feature descriptor is N*128*36, where N is no. of keypoints. What does 36 mean here and how to eliminate this factor so that we can get descriptor vector of size N*128 only?


Pierre (view profile)

Finally I have found the reason for the value 14. As you remember, extremums at the scale s are determinated with the adjacent scales (s-1) and (s+1) and a [3x3]neighbourhood . That means that at the beginning of the image the pixel index
are the following (index of the point Under test = 14 !):
s-1 | s | s+1
1 2 3 | 4 5 6 | 7 8 9
10 11 12 | 13 14 15 | ......


Pierre (view profile)

Thank you for this very interesting code.
nevertheless can anybody explain me where does the value 14 come from.
MinMap = (MinMap == 14);
[~,MaxMap] = max(CompareDiffImg,[],3);
MaxMap = (MaxMap == 14);

Thank you for your help


Howie (view profile)

Heni Endah

Thankyou sir. Nice Code.

[~,MinMap] = min(CompareDiffImg,[],3);
MinMap = (MinMap == 14);
[~,MaxMap] = max(CompareDiffImg,[],3);
MaxMap = (MaxMap == 14);
DiffMinMaxMap{Octave,s-1} = MinMap + MaxMap; % the center indx is 9 + 5 = 14

But, where did we get 14? anyone can help me?

Atul Surwase

Good one


anu (view profile)

Hello Sir,This is good code.but i am not getting right result.Have you got mistake?


sindhu (view profile)

Hi,Really great code!I'm working on a project which uses SIFT. Could you please tell me how to display images from the cell array? Looking forward for your reply.
Thank you.

yuli zhang

well done


nice code
please provide more information on code
how it is implement? each variable is for what purpose?

I Chieh Chen

Hi hamed, thanks for the response.
For feature matching, there's a general way: RANSAC algorithm
and please search: RANSAC SIFT, you may find useful information.
If you need more detailed information, you're welcome to discuss with me.
PS. plz be reminded that my code is not for sure the correct way for feature computation.
The website created by the author or the original paper:
offers the code for feature detection and feature matching, thanks!


hamed (view profile)

hi, thanks for your great code. can you please tell me how can I match these created key points?


hamed (view profile)


Hossein (view profile)

that is cool

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor