How do I open imtool pixel selector within a GUI

5 ビュー (過去 30 日間)
Michael Loutzenheiser
Michael Loutzenheiser 2021 年 6 月 11 日
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
Michael Loutzenheiser 2021 年 6 月 15 日
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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by