2

I am trying to gat the x,y coordinate of the image I loaded in axes by clicking the mouse. I've seen a few answers, such as this one MATLAB how to get mouse click coordinates My questions is where(under which function?) should I put the

imageHandle = imshow(imageObj);

as well as

set(imageHandle,'ButtonDownFcn',@ImageClickCallback);

Sorry for this naive question, Thanks!

Community
  • 1
  • 1
Suicide Bunny
  • 894
  • 1
  • 10
  • 23
  • You would set the `ButtonDownFcn` in `guiName_OpeningFcn`, but with GUIDE, I believe you could just set that with the properties browser and it would be stored in the .fig. Depending on when `imageObj` is updated, that would go in the appropriate callback or subroutine, possibly in the opening function if the image never changes. – chappjc Nov 15 '13 at 21:48
  • The frames are mostly updated in the slider bar(tiff sequence), does it mean i should it put it under fucntion slider_callback? Right after the new image is loaded? – Suicide Bunny Nov 15 '13 at 21:50
  • If your slider loads a new image, then that would seem appropriate. – chappjc Nov 15 '13 at 21:51

1 Answers1

1

I've had good success using the "impixel" function as a way to detect x,y coordinates. I would give this a shot:

imageHandle = imshow(imageObj);
[clicked_col clicked_row rgb_info] = impixel

Note: impixel allows multiple clicks. Press "Enter" to return the x,y info once you're done clicking.

ams
  • 173
  • 8