smart ginput or getpts : how to unselect a point
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (2)
Vinny Chandran Suja
el 3 de Nov. de 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:
while(1)
[Imx, Imy , mb]=ginput(1);
if mb==1
data(:,count)=[Imx,Imy];
% optionally display points
handlesPointsInImage(:,count)=plot(Imx,Imy,'.r');
end
if mb==3
ind=knnsearch(data(1:2,:)',[Imx,Imy]);
data(:,ind)=[];
% if points were displayed
delete(handlesPointsInImage(:,ind));
handlesPointsInImage(:,ind)=[];
end
if mb==2 % Middle mouse button exits the pick mode
break;
end
count = count +1;
end
0 comentarios
Image Analyst
el 10 de Ag. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!