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 displays a histogram of pixel values and information about the data range and display range.
The data range corresponds to the underlying pixel values of the image. The data range is a fixed property of the image data, and, by default, does not change when you adjust the display range using the Adjust Contrast tool.
The display range controls the display of the image. Any pixel with a value less than or equal to the minimum value of the display range displays as black. Any pixel with a value greater than or equal to the maximum value displays as white. In the Adjust Contrast tool, the red-tinted box overlaid on the histogram corresponds to the display range.
You can use the Adjust Contrast tool to adjust the display range of the image in these ways.
Adjust the minimum and maximum values of the display range by dragging the left and right edges of the red window. Change the center of the window by dragging the dotted line in the interior of the window.
Enter specific values in the Window section. You can also define the minimum or maximum value by clicking the dropper button next to the corresponding field. When you do this and move the pointer over the image, the pointer becomes an eye dropper shape. Position the eye dropper shape over the pixel with the value that you want to be the minimum or maximum and left-click.
Scale the display range automatically. Select Match Data Range to make the display range equal to the data range of the image. Select Eliminate outliers to saturate an equal percentage of pixels at the top and bottom of the display range. By default, the tool eliminates 2%, so the top 1% and the bottom 1% of pixel values. This is equivalent to the operation performed by the
When you use the Adjust Contrast tool,
imcontrastadjusts the contrast of the displayed image by modifying the axes
CLimproperty. To modify the actual pixel values in the target image, select Adjust Data. You cannot select Adjust Data until you make a change to the contrast of the image.
The Adjust Contrast tool can process 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