- You can create a WindowButtonDownFcn for your UIFigure by right clicking on your UIFigure in the Component Browser, selecting "Callbacks" from the context menu, then selecting "WindowButtonDownFcn".
- Once this is done, App Designer should switch to Code View to display your newly created callback. This callback method can access the current coordinates of the mouse pointer by using the CurrentPoint property Eg: app.UIFigure.CurrentPoint
How do I open imtool pixel selector within a GUI
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael Loutzenheiser
el 11 de Jun. de 2021
Comentada: Michael Loutzenheiser
el 15 de Jun. de 2021
I am trying to create a GUI for selecting pixel locations from an image containing a calibration grid. Currently, the GUI is set up to open the Image Toolbox in a seperate window upon pressing the "Open Pixel Selector" button on the interface. I would like to simply have this figure open at all times within the GUI instead of opening in another window. The plot shown in the GUI is for reference to show the pixel pairs that have been selected already, and should remain unchanged.
Here is the GUI for reference:
Here is the tool opened by "Open Pixel Selector":
Here is the code implemented in app designer for opening the ginput tool in a seperate window. I am assuming the code I need to complete this problem will either be placed here or within the startup function. Also, I may need to use a function other than ginput()?
function OpenPixelSelectorButtonPushed(app, event)
rgbImage = imread('http://192.168.1.115/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wfw&user=camera&password=camera');
imshow(rgbImage);
[xvals yvals] = ginput(2);
x1 = xvals(1,:); y1 = yvals(1,:);
x2 = xvals(2,:); y2 = yvals(2,:);
app.new_line = {x1 y1 x2 y2};
app.HoldingTable.Data = app.new_line;
plotgraph(app);
hold(app.UIAxes,'on');
plot(app.UIAxes,[x1 x2],[y1 y2],'b+-')
hold(app.UIAxes,'off');
end
0 comentarios
Respuesta aceptada
Aghamarsh Varanasi
el 14 de Jun. de 2021
Hi,
1. You can open an image within the app using imshow and setting the parent of the image.
imshow(rgbImage, 'Parent', app.UIAxes);
2. To get the coordinates from the image,
Hope this helps
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!