How to extract pixel position from Image in app designer ?

8 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Siraj
Siraj il 7 Set 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,
For a more comprehensive understanding of datacursormode and its configuration options to suit your specific requirements, refer to the link below.
Hope this helps.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by