image

Displays an array as an image, with each value taken as a colormap index or a color.

Category: Graphics > Images

Syntax

image(C)

Displays C. A matrix is indexed into the current colormap; an m-by-n-by-3 array is read as RGB.

image(x, y, C)

Places the image so the first and last pixels are centered at the x and y limits.

h = image(___)

Returns the image object.

Description

image does not rescale the data: values are used directly as colormap positions, so values outside the colormap are clipped. For automatic scaling use imagesc. Pixels are drawn as squares, and the y-axis may run downward depending on the axes setup.

Input arguments

C
Matrix of indices or an RGB array. For double data, indices start at 1; for uint8, at 0.
x, y
Two-element vectors of pixel-center limits.

Output arguments

h
Image object; h.CData holds the data.

Example

Matrix as image

h = image([1 2; 3 4]);
disp(class(h))
disp(h.CData)
Output
matlab.graphics.primitive.Image
     1     2
     3     4

See also

imagesc imshow colormap colorbar