File Exchange

image thumbnail

GINPUT on GUI (Keeping toolbar features on) & Use of custom pointers

version 1.1 (26.2 KB) by

GUI Framework to use GINPUT (keeping all toolbar features on) + Custom pointers for plots and more.

15 Downloads

Updated

View License

This is basically a GUI framework, inviting users to tweak it to their needs. It comes with the following salient features:

1. Shows different Pointers when mouse is hovered over one or more than one plots. The number of plots used in this framework is two, but it can be easily extended to more numbers if needed.

2. Point clicking on the plots can be associated to custom functions and thus they can be used to act as region selection, image data finding, image coordinate finding, etc. In one of my previous projects I extended this GUI framework to make it able to display multiple rectangular boxes on a single plot, change the Pointer whenever mouse was hovered over one of these boxes, click one of these and display the data from the selected rectangular box onto another plot. So, that’s possible too, if anyone is interested.

3. X and Y coordinates of the points clicked are obtainable as GUI output. Thus, it can also be used to act as GINPUT, while keeping the commonly used figure toolbar features on and letting user activate any GUI component. When GINPUT is called, user needs to complete the point selection before proceeding with any other instruction. During the point selection with GINPUT, the GUI toolbar features like Zoom-in, Zoom-out, Pan and few others get disabled. This limitation doesn’t exist in this code, as inherently it simulates GINPUT for point selection only, but lets user proceed with the next instruction or other functions. This GINPUT-style point selection is also continuous, meaning user won’t need to activate it with any GUI component, but of course its start and stop is controllable. The figure toolbar features that are available with this GUI are - New Figure, Open File, Print Figure, Zoom In, Zoom Out, Pan, Rotate 3D, Data Cursor, Insert Colorbar & Insert Legend.

4.With minor tweaking, it’s possible to modify this framework to make it act as IMPIXEL, but use commonly used figure toolbar features as well, unlike in IMPIXEL. This can be found on MATLAB Central too.

Feedback / Bugs / How-this-helped / How-this-sucked / How-this-could_be_improved / Anything about it are MOST welcome. For contacting me, please click on my name above that will direct you to my homepage and on it, click on "Contact Author" link.

Comments and Ratings (6)

Jimmy

Jimmy (view profile)

Nearly identical error trace as reported by adi, this time for Matlab 8.3.0.532 (R2014a) on Ubuntu Linux.

adi

adi (view profile)

tried it with matlab 2013a as instructed in the example:
[pt1cell,pt2cell] = ginput_gui(img1,[],img2,[]);

got an error....

Error using load
Unable to read file 'ginput_gui.fig':
no such file or directory.

Error in
graphics.internal.figfile.FigFile/read
(line 25)
hgDataVars = load(filename, '-mat',
'-regexp', '^hg[SO]');

Error in
graphics.internal.figfile.FigFile
(line 98)
obj.read(file);

Error in C:\Program
Files\MATLAB\R2013a\toolbox\matlab\graphics\hgload.p>hgload
(line 59)

Error in openfig (line 72)
[fig, savedvisible] =
hgload(filename,
struct('Visible','off'));

Error in gui_mainfcn>local_openfig
(line 286)
gui_hFigure = openfig(name,
singleton, visible);

Error in gui_mainfcn (line 159)
gui_hFigure =
local_openfig(gui_State.gui_Name,
gui_SingletonOpt,
gui_Visible);

Error in ginput_gui (line 122)
gui_mainfcn(gui_State,
varargin{:});

Divakar Roy

Divakar Roy (view profile)

Harold -

Maybe you can start with my GUI and add your GUI stuffs on top of it.

Otherwise if you want to add my GUI stuffs on top of yours, you need to make the changes listed below and it is assumed that you are starting off with a blank GUI that automatically creates functions like OpeningFcn, etc. on your behalf.
Changes:
1. Edit these two functions to include my stuffs from – OpeningFcn and OutputFcn.
2. Add these functions that are needed for OutputFcn - detect_mouse_hover, detect_mouse_press_print_plus, detect_mouse_press_do_nothing, estimate_new_position. The toolbar functions can be similarly edited, if needed.

Hope this helps!

Harold

Harold (view profile)

Would really like to use this function in my own function but I am having trouble figuring out what I need to keep. I already have my GUI made in GUIDE. So basically I need all the functionality of what your code has but for my GUI. I also have only one figure.

Divakar Roy

Divakar Roy (view profile)

Nicolas,

Yes, that should be possible. You are needed to trigger an infinite loop inside function - detect_mouse_press_print_plus or make a new one similar to it but with an infinite loop that plots the marking symbols ('+' in the code) continuously.

Then add WindowButtonUpFcn in the function - detect_mouse_hover, so that the infinite loop could be broken when user releases the pressed mouse button.

To accomplish all this, you most probably would require a flag.

Hope this helps.

Very interesting tool; would there be a way to enable holding down the mouse button and dragging around to effectively paint on the image?

Updates

1.1

Minor revision in the documentation.

MATLAB Release
MATLAB 7.13 (R2011b)
Acknowledgements

Inspired: IMPIXEL with FIGURE TOOLS

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