Try using the ginput (...) function in MATLAB, for example:
% Load some image: data = imread('fishy 01.jpg'); % display the image: figure(88); clf; h = imagesc(data); axis image % Get a value from the screen: [x, y] = ginput(1); msgbox(['You want pixel: ' num2str(round([x,y]))]);
This will give you the location of the pixel on the current axis. Alternatively, you could use the WindowButtonUpFcn shape callback to get the current mouse position in the drawing, and then translate this to the axis where you want it relative then, then scale to the current xlim and ylim axis. But ginput (1) will be much simpler.

Steve source share