/usr/share/octave/site/m/vlfeat/toolbox/plotop/vl_clickpoint.m is in octave-vlfeat 0.9.17+dfsg0-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function sel = vl_clickpoint(V,N,varargin)
% VL_CLICKPOINT Select a point by clicking
% SEL = VL_CLICKPOINT(V) let the user vl_click a point in the current
% figure and returns the index v of the closest point (in Euclidean
% norm) in the collection V. The 2xK matrix V has a a column for
% each point.
%
% The user can abort the operation by pressing any key. In this case
% the function returns the empty matrix.
%
% VL_CLICKPOINT(V,N) selects N points in a row. The user can stop the
% selection at any time by pressing any key. In this case the
% partial selection is returned. This can be used in combination
% with N=inf to get an arbitrary number of points.
%
% VL_CLICKPOINT() accepts the following options:
%
% PlotMarker:: [0]
% Put a marker as points are selected. The markers are deleted on
% exiting the function.
%
% See also: VL_CLICK(), VL_HELP().
% Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
% All rights reserved.
%
% This file is part of the VLFeat library and is made available under
% the terms of the BSD license (see the COPYING file).
plot_marker = 0 ;
for k=1:2:length(varargin)
switch lower(varargin{k})
case 'plotmarker'
plot_marker = varargin{k+1} ;
otherwise
error(['Uknown option ''', varargin{k}, '''.']) ;
end
end
if nargin < 2
N=1;
end
if size(V,1) ~= 2
error('Array V should be 2xK') ;
end
% --------------------------------------------------------------------
% Do job
% --------------------------------------------------------------------
fig = gcf ;
is_hold = ishold(fig) ;
hold on ;
sel = [] ;
h = [] ;
for n=1:N
P=vl_click ;
if ~isempty( P )
d = (V(1,:)-P(1)).^2 + (V(2,:)-P(2)).^2;
[drop,v]=min(d(:)) ;
if(plot_marker)
h=[h plot(V(1,v),V(2,v),'go')] ;
end
sel = [sel v] ;
else
return ;
end
end
if ~is_hold
hold off ;
end
if( plot_marker )
pause(.1);
delete(h) ;
end
|