ginput with right mouse button
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Image Analyst
le 25 Mar 2014
If you have the Image Processing Toolbox, you can use impoint() instead of ginput().
5 commentaires
Joseph Cheng
le 27 Mar 2014
See my second post to your question below about how to get the right click.
Image Analyst
le 19 Avr 2014
Daniel, try getpts() instead of ginput:
grayImage = imread('cameraman.tif'); % Read the image into an array
imshow(grayImage); % Display the image
[x,y] = getpts
Plus de réponses (1)
Joseph Cheng
le 25 Mar 2014
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 commentaires
Joseph Cheng
le 26 Mar 2014
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.
- normal: left mouse button
- extend: right mouse button on a 2-button mouse; middle mouse button on a 3-button mouse
- alt: left+right buttons on a 2-button mouse; right mouse button on a 3-button mouse
- 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''));');
Voir également
Catégories
En savoir plus sur Visual Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!