Image 'CurrentPoint' properties does not exist? (appDesigner Image Component)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Roger Breton
am 3 Jan. 2022
Kommentiert: Rik
am 5 Jan. 2022
I found some code designed to retrieve an UIAxes component x,y coordinates when 'traversed' by the mouse :
pm.enterFcn = [];
pm.exitFcn = @(~,~) set(app.CurrentPositionEditField, 'Value', '');
pm.traverseFcn = @(~,~) set(app.CurrentPositionEditField, 'Value', sprintf('%.2f, %.2f', app.UIAxes.CurrentPoint(1,1:2)));
iptSetPointerBehavior(app.UIAxes, pm)
iptPointerManager(app.UIFigure,'enable');
set(app.UIFigure,'WindowButtonMotionFcn',@(~,~)NaN)
It works like a charm, except my application is not after 'charts' but 'images', RGB images. So I add an Image component to the interface and got this :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/852165/image.jpeg)
You see the image on the right? I would like to retrieve the mouse position when it hovers the image. And eventually use those coordinates to retrieve the image RGB pixel values.
So I tried to modify the above code, by changing the 'traverseFcn' and 'iptSetPointerBehavior' to use an Image component instead but, as it turns out, Image components don't have CurrentPoint properties?
I've been searching the Community, the internet and Matlab Help on how to do this to no avail.
Any help is appreciated.
1 Kommentar
Rik
am 4 Jan. 2022
As far as I can tell, uiaxes do have the current point property. Have you tried putting your callback in a separate function so you can do the indexing in a variable instead of the property?
Akzeptierte Antwort
Roger Breton
am 5 Jan. 2022
1 Kommentar
Rik
am 5 Jan. 2022
Using a global variable is not required.
For the title I would suggest using sprintf to compose the text.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!