File Exchange

image thumbnail

ginput2.m v3.1 (Nov 2009)

Same as GINPUT but with ZOOM, PAN and (optionally) PLOT and image SCALE/GEOREFERENCE!

9 Ratings



View License

Do you still use GINPUT to graphically select points on current axes with the mouse? Try this one!

With GINPUT2 you can also:
1. ZOOM: in, out (double-click)!
2. PAN: when dragging!
3. DELETE: last selected point!
4. PLOT: while selecting! (optional, just input the line style!)
5. SCALE or GEOREFERENCE images! (optional, just input: true)

So, besides of selecting points in a more precise way (zooming) you can DIGITIZE(!!!) lines with the last two options, by simply using:
>> ginput2(true,'.k')

Enjoy it!
Bug reports and comments will be very appreciated!

Comments and Ratings (11)



GagoX (view profile)

To deactivate the rezoom, just comment line 613

% Centers the selected point if ZOOM-IN: 29 SEP,2008
if all((lim~=zlim))
lim = [x+diff(lim(1:2))/2*[-1 1] y+diff(lim(3:4))/2*[-1 1]];
axis(lim) %Comment this line to deactivate recentering after each point selection


adi (view profile)

needs one big improvement: when I zoom in, the image jumps every time I select a point! this is very annoying... otherwise, a very good tool


This looks very promising, but isn't working for me - I've tried various ways of running it, including the examples in the source, and every time I click on the plot it simply zooms in. I'm sure this isn't the expected behaviour - I can't get it to select any points at all, just zoom.

I'm using R2012a.


Sherif (view profile)

Excellent work. Thank you very much.


Igor (view profile)


Mehdi (view profile)

Thanks for sharing such a useful code,
for my data, after running my code I get images for which I need the following action:
When selecting a part of image,I want Matlab to run my code for that area and calculate or graph other parameters for that part of image,
How can I do that?


I take that back. It does work on 3 dimension picture.
I apologize.


Olga Avila

This is really good!
It works perfect for me, and was exactly what I needed...
I just added a minor detail to plot a line from an input center point to the ginput point selected by the user (like a radial line). This was just to improve visualization for my needs.
Thank you very much!



v3.1 Now returns when N=1 and an "strange" KEY is pressed.


v3.0 Now allows panning while dragging. Some changes on help.


v2.1 Fixed bugs related with points delection. Added new 'keepzoom' feature.


Changed default YESERROR value and fixed a bug there. Changed behavior when N==1. Fixed bug with zoom out. Changed default selection keys. Changed default selection click mouse: from left one to the right one.

MATLAB Release
MATLAB 7.7 (R2008b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today