This section describes how to use the Adjust Contrast tool in the Image Viewer.
View an image in the Image Viewer.
You can also use the Adjust Contrast tool independent of the
Image Viewer by calling the
Click Adjust Contrast in the Image Viewer toolbar, or select the Adjust Contrast option from the Image Viewer Tools menu. The Adjust Contrast tool opens in a separate window containing a histogram of the image displayed in the Image Viewer. The histogram shows the data range of the image and the display range of the image. The data range is the range of intensity values actually used in the image. The display range is the black-to-white mapping used to display the image, which is determined by the image class. The Adjust Contrast tool works by manipulating the display range; the data range of the image remains constant.
For example, in the following figure, the histogram for the
image shows that the data range of the image is 74 to 224 and the
display range is the default display range for the
0 to 255. The pixel values for the image are clustered in the middle
of the display range. Adjusting the contrast spreads the pixel values
across the display range, revealing much more detail in the image.
To adjust the contrast of the image, you can manipulate the red-tinted rectangular box, called a window, that the Adjust Contrast tool overlays on the histogram. By changing the size and position of this window using the mouse, you can modify the display range of the image and improve its contrast and brightness — see Adjust Image Contrast Using the Histogram Window.
Note You can also use the Window/Level tool to adjust contrast and brightness using the mouse. (The name comes from medical applications.) Click Window/Level in the Image Viewer toolbar or select the Window/Level option from the Image Viewer Tools menu. For more information about using the Window/Level tool, see Adjust Image Contrast Using Window/Level Tool.
When you close the Adjust Contrast tool, the Window/Level tool remains active. To turn off the Window/Level tool, click the Window/Level button or one of the navigation buttons in the Image Viewer toolbar.
To adjust image contrast using the Adjust Contrast tool, you manipulate the size of the red-tinted window displayed over the histogram, using any of the following methods.
Grabbing one of the red handles on the right and left edges of the window and dragging it. You can also change the position of the window by grabbing the center line and dragging the window to the right or left.
Specifying the size and position of the window in the Minimum and Maximum fields. You can also define these values by clicking the dropper button associated with these fields. When you do this, the pointer becomes an eye dropper shape. Position the eye dropper pointer over the pixel in the image that you want to be the minimum (or maximum) value and click the mouse button.
Specifying the size and position of the window in the Width and Center fields.
Selecting the Match data range button in the Scale Display Range part of the tool. When you choose this option, the size of the window changes from the default display range to the data range of the image.
Trimming outliers at the top and bottom of the image
data range. If you select the Eliminate outliers option,
the Adjust Contrast tool removes the top 1% and the bottom 1%, but
you can specify other percentages. When you specify a percentage,
the Adjust Contrast tool applies half the percentage to the top and
half to the bottom. (You can perform this same operation using the
The following figure shows these methods of adjusting contrast. The Image Viewer updates the display range values displayed in the lower right corner of the Image Viewer as you change the size of the window.
To start the Window/Level tool, click Window/Level in the Image Viewer toolbar.
Using the Window/Level tool, you can change the contrast and brightness of an image by simply dragging the mouse over the image. Moving the mouse horizontally affects contrast; moving the mouse vertically affects brightness. Note that any contrast adjustments you make using the Window/Level tool are reflected immediately in the Adjust Contrast tool. For example, if you increase the brightness, the window in the Adjust Contrast moves over the histogram.
The following table summarizes how these mouse motions affect the size and position of the window in the Adjust Contrast tool.
Horizontally to the left
Shrinks the window from both sides.
Horizontally to the right
Expands the window from both sides.
Moves the window to the right over the histogram, increasing brightness.
Moves the window to the left over the image histogram, decreasing brightness.
To stop the Window/Level tool, click the
in the Image Viewer toolbar, or click any of the navigation buttons
in the toolbar.
Read an image from a sample DICOM file included with the toolbox.
I = dicomread('CT-MONO2-16-ankle.dcm');
View the image data using the Image Viewer. Because the image data is signed 16-bit data, this example uses the autoscaling syntax.
Click the Window/Level button to start the tool, or select Window/Level from the Tools menu in the Image Viewer.
Move the pointer over the image. The pointer changes to the Window/Level cursor .
Click and drag the left (or right) mouse button and move the pointer horizontally to the left or right to adjust the contrast, or vertically up or down to change the brightness.
By default, the Adjust Contrast tool adjusts the values of the pixels used to display the image in the Image Viewer but does not change the actual image data. To modify pixel values in the image to reflect the contrast adjustments you made, you must click the Adjust Data button.
The following example illustrates this process.
Display an image in the Image Viewer. The example opens an image from a file.
Start the Adjust Contrast tool by clicking the Adjust contrast button, , or by selecting Adjust Contrast from the Tools menu in the Image Viewer.
Adjust the contrast of the image. Use one of the mechanisms provided by Adjust Contrast tool, such as resizing the window over the histogram. See Adjust Image Contrast Using the Histogram Window. You can also adjust contrast using the Window/Level tool, moving the pointer over the image.
Adjust the image data to reflect the contrast adjustment you just made. Click the Adjust Data button in the Adjust Contrast Tool. When you click the Adjust Data button, the histogram will update. You can then adjust the contrast again, if necessary. If you have other interactive modular tool windows open, they will update automatically to reflect the contrast adjustment.
Note: The Adjust Data button is unavailable until you make a change to the contrast of the image.
By default, if you close the Image Viewer, it does not save the modified image data. To save these changed values, use the Save As option from the Image Viewer File menu to store the modified data in a file or use the Export to Workspace option to save the modified data in a workspace variable.