How to extract pixel position from Image in app designer ?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Basically , I am devleping an matlab app using matlab app designer.In that I want to exterct pixel position for ferther operation.
I have tried impoint and ginput but proble with that is they are opening grap in new window, I want to select pixel from the same app window.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048535/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048535/image.png)
1 commentaire
Réponses (1)
Siraj
le 7 Sep 2023
Hi! It is my understanding that you have an image displayed in the app designer and would like to obtain the coordinates of the pixel that the mouse pointer is currently hovering over.
To extract the coordinates of the pixel under the mouse pointer in an image displayed in the app designer, you can utilize the "datacursormode" function. This function enables interactive data exploration by creating and editing data tips, which are small text boxes displaying information about specific data points. To better understand the implementation, refer to the provided code example below:
% Button pushed function: TrackanImageButton
function TrackanImageButtonPushed(app, event)
img = imread("TestImage.jpeg");
img = rgb2gray(img);
dcm = datacursormode(ancestor(app.UIAxes, 'figure'));
dcm.Enable = 'on';
imshow(img, 'Parent',app.UIAxes)
end
I have also included the design view of the app for your reference,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1475486/image.png)
For a more comprehensive understanding of “datacursormode” and its configuration options to suit your specific requirements, refer to the link below.
Hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!