GUIDE: build an array of pixel coordinates by pressing button or carriage return
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Paulo Silva
2011년 2월 28일
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?!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!