Reputation: 9796
I want to display a series of images to a user. For each image request input from the user in the form of a mouse click on the image. Store the coordinates of each click in a matrix. Thus, in end having a matrix of dimension num_images x 2.
function main()
clc;
global agent_pos;
....
for i=1:numel(img_names),
imname = [ path_img img_names{i}];
im0 = imread(imname);
imageHandle =imshow(im0);%_____________displays the image
set(gcf,'units','normalized','outerposition',[0 0 1 1])
set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
uiwait(gcf);
end
end
function coordinates=ImageClickCallback ( objectHandle , eventData )
axesHandle = get(objectHandle,'Parent');
coordinates = get(axesHandle,'CurrentPoint');
coordinates = coordinates(1,1:2);
global agent_pos;
agent_pos=[agent_pos;coordinates]; %___ add these coordinates for each image
close gcf;
end
My only issue here is that instead of creating a new window after user click , can I somehow display the image on the current figure itself.
I tried to replace close(gcf) with clf
or cla
. But the new image appears in a new window only that too after I close the current window. I think it's something related to the handle attached to the figure.
Upvotes: 0
Views: 53