removing previously selected points from image and displaying value?
15 views (last 30 days)
Show older comments
How do I remove a selected point from an image and display its value?
I want it to prompt the user to select point A on an image, once they do I'd like it to display that value and record it in an array, before asking the user to select point B on an image, how do i do this?
So far I've got this but it doesn't work:
Map=imread('Map.Jpg');
imshow(Map);
uiwait(msgbox('Choose Point A'));
[x,y] = ginput(1); hold on;
plot(x,y,'r+', 'MarkerSize', 50);
disp(ginput(1));
uiwait(msgbox('Choose Point B'));
[x,y] = ginput(2); hold on;
plot(x,y,'r+', 'MarkerSize', 50);
disp(ginput(2));
Please help, tearing hair out!
0 Comments
Answers (2)
Guillaume
on 2 Nov 2017
plot returns a handle to the points/lines it created. To get rid of these lines/points you call the delete function on these handles, so:
uiwait(msgbox('Choose Point A'));
[x,y] = ginput(1); hold on;
hline = plot(x,y,'r+', 'MarkerSize', 50);
disp(ginput(1));
%when you want to get rid of the point:
delete(hline);
3 Comments
Guillaume
on 2 Nov 2017
Please use the {}Code button to format your code appropriately in your comments/questions.
A good idea when you say you get an error is to give the full text of the error message rather than letting us guess what it is. In this case, clearly you're going to get the error undefined function or variable hline
I did write: "plot returns a..." So you have to capture that return value. As I have shown:
hline = plot(...
Attempting to
delete(hline)
when you've never created the hline variable in the first place is of course never going to work.
See Also
Categories
Find more on Data Distribution Plots 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!