-
Notifications
You must be signed in to change notification settings - Fork 5
/
corner_base.m
88 lines (73 loc) · 2.61 KB
/
corner_base.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%% CORNER_BASE - Base function for CORNER.
%
%% Syntax
% [cornermap, ptcorner] = ...
% CORNER_BASE(I, meth, thr, kap, rad, nnmax, gap, thang, sigma, rho, reduce);
%
%% See also
% Related:
% <CORNER.html |CORNER|>,
% <EDGECORNER_BASE.html |EDGECORNER_BASE|>.
% Called:
% <HARRISCORNER.html |HARRISCORNER|>,
% <SUSANCORNER_BASE.html |SUSANCORNER_BASE|>,
% <FASTCPDA_BASE.html |FASTCPDA_BASE|>,
% <FASTCORNER_BASE.html |FASTCORNER_BASE|>.
%% Function implementation
function [cornermap, ptcorner] = ...
corner_base(I, method, thres, kappa, radius, nonmax, gap, thang, sigma, rho, reduce )
%%
% dealing with multispectral images
[X,Y,C] = size(I);
if C>1
ptcorner = cell(C,1);
cornermap = false(size(I));
if isempty(sigma), sigma=zeros(1,1,3); % dummy variable
elseif isscalar(sigma), sigma=repmat(sigma,[1 1 3]); end
if isempty(rho), rho=zeros(1,1,3); % dummy variable
elseif isscalar(rho), rho=repmat(rho,[1 1 3]); end;
for ic=1:C
[cornermap(:,:,ic), ptcorner{ic}] = ...
corner_base(I(:,:,ic),method, thres, kappa, ...
radius, nonmax, gap, thang, sigma(:,:,ic), rho(:,:,ic));
end
if reduce
for c=2:C
cornermap(:,:,1) = cornermap(:,:,1) | cornermap(:,:,c);
ptcorner{1} = [ptcorner{1}; ptcorner{c}];
end
cornermap = cornermap(:,:,1);
ptcorner = ptcorner{1};
end
return
end
%%
% calling appropriate method
switch method
case {'harris','noble','forster'} % Harris
% use Kovesi implementation if desired
% [cim, r, c] = harris(I, sigma, 1000, radius);
% ptcorner{1} = [r,c];
ptcorner = harriscorner_base(I, sigma, rho, kappa, thres, radius);
case 'susan'
ptcorner = susancorner_base(I, 'c', thres, 'flat', false, true);
% case 'cur'
% ptcorner = curvecorner_base(I);
case {'fast9','fast10','fast11','fast12'}
nn = method(5:end);
ptcorner = fastcorner_base(I, nn, nonmax, thres);
class(ptcorner)
case 'cpda'
V = cannyedge_base(I, sigma, 'matlab', [], false);
ptcorner = fastcpda_base(V, gap, thang, false);
% case 'comp'
% case 'cong'
otherwise
error('corner:errorinput', ...
['method ' method ' not implemented yet'])
end
ptcorner = ptcorner{1};
cornermap = false(X,Y);
% cornermap(sub2ind([X,Y],ptcorner(:,1),ptcorner(:,2))) = true;
cornermap(ptcorner(:,1) + (ptcorner(:,2)-1)*X) = true;
end % end of corner_base