function c = click3(fig,f)
%
% click3: click on figure fig 
%         row, col, value in the command window
% On input:
%     fig: figure number
%     f: image to choose values from for clicked location
% On output:
%     c: clicked locations and values
% Call:
%     c = click2(fig,f);
%

[m,n] = size(f);
figure(fig);
index = 0; buttun = 1; hold on;
while buttun~=2
  [x,y,buttun] = ginput(1);
  index = index+1;
  xt = min(n,max(1,round(x)));
  yt = min(m,max(1,round(y)));
  plot(xt,yt,'oy');
  c(index,1) = yt;
  c(index,2) = xt;
 % irm1 = max(1,yt-1); irp1 = min(m,yt+1); 
 % icm1 = max(1,xt-1); icp1 = min(n,xt+1);
 % ir = yt; jr = xt; 
 % a(1,1) = f(irm1,icm1); a(1,2) = f(irm1,jr); a(1,3) = f(irm1,icp1);
 % a(2,1) = f(ir,icm1);   a(2,2) = f(ir,jr);   a(2,3) = f(ir,icp1);
 % a(3,1) = f(irp1,icm1); a(3,2) = f(irp1,jr); a(3,3) = f(irp1,icp1);
 % disp('Clicked at: ');
 % disp(c(index,:));
 % disp(a(1,:)); disp(a(2,:)); disp(a(3,:));
end
hold off
