- 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
6 views (last 30 days)
Show older comments
Michael Loutzenheiser
on 11 Jun 2021
Commented: Michael Loutzenheiser
on 15 Jun 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 Comments
Accepted Answer
Aghamarsh Varanasi
on 14 Jun 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
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!