Saving mouse click coordinates on image in GUI
Show older comments
Hello,
How do I record up to 5 mouse click coordinates ([x,y] relative to the image with (0,0) being in the upper left) on an 512 by 512 image (axes1 of my GUI)? I would like the mouse click locations to be saved in a table, so I can use the values for subsequent calculations.
I found the following script online for saving coordinates, but am not sure how it works and where to put this within the GUI script.
function ImageClickCallback (objectHandle , eventData )
axesHandle = get(objectHandle,'Parent');
coordinates = get(handles.axes1,'CurrentPoint');
coordinates = coordinates(1,1:2);
%// then here you can use coordinates as you want ...
For the data-capturing table, I suppose I should be doing the following, but I am not sure which callback section to place it under (do I have to manually create a "mouseclick" callback?):
tableData = {x1,y1,z1;x2,y2,z2;x3,y3,z3;x4,y4,z4;x5,y5,z5};
set(handles.CoordinateTable,'Data',tableData)
The Z values refer to the slice number (obtainable from the slider location) since I am showing a stack of images. I believe that after updating the handles, I should be able to perform my calculations from there.
Apologies for the novice question, as I am quite new to MATLAB. Thank you so much!
Accepted Answer
More Answers (0)
Categories
Find more on Data Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!