Main Content

Adjust Image Contrast in Image Viewer App

An image lacks contrast when there are no sharp differences between black and white. Brightness refers to the overall lightness or darkness of an image. Contrast adjustment works by manipulating thedisplay rangeof the image. Pixels with value equal to or less than the minimum value of the display range appear black. Pixels with value equal to or greater than the maximum value of the display range appear white. Pixels within the display range appear as a smooth gradient of shades of gray. Adjusting the contrast spreads the pixel values across the display range, revealing much more detail in the image.

The default display range of an image is determined by the image data type. For instance, the display range for images with data typeuint8is 0 to 255. If thedata range, or actual minimum and maximum pixel values of the image data, is more narrow than the display range, then the displayed image does not display all shades of gray from black to white. In this case, you can improve the image contrast by shrinking the display range to match the data range. To highlight certain image features, you can further shrink the display range to be less than the data range.

TheImage Viewerapp offers two tools that enable you to change the contrast or brightness of an image interactively. The Window/Level tool enables you to change contrast and brightness by simply dragging the mouse over the image. The Adjust Contrast tool displays a histogram of image pixel values and graphical representation of the display range so that you can see how the display range relates to pixel values.

Adjust Contrast and Brightness using Adjust Contrast Tool

After you open an image inImage Viewer, open the Adjust Contrast tool by clickingAdjust Contrastin theImage Viewertoolbar. For more information about opening an image inImage Viewer, seeOpen Image Viewer App

The Adjust Contrast tool displays a histogram of pixel values and information about the data range. The data range is a fixed property of the image data and does not change when you adjust the display range using the Adjust Contrast tool. The Adjust Contrast tool also displays a red-tinted rectangular box, called awindow, overlaid on the histogram. The window directly corresponds to the display range of the image. The tool also shows the precise values of the precise values of the range and location of the window on the histogram.

For example, in the figure, the histogram for the image shows that the data range of the image is 7 to 253. The display range is the default display range for theuint8data type, 0 to 255. Therefore, no pixels appear as black or white. Further, the histogram shows that many pixel values are clustered in the middle of the display range, which explains why it is challenging to distinguish between the medium-gray pixel values.

To increase the contrast of the image, narrow the range of pixel values. To increase the brightness of an image, shift the range towards large pixel values. There are three ways to adjust the display range of the image.

  • You can adjust the display range interactively by manipulating the window. Adjust the minimum and maximum value of the display range by clicking and dragging the left and right edges of the window. Change the position of the window by clicking and dragging the interior of the window.

  • You can enter specific values for the extent, width, and center of the window. 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.

  • You can let the Adjust Contrast tool scale the display range automatically. When you select theMatch data rangeoption, the tool makes the display range equal to the data range of the image. When you select theEliminate outliers选项,工具删除同等比例的πxels from the top and bottom of the display range. By default, the tool eliminates 2% of pixels, in other words, the top 1% and the bottom 1% of pixels. (You can perform this same operation using thestretchlimfunction.)

The display range of the image displayed in theImage Viewerwindow updates in real time when you change the display range.Image Vieweralso updates the display range values displayed in the lower right corner of the app window.

For example, in the figure, the window indicates that the display range of the image is 12 to 193. Bright pixels appear much brighter than in the original image. There is better contrast between pixels with similar gray values, such as for the pillars and roof of the domed buildings.

Adjust Contrast and Brightness Using Window/Level Tool

To start the Window/Level tool, click theWindow/Levelin theImage Viewertoolbar or select theWindow/Leveloption from theImage ViewerToolsmenu.

Move the pointer over the image. The pointer changes to the Window/Level cursor。调整图像的对比, click and drag the mouse horizontally. To adjust image brightness, click and drag the mouse vertically.

If you also have the Adjust Contrast tool open, then contrast adjustments you make using the Window/Level tool immediately adjust the window in the Adjust Contrast tool. For example, if you increase the brightness using the Window/Level tool, then the window in the Adjust Contrast tool shifts to the right.

When you close the Adjust Contrast tool, the Window/Level tool remains active. To stop the Window/Level tool, click theWindow/Levelbuttonor any of the navigation buttons in theImage Viewertoolbar.

Make Contrast Adjustments Permanent

The Adjust Contrast tool and Window/Level tool adjust the values of the pixels used to display the image inImage Viewerbut do not change the actual image data.

When using the Adjust Contrast tool, you can modify pixel values in the image to reflect the contrast adjustments by clicking theAdjust Databutton. When you click theAdjust Databutton, the histogram updates. 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

TheAdjust Databutton is unavailable until you make a change to the contrast of the image.

When you closeImage Viewer, the app does not save the modified image data. To save these changed values, use theSave Asoption from theImage ViewerFilemenu to store the modified data in a file or use theExport to Workspaceoption to save the modified data in a workspace variable. For more information, seeSave and Export Results

See Also

|

Related Topics