0
votes

I'm having some problems with MATLAB GUIDE.

I have an axes object in a GUI (axes1) which is displaying an image ( imshow(I) ). I need to store the coordinates of a user click on the image.

I tried

[x,y] = ginput(1). 

The problem with this function is that it returns the coordinates of the axes, not the coordinates of the image I.

1

1 Answers

0
votes

The coordinates of the axes and the image are aligned:

For example:

figure();
imshow('peppers.png');
[x,y]=ginput(1)

If you're bothered about out of bounds conditions, you could check and remove them after calling ginput:

if x> size(im,2)
   x = size(im,2);
end
if y> size(im,1)
   y = size(im,1);
end