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

采纳的回答

Aghamarsh Varanasi
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,
  • 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
Hope this helps
  1 个评论
Michael Loutzenheiser
Thanks Aghamarsh!
This helps alot, however, I am still wondering how to get the entirety of the image toolbox into the matlab GUI. I would like to utilize the zoom functions as well when selecting pixels. Thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by