imshow

Displays an image with the right scale, colormap and aspect ratio.

Category: Graphics > Images

Syntax

imshow(I)

Shows a grayscale, RGB or binary image.

imshow(I, [low high])

Displays grayscale data with low as black and high as white.

imshow(X, map)

Shows an indexed image with the colormap map.

h = imshow(___)

Returns the image object.

Description

Unlike image, imshow sets pixels to be square, hides the axes ticks and chooses scaling by class, so a uint8 image looks right without further setup. Pass [] as the range to stretch the data's own minimum and maximum over the display.

Input arguments

I
Image array. Integer images use their full class range; double data is read as [0, 1].
[low high]
Display range for grayscale data.

Output arguments

h
Image object.

Example

Show a small gray image

I = uint8([0 255; 128 64]);
h = imshow(I);
disp(class(h))
Output
matlab.graphics.primitive.Image

See also

image imagesc imread imresize colormap