sift--算法学习 2012 年5月草稿

这个是几个月前开始学习的东西,好久没有碰过了~~

现在来 自惭形秽一下。

这是队友给我的matlab的资料,网上流传的学习中有两份,一份是vedaldi的,一份是lowe的。

这里这份是仿v的,全部用matlab来实现,速度肯定比不上v的matlab与C的混编版,更别说纯c版

因为matlab的循环是非常费时间的,我有一次循环计算量大了差点死机。

废话不多说,我从do_demo1开始吧

1.读入一幅图


% Add subfolder path.
main; 
img1_dir = 'demo-data\';
img1_file = 'beaver11.bmp';

I1=imreadbw([img1_dir img1_file]) ; 

2.调整大小,我觉得这个是从运算量的角度来说
I1_rgb = imread([img1_dir img1_file]) ; 
I1=imresize(I1, [240 320]);

I1_rgb =imresize(I1_rgb, [240 320]);
I1=I1-min(I1(:)) ;                                     %min(I1) <0 我感觉是去除负值,我调试的时候发现有负值,为什么不知道
I1=I1/max(I1(:)) ;


%fprintf('CS5240 -- SIFT: Match image: Computing frames and descriptors.\n') ;



 %FRAMES(1:2,k)  center (X,Y) of the frame k,  k帧的中心元素坐标
%     FRAMES(3,k)    scale SIGMA of the frame k,    不知道这个中文怎么翻译,尺度空间的规模
%     FRAMES(4,k)    orientation THETA of the frame k.  方向

 DESCR is a DxK matrix stores one descriptor per columm (usually
%   D=128).  描述子


[frames1,descr1,gss1,dogss1] = do_sift( I1, 'Verbosity', 1, 'NumOctaves', 4, 'Threshold',  0.1/3/2 ) ; %0.04/3/2

figure(11) ; clf ; plotss(dogss1) ; colormap gray ;
drawnow ;


figure(2) ; clf ;
imshow(I1_rgb) ; axis image ;


hold on ;
h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','g') ;


function [frames,descriptors,scalespace,difofg]=sift(I,varargin)
%% file:       sift.m
% author:      Noemie Phulpin
% description: SIFT algorithm


warning off all;


[M,N,C] = size(I) ;

3.生成高斯尺度空间


O可以理解成组。S是不同的尺度。

% Lowe's choices
S=3 ;
omin= 0 ;
%O=floor(log2(min(M,N)))-omin-4 ; % Up to 16x16 images
O = 4;
这部分是算法里面有的
sigma0=1.6*2^(1/S) ;   
sigman=0.5 ;

这个门限值我觉得有点带经验色彩
thresh = 0.2 / S / 2 ; % 0.04 / S / 2 ;
r = 18 ;


NBP = 4 ;
NBO = 8 ;
magnif = 3.0 ;


% Parese input
compute_descriptor = 0 ;
discard_boundary_points = 1 ;
verb = 0 ;


% Arguments sanity check
if C > 1
  error('I should be a grayscale image') ;
end


frames = [] ;
descriptors = [] ;



% Do the job
%
fprintf('---------------------------- CS5240 SIFT: Extract SIFT features from an image ------------------------------\n') ; tic ; 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值