Mouse control in GUI and contrast button access

Hi all, I'm designing a GUI (2011a) and have a few things I'm trying to sort out
I've got a stack of mediacl 2D images, and am trying to step through them by rolling the mouse wheel. I can already do this with a slider, but since the dataset is pretty large, the mouse wheel would be far better. Does anyone know how I might achieve this using the mouse wheel?
Also I'd like to be able to use the mouse-controlled contrast adjustment button available in "imtool" in my GUI. As I can create my own button on the file menu, does anyone know how I might have access to the button in my own GUI without launching imtool or using the imcontrast function?
Thanks Jim O' Doherty

1 commentaire

Camille Zimmer
Camille Zimmer le 8 Mai 2012
Déplacé(e) : DGM le 20 Fév 2023
Hello Jim, Did you ever figure this out? I am trying to do the exact same thing, to add a contrast tool to the toolbar? (Your second question). If you have any ideas, your help would be so appreciated! Thanks

Connectez-vous pour commenter.

Réponses (3)

Matt Fig
Matt Fig le 10 Mai 2011

0 votes

For the first question, have a look at the WindowScrollWheelFcn (and cousins) of the GUI figure.
For the second, set the menubar of your GUI to 'figure'. Then you can add your button (menu). (I am not sure I understand this question completely.)

4 commentaires

Jim O'Doherty
Jim O'Doherty le 10 Mai 2011
Hi,
Thanks for the reply. I'll have a look a the WindowScrollWheelsFcn.
I've already added a button to the file menu, what I'd like the button to do is the exact same what the contrast button does in the imtool stand-alone tool, i.e. hold down the mouse button and move the mouse left-right and up-down to adjust the window width and level. There doesn't seem to be any way (that I can see!) to achieve this without launching one of the in-built tools
Jim
Matt Fig
Matt Fig le 10 Mai 2011
In that case, I would go into imtool and look at the callback for the button of interest. You should be able to pretty much copy and paste it into a callback of your own. I don't have IPT, so I am assuming imtool is an M-file...
Matt, imtool is kind of its own thing; I don't think it would be very easy to copy the relevant parts.
Matt Fig
Matt Fig le 10 Mai 2011
I was afraid of that, but it was worth a try...

Connectez-vous pour commenter.

Sean de Wolski
Sean de Wolski le 10 Mai 2011

0 votes

  1. Scroll Wheel: no idea.
  2. The imtool contrast is basically just a histogram with adjustable upper and lower bounds. I think I would implement it with three sliders: one that controls the lower bound, one that controls the upper bound, and one that controls the scalar offset from zero (just like the red bars in imtool). The rescaling of the image based on the two bounds is easy, just algebra. I don't think there is any easy way around making you own adjustment tool and imtool isn't very friendly for interactions with code.
Good Luck!

3 commentaires

Jim O'Doherty
Jim O'Doherty le 10 Mai 2011
Thanks for the tips. Already have the contrast sliders but the mouse control button is a lot more simplistic, and obviously the code is already there.
The hunt goes on
Eduardo Martins
Eduardo Martins le 13 Sep 2018
Modifié(e) : Walter Roberson le 15 Sep 2018
Hello, can you please provide the code for the contrast sliders? I am trying to do this using the code I used for brightness (changing to imcontrast), but it is not working. Thank you.
global im2
val = 0.01 * get(hObject, 'Value') - 0.1;
imbright = im2 + val;
axes(handles.axs_img);
imshow(imbright);
Consider using imcontrast()

Connectez-vous pour commenter.

Walter Roberson
Walter Roberson le 10 Mai 2011

0 votes

You can use imadjust for contrast control.
The function that imtool invokes to do the contrast work is the image toolbox private function imuitools/private/windowlevel.m

Déplacé(e) :

DGM
le 20 Fév 2023

Community Treasure Hunt

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

Start Hunting!

Translated by