Main Content

subimage

Display multiple images in single figure

subimage is not recommended. Use imshow with tiledlayout to display multiple images in the same figure window. For more information, see Compatibility Considerations.

Description

subimage(I) displays the RGB (truecolor), grayscale, or binary image I in the current axes.

You can use subimage in conjunction with subplot to create figures with multiple images, even if the images have different colormaps. subimage converts images to RGB for display purposes, thus avoiding colormap conflicts.

example

subimage(X,map) displays the indexed image X with colormap map in the current axes.

subimage(x,y,___) displays an image using a nondefault spatial coordinate system, where x and y specify the image limits in the world coordinate system.

h = subimage(___) returns a handle to an image object.

Examples

Display Two Indexed Images in Same Figure

load trees
[X2,map2] = imread('forest.tif');
subplot(1,2,1), subimage(X,map)
subplot(1,2,2), subimage(X2,map2)

Input Arguments

collapse all

Image to display, specified as an RGB (truecolor), grayscale, or binary image.

Data Types: double | uint8 | uint16 | logical

Indexed image, specified as an m-by-n matrix of integers.

  • If you specify X as an array of integer data type, then the value 0 corresponds to the first color in the colormap map. For a colormap containing c colors, values of image X are clipped to the range [0, c-1].

  • If you specify X as an array of data type double, then the value 1 corresponds to the first color in the colormap. For a colormap containing c colors, values of image X are clipped to the range [1, c].

Data Types: double | uint8 | uint16 | logical

Colormap associated with indexed image X, specified as a c-by-3 matrix with values in the range [0, 1]. Each row of map is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap.

Data Types: double

Image limits in the x direction in world coordinates, specified as a 2-element numeric vector of the form [xmin xmax]. The value of x sets the image XData.

Image limits in the y direction in world coordinates, specified as a 2-element numeric vector of the form [ymin ymax]. The value of y sets the image YData.

Output Arguments

collapse all

Handle to an image graphics object, specified as a handle.

Compatibility Considerations

expand all

Not recommended starting in R2016b

See Also

| |

Introduced before R2006a