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 Version History.

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.

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

example

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

collapse all

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.

Version History

Introduced before R2006a

collapse all

R2016b: subimage is not recommended

Before R2016b, imshow set the colormap of a figure window, and all axes within the figure would have an identical colormap. subimage was introduced in R2006a as a workaround to display multiple images with different colormaps in the same figure. However, subimage does not provide all of the syntaxes and options that imshow provides, such as the ability to specify the display range.

In R2016b, imshow was enhanced so that images displayed within a figure could have different colormaps. This enhancement renders the subimage function irrelevant. There are no plans to remove subimage at this time.

To update your code, replace instances of subimage with imshow. You do not need to change the input arguments.