Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Display image with scaled colors

`imagesc(C)`

`imagesc(x,y,C)`

`imagesc('CData',C)`

`imagesc('XData',x,'YData',y,'CData',C)`

`imagesc(___,Name,Value)`

`imagesc(___,clims)`

`imagesc(ax,___)`

`im = imagesc(___)`

`imagesc(`

displays
the data in array `C`

)`C`

as an image that uses the
full range of colors in the colormap. Each element of `C`

specifies
the color for 1 pixel of the image. The resulting image is an `m`

-by-`n`

grid
of pixels where `m`

is the number of columns and `n`

is
the number of rows in `C`

. The row and column indices
of the elements determine the centers of the corresponding pixels.

`imagesc(`

specifies
the image location. Use `x`

,`y`

,`C`

)`x`

and `y`

to
specify the locations of the corners corresponding to `C(1,1)`

and `C(m,n)`

.
To specify both corners, set `x`

and `y`

as
two-element vectors. To specify the first corner and let `imagesc`

determine
the other, set `x`

and `y`

as scalar
values. The image is stretched and oriented as applicable.

`imagesc('CData',`

adds
the image to the current axes without replacing existing plots. This
syntax is the low-level version of `C`

)`imagesc(C)`

.
For more information, see High-Level Versus Low-Level Version.

`imagesc(___,`

specifies image
properties using one or more name-value pair arguments. You can specify
name-value pair arguments after any of the input argument combinations in the
previous syntaxes. For a list of image properties and descriptions, see
Image Properties.`Name,Value`

)

`imagesc(___,`

specifies the data values that map to the first and last elements of the
colormap. Specify `clims`

)`clims`

as a two-element vector of the form
`[cmin cmax]`

, where values less than or equal to
`cmin`

map to the first color in the colormap and values
greater than or equal to `cmax`

map to the last color in the
colormap. Specify `clims`

after name-value pair
arguments.

`imagesc(`

creates the image in the
axes specified by `ax`

,___)`ax`

instead of in the current axes
(`gca`

). Specify the axes as the first input
argument.

To read image data into MATLAB from graphics files in various standard formats, such as TIFF, use

`imread`

. To write MATLAB image data to graphics files, use`imwrite`

. The`imread`

and`imwrite`

functions support various graphics file formats and compression schemes.To view or set the color limits of the axes, you can use the

`caxis`

function.

Was this topic helpful?