Main Content

Image Properties

Image appearance in 2-D Viewer

Since R2024b

Image properties control the appearance and behavior of an Image object. By changing property values, you can modify certain aspects of the image. Create an Image object using the imageshow function.

Use dot notation to query and set properties. For example, these commands show how to create an Image object that displays the 2-D image data I, query the value of the Colormap property, and set the value of the Colormap property, respectively.

im = imageshow(I);
cmap = im.Colormap;
im.Colormap = parula;

Parent/Child

expand all

Parent of the Image object, specified as a Viewer object. You can create a Viewer object optimized for 2-D image display by using the viewer2d function. When you call imageshow without specifying a parent, the function creates a new Viewer object and sets that object as the parent. After object creation, this property is read-only.

Data Display

expand all

Image data, specified as one of the options in this table. You can specify the Data property directly, or as an input argument to the imageshow function.

Image TypeDescription
GrayscaleSpecify as an m-by-n numeric matrix.
BinarySpecify as an m-by-n matrix of data type logical.
RGBSpecify as an m-by-n-by-3 numeric array.
Blocked imageSpecify as a blockedImage object that reads 2-D blocks of grayscale, RGB, or binary image data.

Image interpolation method, specified as one of the values in this table.

ValueDescription
"auto"The interpolation method depends on the current zoom level. If one data pixel spans fewer than 10 screen pixels, the image displays using bilinear interpolation. If one data pixel spans more than 10 screen pixels, the image displays using nearest neighbor interpolation.
"bilinear"The image displays using bilinear interpolation. The value of a pixel located at (x, y) is the weighted average of the surrounding pixels in the original image.
"nearest"

The image displays using nearest neighbor interpolation. The value of a pixel located at (x, y) is the value of the pixel closest to (x, y) in the original image.

This option provides the fastest performance, and is recommended for workflows, such as the playback of multiframe image series, where fast rendering speed is more important than image quality.

Colormap for the image data, specified as an n-by-3 numeric matrix with values in the range [0, 1]. The maximum number of colors n is 256. This property has no effect when viewing RGB images. You can specify a different colormap for each Image object in a scene.

Values less than or equal to the minimum value of DisplayRange map to the first color in Colormap, and all values greater than or equal to the maximum value of DisplayRange map to the last color in Colormap. Intermediate values map linearly to the intermediate colors in the colormap.

Display range of the image content, specified as one of these options:

  • 2-element row vector of the form [min max] — Scale data according to the values min and max. For RGB images, specifying a 2-element row vector applies the same data limits to all color channels.

  • 3-by-2 numeric matrix with rows of the form [min max]— Scale each RGB channel according to the values min and max. The first, second, and third rows specify the data limits for the red, green, and blue color channels, respectively.

When the DisplayRangeMode value is "type-range" (the default) or "data-range", this property updates automatically to reflect the range of the data type or data of the current image, respectively. If you specify this property, the DisplayRangeMode property changes to "manual".

Display range mode, specified as one of the options in this table.

ValueDescription
"type-range"Set the display range equal to the data type range. For example, for uint8 images, the display range is [0 255].
"data-range"Set the display range equal to the data range of the image. For RGB images, the data range is the overall minimum and maximum across channels.
"10-bit"Set the display range to [0 1023]. This value is useful for displaying medical images with 10-bit data ranges.
"12-bit"Set the display range to [0 4095]. This value is useful for displaying medical images with 12-bit data ranges.
"manual"Manually set a fixed display range using DisplayRange. Specifying DisplayRange automatically sets DisplayRangeMode to "manual".

Transparency channel for the image data, specified as one of the options in this table.

ValueDescription
Numeric scalarDisplay the image with a constant transparency value in the range [0, 1].
m-by-n numeric matrix

Specify the transparency value for each pixel directly. m and n are the lengths of the first and second dimensions of the input image, respectively.

The function expects values of data type single and double to be in the range [0, 1]. If AlphaData is an integer datatype, values are scaled to the range [0, 1] before displaying the image.

2-D blockedImage object

Specify the transparency for each pixel of the blocked image directly. Use this option when Datacontains a blockedImage object. The blocked images for Data and AlphaData must have the same Size, BlockSize, SizeInBlocks, NumLevels, WorldStart, and WorldEnd values.

The function expects underlying pixel values of data type single and double to be in the range [0, 1]. If AlphaData is an integer datatype, values are scaled to the range [0, 1] before displaying the image.

Geometric transformation applied to the image, specified as one of the 2-D or 3-D geometric transformation objects listed in the table. Use the Transformation property to apply intrinsic-to-world mapping, adjust the size of the image, rotate the image, or perform other affine transformations. The default value is an affinetform3d object that performs an identity transformation.

ValueDescription
imref2d object2-D spatial referencing object
affinetform2d object2-D affine transformation, including translation, rotation, anisotropic scaling, reflection, and shearing
rigidtform2d object2-D rigid transformation, including translation and rotation
simtform2d object2-D similarity transformation, including translation, rotation, and isotropic scaling
transltform2d object2-D translation transformation
affinetform3d object3-D affine transformation, including translation, rotation, anisotropic scaling, reflection, and shearing
rigidtform3d object3-D rigid transformation, including translation and rotation
simtform3d object2-D similarity transformation, including translation, rotation, and isotropic scaling
transltform3d object3-D translation transformation

Overlay

expand all

Overlay data to blend with the image data, specified as a numeric array, categorical array, or a blockedImage object. If Data is a blockedImage, specify OverlayData as a blockedImage with the same Size, BlockSize, SizeInBlocks, NumLevels, WorldStart, and WorldEnd values.

You can modify the appearance of the overlay by changing the OverlayDisplayRange, OverlayColormap, OverlayAlpha, and OverlayAlphamap properties.

Overlay colormap, specified as an n-by-3 numeric matrix with values in the range [0, 1]. The maximum number of colors n is 256. This property affects the visualization only when the OverlayData property is nonempty. The default colormap maximizes color differences between adjacent colors in the colormap, which helps visually distinguish between different values in a label image.

The OverlayDisplayRange property determines which values of OverlayData map to the colormap. Values less than or equal to the minimum value of OverlayDisplayRange map to the first color in OverlayColormap, and all values greater than or equal to the maximum value of OverlayDisplayRange map to the last color in OverlayColormap.

Uniform transparency value for the overlay image, specified as a numeric scalar in the range [0, 1] or an empty array. Specify a numeric scalar to apply a uniform transparency to all nonzero pixels in OverlayData. Zero-valued pixels display fully transparent.

To specify a nonuniform transparency, or to apply a uniform transparency to all pixels including zero-valued pixels, specify the OverlayAlphamap property. If you specify OverlayAlphamap, then OverlayAlpha automatically changes to an empty matrix, [].

Nonuniform transparency map for the overlay image, specified as one of the values in the table. Specify this property to apply a non-uniform transparency to pixels in OverlayData. By default, OverlayAlphamap is a 256-element column vector that reflects the current OverlayAlpha value.

The OverlayDisplayRange property determines which values of OverlayData map to the transparency range. Values less than or equal to the minimum value of OverlayDisplayRange map to the first value of the transparency map, and all values greater than or equal to the maximum value of OverlayDisplayRange map to the last value of the transparency map.

ValueDescription
n-element column vector with values in the range [0, 1]Values in OverlayData map linearly to the transparency values in OverlayAlphamap.
"linear"Values in OverlayData map linearly to transparencies in the range [0, 1].
"quadratic"Values in OverlayData map quadratically to transparencies in the range [0, 1].
"cubic"Values in OverlayData map cubically to transparencies in the range [0, 1].

Overlay display range, specified as a 2-element numeric vector of the form [low high] that specifies the minimum and maximum of the display range. If you specify this property directly, the OverlayDisplayRangeMode automatically changes to "manual". When the OverlayDisplayRangeMode property is "data-range" or "type-range", this property automatically updates to reflect the range of the overlay data or the data type, respectively.

Overlay display range mode, specified as one of the options in this table.

ValueDescription
"8-bit"Set the overlay display range to [0 255].
"type-range"Set the overlay display range equal to the data type range for OverlayData. For example, if OverlayData is of data type double, the display range is [0 1].
"data-range"Set the display range equal to the data range of OverlayData.
"manual"Manually set a fixed display range using the OverlayDisplayRange property. Specifying the OverlayDisplayRange property automatically sets OverlayDisplayRangeMode to "manual".

Version History

Introduced in R2024b