How to get col/x and row/y coordinates of mouse pointer of an image inside UIAxes in app designer?

I have an app in app designer which loads an image inside UIAxes. The app looks like this:
Screenshot (5).png
Now, I also want to show the x, y coordinates of image based on mouse movement on the image. For example, if mouse pointer is at the top left corner of image it should show 1,1 and on the bottom left 299,392 which is the image resolution.
What I have been able to do so far is get x,y coordiates of the whole figure with this code which is working:
while true
loc = get(0, 'PointerLocation');
app.xpoint = loc(1,1);
app.ypoint = loc(1,2);
yEditFieldValueChanged(app);
xEditFieldValueChanged(app);
pause(0.01);
end
But I need x,y coordinates of image which is in UIAxes.

Réponses (0)

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by