hello, i would like to use apply ginput function in such way that the user will chose the amount of coordinates to save (left click) and when he decide to finish so he will click the right button on the mouse.
how do i apply this?
thanks

 채택된 답변

Image Analyst
Image Analyst 2014년 3월 25일

0 개 추천

If you have the Image Processing Toolbox, you can use impoint() instead of ginput().

댓글 수: 5

daniel
daniel 2014년 3월 26일
Thanks for the quick answer, i checked the function help and i didn't find how to apply the desired mouse button. any lead?
thanks again.
You can use ginput but it does not drop down a marker after you click a point so you're essentially doing it blind:
plot(1:9)
grid on;
uiwait(msgbox('Left click points. Type Enter when done'));
[x,y] = ginput()
hold on;
plot(x,y, 'b+');
daniel
daniel 2014년 3월 27일
is there a way to use a loop which will runs until right click will press (this will be the flag which stops the loop), how do i define a variable which get as input the right mouse click (mouse callback)?
thanks.
Joseph Cheng
Joseph Cheng 2014년 3월 27일
See my second post to your question below about how to get the right click.
Daniel, try getpts() instead of ginput:
grayImage = imread('cameraman.tif'); % Read the image into an array
imshow(grayImage); % Display the image
[x,y] = getpts

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 3월 25일

0 개 추천

I do not know if ginput will let you use the right mouse button the way you want. But you can go with something like this. which will select the range of points with the left click. Perhaps a prompt to say these are the points you select, are you sure?
t=1:100;plotDATA = rand(1,100);
figure,plot(t,plotDATA)
[x,y] = ginput(2);
x = sortrows(x);
sectiont = t(ceil(x(1)):floor(x(2)));
sectionData = plotDATA(ceil(x(1)):floor(x(2)));
hold on, plot(sectiont,sectionData,'r.')

댓글 수: 2

Thinking about it more, to get the right click to finalize the selection of points you can use
set(gcf,'WindowButtonDownFcn', yourfunctionhere);
Write a function that uses get(gcf,'SelectionType') which will detect whether it is a left, right, or middle click. Filter for right click with a switch statement that will store or return the points selected by Image Analyst method.
  1. normal: left mouse button
  2. extend: right mouse button on a 2-button mouse; middle mouse button on a 3-button mouse
  3. alt: left+right buttons on a 2-button mouse; right mouse button on a 3-button mouse
  4. open:double mouse click
an example of this function working and detecting what mouse button is pressed:
figure,plot(1:100);
set(gcf,'WindowButtonDownFcn', 'disp(get(gcf,''SelectionType''));');
daniel
daniel 2014년 3월 27일
Thanks!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Exploration에 대해 자세히 알아보기

태그

질문:

2014년 3월 25일

댓글:

2014년 4월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by