forked from ndwork/dworkLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFeaturesFromImg.m
More file actions
38 lines (34 loc) · 1.14 KB
/
getFeaturesFromImg.m
File metadata and controls
38 lines (34 loc) · 1.14 KB
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
function [features,values] = getFeaturesFromImg( n, varargin )
% features = getFeaturesFromImg( n [, scale ] )
%
% Inputs:
% n - the number of features to select
% scale - the scale of the displayed image (default is 1)
%
% Output:
% features - a 2 column array. The first column are the x (or
% horizontal) coordinates, and the second column are the y (or
% vertical coordinates).
%
% Written by Nicholas Dwork - Copyright 2018
%
% This software is offered under the GNU General Public License 3.0. It
% is offered without any warranty expressed or implied, including the
% implied warranties of merchantability or fitness for a particular
% purpose.
p = inputParser;
p.addRequired( 'n', @(x) isnumeric(x) && x>0 );
p.addOptional( 'scale', 1, @isnumeric );
p.parse( n, varargin{:} );
scale = p.Results.scale;
scaledFeatures = ginput(n);
features = round( scaledFeatures / scale );
if nargout > 1
img = getimage;
values = zeros( n, 1 );
scaledFeatures = round( scaledFeatures );
for fIndx = 1:n
values(fIndx) = img( scaledFeatures(fIndx,2), scaledFeatures(fIndx,1) );
end
end
end