function [rock, ice, origin] = getpoints(im, Npoints)

% [rock, ice, origin] = getpoints(im)
%        				 = getpoints(im, Npoints)
%
% Returns 2 matrices (1 obs / row) of observations of points in a 3 color image image im.
% Npoints = [Num rock points, Num ice points].
%           Default is to not read any beyond origin.

% Liam Pedersen, October 1998, FACH C-130 Hercules

% display image
clf;
image(im);

% get number of inputs to take
if (nargin == 1)
   Npoints = [0 0];
end

[YY XX] = size(im);
hold on;

disp('click on rock origin');
[ox, oy] = ginput(1);
origin = round([ox oy]);
plot(origin(1), origin(2),'go');

for i = 1:Npoints(1)
	disp('click on rock');
	[rx(i), ry(i)] = ginput(1);
	rx(i) = round(rx(i));
   ry(i) = round(ry(i));
   plot(rx(i),ry(i),'r*');
end
disp('\n');

for i = 1:Npoints(2)
	disp('click on ice');
	[ix(i), iy(i)] = ginput(1);
	ix(i) = round(ix(i));
   iy(i) = round(iy(i));
   plot(ix(i),iy(i),'y.');
end

for i = 1:length(rx)
   if (1 <= rx(i) & rx(i) <= XX & 1 <= ry(i) & ry(i) <= YY)
      rock(i,:) = pixfeatures(im,rx(i),ry(i));
   end
end

for i = 1:length(ix)
   if (1 <= ix(i) & ix(i) <= XX & 1 <= iy(i) & iy(i) <= YY)
      ice(i,:) = pixfeatures(im,ix(i),iy(i));
   end
end

hold off