I have following code in initialization
im = imread('Image02.tif');
figure(); imagesc(im); colormap(gray);
[hImage hfig ha] = imhandles(gcf);
set(hImage,'ButtonDownFcn',@clickInImage);
And clickInImage function looks like this
function clickInImage(s,e)
pt=get(gca,'Currentpoint');
x=pt(1,1);
y=pt(1,2);
...
My question: How can I access image im in clickInImage function? I can’t use global variable.
You could retrieve the image inside the callback using:
Otherwise, make the callback a nested function inside your main GUI function, that way you get access to all its parent workspace: