In a comp.soft-sys.matlab newsgroup post on January 17, Kevin wanted to know how the brightness/contrast control in imtool worked. Image Processing Toolbox function imtool is an image viewing/navigation GUI.
In medical imaging the brightness/contrast control is called the "window/level" control, and there is a reasonably standard set of mouse motions for changing the window and level. These mouse motions are supported by imtool.
This diagram shows how the terms "window" and "level" are related to brightness and contrast adjustment. Making the window wider or narrower decreases or increases the display contrast; moving the level left or right changes the display brightness.
This window-level scaling function is just like the CLim scaling function I described previously. I replied to Kevin that the brightness/contrast control in imtool worked by adjusting the axes CLim property.
Here's an non-medical example of how adjusting the CLim can make previously unseen image details visible.
I = imread('cameraman.tif'); imshow(I) text(256, 265, 'Image courtesy of Massachusetts Institute of Technology', ... 'HorizontalAlignment', 'right', 'FontWeight', 'light', 'FontSize', 7, ... 'Color', [.7 .7 .7])
Not much detail is visible in the coat or glove. But you can make out much more detail if you change the CLim property of the axes:
imshow(I) set(gca, 'CLim', [6 21]) % caxis([6 21]) does the same thing.
If you want to see how to make this adjustment interactively, look here in the Image Processing Toolbox Users Guide.
Get
the MATLAB code
Published with MATLAB® 7.1


The link on this page doesn’t work! (to the IPT user guide)
Greg – I fixed the link.
it’s helpful to me.thank u!
I want to form a cube consisted of pixels and place this to a coordinate frame. if you help me ı will be very glad
Ali – I’m sorry, but I don’t understand your question. Can you be a lot more specific about what you want to do? What are your inputs, and what output do you want?
I’m using the imtool function for adjusting contrast in an image after a fast Fourier transform. After adjusting the contrast using imtool, I still need to use data from the image for further analysis. However, the 256X256 image I had prior to using imtool, is now only one number and no further processing can be done. Is there a way I can get the image data? I tried exporting the data back to the workspace, but am not sure how to update the rest of the code so that it uses the new contrasted image
Shaili—I have no idea what you mean by saying your image is now only one number.
Steve,
In Imtool there is a button for adjustment of the window/level directly through click-and-drag on the image, without opening the “ImContrast” GUI. I think I located this functionality to the “windowlevel.m” file. I like this feature and want to use it in a GUI of my own. Is there a simple way to do this? I tried but couldn’t really figure out what input handles the windowlevel function expects. I tried to just use the handle of the axes containing my image, but that didn’t work.
Jonas—windowlevel is a private function that is not directly callable. I don’t generally get into GUI programming in this blog because it is neither my area of expertise nor my main interest. You might try posting your question to the MATLAB newsgroup or to MATLAB Answers.
Ok, thank you for your quick reply, I’ll try the newsgroups. /Jonas