Adjust Contrast tool
imcontrast function to create an Adjust Contrast
tool. The Adjust Contrast tool enables you to interactively adjust the contrast and
brightness of a displayed grayscale image. For more information about using the tool,
The Adjust Contrast tool adjusts the values of the pixels used to display the
image but does not change the actual image data. If you want to change the image
data, use the
imcontrast creates an Adjust Contrast tool in a separate
figure that is associated with the grayscale image in the current figure.
imcontrast( creates an Adjust Contrast
tool associated with the image in the graphics container
returns the figure
hTool = imcontrast(___)
hTool containing the Adjust Contrast
Adjust the Contrast of the Current Image
Display an image and adjust the contrast of the image.
Adjust Image Contrast, Specifying Figure Handle
Read an image into the workspace and define the handle of the
h1. Open a second figure window and define the
handle of that figure as
h2. Adjust the contrast of the first
figure by specifying
h1 in the call to
h1 = figure; imshow("pout.tif") h2 = figure; imshow("coins.png") imcontrast(h1)
h — Graphics object containing image
Figure object |
Panel object |
Axes object |
Graphics object containing the image, specified as a
Image object. If
h is an axes or
imcontrast uses the first image returned
hTool — Adjust Contrast tool
Adjust Contrast tool, returned as a
The Adjust Contrast tool presents a scaled histogram of pixel values (overly represented pixel values are truncated for clarity). Dragging on the left red bar in the histogram display changes the minimum value. The minimum value, and any pixel value less than the minimum, display as black. Dragging on the right red bar in the histogram changes the maximum value. The maximum value, and any value greater than the maximum, display as white. Values in between the red bars display as intermediate shades of gray.
Together the minimum and maximum values create a "window". Stretching the window reduces contrast. Shrinking the window increases contrast. Changing the center of the window changes the brightness of the image. It is possible to manually enter the minimum, maximum, width, and center values for the window. Changing one value automatically updates the other values and the image.
Click and drag the mouse within the target image to interactively change the window values. Dragging the mouse horizontally from left to right changes the window width. Dragging the mouse vertically up and down changes the window center. Holding down the Ctrl key before clicking and dragging the mouse accelerates the rate of change; holding down the Shift key before clicking and dragging the mouse slows the rate of change. Keys must be pressed before clicking and dragging.
When you use the tool,
imcontrastadjusts the contrast of the displayed image by modifying the axes
CLimproperty. To modify the actual pixel values in the target image, click the Adjust Data button. This button is unavailable until you make a change to the contrast of the image.
The Adjust Contrast tool can handle grayscale images of class
singlewith data ranges beyond the default display range of [0, 1]. For these images,
imcontrastsets the histogram limits to fit the image data range, with padding at the upper and lower bounds.
Introduced before R2006a