GUIDE: build an array of pixel coordinates by pressing button or carriage return
4 views (last 30 days)
Show older comments
Hello,
I have built (with a lot of help) a basic GUI that allows a user to select a region of interest for an image, and then navigate (using buttons) pixel by pixel around that region of interest to select the exact pixels they want to examine...
When the user finds a pixel they are interested in, they should press a "tag" button or preferably, just the carriage return. A cell array of the pixel coordinates should then be built and the user can navigate around to find a second pixel of interest and tag that too... and so on until they have x amounts of pixel coordinates.
My question is how can I build this cell array whenever they click the button? I have the coordinates already but I don't know how to insert them into a cell array each time the user clicks tag... Is it also possible to do this on a carriage return?
Thanks!!
0 Comments
Accepted Answer
Paulo Silva
on 28 Feb 2011
I can't make it to work with the carriage return but it does work great with the space button (32) and mouse left button (1), use the carriage return or other button to stop entering points.
button=1;xx=[];yy=[];
while ((button==1) | (button=32))
[x,y,button]=ginput(1);
plot(x,y,'rx') %mark the point
if ((button==1) | (button=32))
xx=[xx x];yy=[yy y];
end
end
This code results on vectors 1xN where N is the number of points marked.
If you want to combine them in just one array do
XYP=[xx' yy'];
or
XYP=[xx;yy];
If you want in cell format use the function mat2cell
You ask for cell and array in the same question?!
More Answers (0)
See Also
Categories
Find more on Denoising and Compression 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!