- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Aghamarsh Varanasi
2021-6-14
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!