-
Notifications
You must be signed in to change notification settings - Fork 16
/
orb.m
71 lines (59 loc) · 1.94 KB
/
orb.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [cnr, br] = orb(im, npts, scale)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLAB implementation of Oriented FAST rotated BRIEF (ORB)
%
% Inputs - im : input image
% npts: number of ORB feature points to be extracted (default
% 500)
% scale : a vector of image scales (ORB is not scale invariant,
% so ORB needs to be computed from different scales of the input
% image
%
% Outputs - cnr : the coordinates of ORB features
% br : BRIEF feature descriptor corresponding to ORB features;
%
%
%
% Juheon Lee (21/06/2018)
% GNU public licence v 3.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin < 3
scale = [1, 0.75, 0.5, 0.25];
end
if nargin <2
npts = 500;
end
if nargin <1
error('input image is needed to compute ORB');
end
im_grey = rgb2gray(im);
corner = [];
harris1 = [];
angle = [];
for i = 1:length(scale)
if scale(i) == 1
im2 = im;
else
im2 = imresize(im,scale(i));
end
im2_grey = rgb2gray(im2);
% extract FAST corners and its score
[corner2, fscore2] = fast9(im2_grey,20, 1);
% non-maximal supression
[corner2,fscore2] = FAST_filter(im2_grey,corner2,fscore2);
% compute Harris corner score
H2 = harris(im2_grey);
harris2 = H2(sub2ind(size(H2),corner2(:,2),corner2(:,1)));
% compute angle
angle2 = orientation(im2_grey,[corner2(:,2),corner2(:,1)]);
corner = [corner;round(corner2*(1/scale(i)))];
harris1 = [harris1;harris2];
angle = [angle; angle2];
end
% selected desired number of points
[~,idx1] = sort(harris1);
cnr = corner(idx1(1:npts),:);
ang = angle(idx1(1:npts));
% compute rotational BRIEF (one can also use BRIEF)
run('sampling_param.m')
br = rBRIEF(im_grey,cnr,sample,ang);