Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

contrast

Create grayscale colormap to enhance image contrast

Syntax

newmap = contrast(I)
newmap = contrast(I,m)

Description

example

newmap = contrast(I) creates a grayscale colormap that enhances the contrast of image I. The new colormap increases the contrast among pixels that are difficult to distinguish visually, but have slightly different brightness values.

example

newmap = contrast(I,m) returns the new colormap as an m-by-3 array. Use this syntax when you want the new colormap to have a different number of rows than the original colormap.

Examples

collapse all

Load clown to get image X and its associated colormap, map. Display the image produced by X and map.

load clown 
figure
imagesc(X)
colormap(map)

Use contrast to return a gray colormap that enhances the contrast of image X. Then update the display with the new colormap.

newmap = contrast(X);
colormap(newmap)

Load clown to get image X.

load clown

Create a contrast-enhancing colormap for the clown image. Then display the image using the new colormap.

figure
imagesc(X)
newmap1 = contrast(X);
colormap(newmap1)

Next, use contrast to create another colormap containing only 10 shades of gray. Update the display with the new colormap. Notice that the shadow areas are lighter and have lost some detail.

newmap2 = contrast(X,10);
colormap(newmap2)

Input Arguments

collapse all

Image to enhance, specified as an m-by-n matrix or an m-by-n-by-3 truecolor image.

Number of rows in the new colormap, specified as a numeric scalar value.

Note

When m is significantly different than the number of rows in the original colormap, the new colormap might be missing some values or contain repeated values. This discrepancy might reduce the amount of tonal detail in the enhanced image.

Example: newmap = contrast(I,50) returns a colormap containing 50 rows.

See Also

| |

Introduced before R2006a

Was this topic helpful?