简体   繁体   中英

MATLAB GUI: how to get mouse click coordinates(need more help on details!)

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM