forked from petercorke/machinevision-toolbox-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScalePointFeature.m
143 lines (126 loc) · 4.84 KB
/
ScalePointFeature.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
%ScalePointFeature ScalePointCorner feature object
%
% A subclass of PointFeature for features with scale.
%
% Methods::
% plot Plot feature position
% plot_scale Plot feature scale
% distance Descriptor distance
% ncc Descriptor similarity
% uv Return feature coordinate
% display Display value
% char Convert value to string
%
% Properties::
% u horizontal coordinate
% v vertical coordinate
% strength feature strength
% scale feature scale
% descriptor feature descriptor (vector)
%
% Properties of a vector of ScalePointFeature objects are returned as a vector.
% If F is a vector (Nx1) of ScalePointFeature objects then F.u is a 2xN matrix
% with each column the corresponding point coordinate.
%
% See also PointFeature, OrientedScalePointFeature, SurfPointFeature, SiftPointFeature.
% Copyright (C) 1993-2011, by Peter I. Corke
%
% This file is part of The Machine Vision Toolbox for Matlab (MVTB).
%
% MVTB is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% MVTB is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Leser General Public License
% along with MVTB. If not, see <http://www.gnu.org/licenses/>.
classdef ScalePointFeature < PointFeature
properties
scale_
end % properties
methods
function f = ScalePointFeature(varargin)
%ScalePointFeature.ScalePointFeature Create a scale point feature object
%
% F = ScalePointFeature() is a point feature object with null parameters.
%
% F = ScalePointFeature(U, V) is a point feature object with specified
% coordinates.
%
% F = ScalePointFeature(U, V, STRENGTH) as above but with specified strength.
%
% F = ScalePointFeature(U, V, STRENGTH, SCALE) as above but with specified
% feature scale.
f = f@PointFeature(varargin{:}); % invoke the superclass constructor
if nargin > 3
f.scale_ = varargin{4};
end
end
function val = scale(features)
val = [features.scale_];
end
% for book compatibility
function plot_scale(features, varargin)
features.plot('circle', varargin{:});
end
function plot(features, varargin)
%ScalePointFeature.plot Plot feature
%
% F.plot(OPTIONS) overlay a marker at the feature position. The default
% is a point marker.
%
% F.plot(OPTIONS, LS) as above but the optional line style arguments LS are
% passed to plot.
%
% If F is a vector then each element is plotted.
%
% Options::
% 'circle' Indicate scale by a circle
% 'disk' Indicate scale by a translucent disk
% 'color',C Color of circle or disk (default green)
% 'alpha',A Transparency of disk, 1=opaque, 0=transparent (default 0.2)
% 'scale',S Scale factor for drawing circles and arrows.
%
% Examples::
%
% Mark the feature coordinates with a white asterisk
% f.plot('w*')
% Mark each feature with a blue translucent disk
% f.plot('disk', 'color', 'b', 'alpha', 0.3);
% Mark each feature with a green circle and with exagerated scale
% f.plot('circle', 'color', 'g', 'scale', 2)
%
% See also PointFeature.plot, plot.
opt.display = {'', 'circle', 'disk'};
opt.color = 'g';
opt.alpha = 0.2;
opt.scale = 1;
[opt,args] = tb_optparse(opt, varargin);
if length(args) == 1 && isstr(args{1})
opt.color = args{1};
args = {};
end
holdon = ishold;
hold on
s = 1;
switch (opt.display)
case 'circle'
plot_circle([ [features.u_]; [features.v_] ], opt.scale*[features.scale_]', ...
'color', opt.color, args{:});
case 'disk'
plot_circle([ [features.u_]; [features.v_] ], opt.scale*[features.scale_]', ...
'fillcolor', opt.color, 'edgecolor', 'none', 'alpha', opt.alpha);
otherwise
plot@PointFeature(features, varargin{:});
end
if ~holdon
hold off
end
end % plot
end % methods
end % classdef