smart ginput or getpts : how to unselect a point
24 views (last 30 days)
I need a GUI for selecting many points in an image. I want Matlab to delete a previously selected point if I click it again, or click on it with the right mouse button (not just the last point I selected, but any of the previous points!). how do I do this? tnx
Image Analyst on 10 Aug 2014
I don't think there is a way for ginput(), but for getpts(), the help says: "Pressing Backspace or Delete removes the previously selected point." getpts() has the advantage that it drops down a marker where you click whereas ginput() does not.
Vinny Chandran Suja on 3 Nov 2017
As ImageAnalyst said there is no inbuild feature in ginput that supports your requirement. However, I came up with the following workaround:
(a) Query single points from ginput in a loop
(b) [For selecting points] If the input was from a left click, add the data to an array/structure
(c) [For removing points] If the input was from a right click, query the nearest neighbor from the array/structure and remove it from the dataset.
A minimal example is below for:
[Imx, Imy , mb]=ginput(1);
% optionally display points
% if points were displayed
if mb==2 % Middle mouse button exits the pick mode
count = count +1;