function [x]=click_image(filename,x_guess) %RADIUS = 25; RADIUS = 50; if length(filename) > 50 ima = filename; map = gray(256); else [ima,map] = readras(filename); end; [m,n] = size(ima); figure(1); image(ima); colormap(map); drawnow; if(nargin==1) %% no guess of x n_points = input('How many points?'); %set(1,'Position', [10, 10, 1100, 800]); [x,y] = ginput(n_points); %set(1,'Position', 'default'); hold on; plot(x,y,'+r'); hold off; drawnow; else, %% a guess of x has been provided x = x_guess(1,:)' + 2; %% add 2 to take marks away from right spot y = x_guess(2,:)' + 2;%% add 2 to take marks away from right spot n_points = size(x,2); end; %% Refine estimates figure(2); colormap(map); %set(2,'Position', [10, 10, 1100, 800]); for p=1:n_points, i = round(y(p)); j = round(x(p)); x1 = max(1,j-RADIUS); x2 = min(n,j+RADIUS); y1 = max(1,i-RADIUS); y2 = min(m,i+RADIUS); subima = ima(y1:y2,x1:x2); image(subima); hold on; plot(x(p)-x1, y(p)-y1, '+r'); drawnow; [x_new, y_new] = ginput(1); x(p) = x1 + x_new; y(p) = y1 + y_new; plot(x(p)-x1, y(p)-y1, '+g'); drawnow; hold off; end; %set(2,'Position', 'default'); figure(1); hold on; plot(x,y,'+g'); hold off; drawnow; x = [x , y]';