Image - Image appearance and behavior - MATLAB (original) (raw)

Image Properties

Image appearance and behavior

Image properties control the appearance and behavior of Image objects. By changing property values, you can modify certain aspects of the image. Use dot notation to query and set properties.

im = image(rand(20)); C = im.CData; im.CDataMapping = 'scaled';

Image Data and Quality

expand all

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Interpolation method, specified as 'nearest' or'bilinear'. MATLAB uses interpolation to display a scaled or rotated version of the image on your screen. The value you choose does not affect the image array. However, MATLAB saves the interpolated visual representation of the image if you save the figure or export the contents of the axes.

Choose an interpolation method based on your image content and the effect you want to achieve:

Since R2022b

Maximum rendered resolution, specified as "none" or a positive integer value. Use this property to control the maximum resolution MATLAB uses to display the larger dimension of the image. The smaller dimension adjusts to preserve the aspect ratio. The value you specify affects the on-screen display, but it does not affect the image data, which is stored in the CData property of the image.

Specify "none" to display the image at full resolution. Specify a number to limit the size of the displayed image. Larger numbers (and "none") provide higher quality images, but the initial images might take longer to render. Smaller numbers provide downsampled images, but they render faster.

In general, images render faster when you specify a value that is smaller than the largest image dimension of the original image. However, if you specify a value that is only one or a few pixels smaller, the initial rendering of that image might take longer than rendering it at full resolution.

Example: Display Downsampled Image

Read peppers.png, which is a 384-by-512 RGB image. Then call the imagesc function to display the image using 128 pixels along the larger dimension. The smaller dimension scales down to 96 pixels to maintain the original aspect ratio.

imdata = imread("peppers.png"); imagesc(imdata,"MaxRenderedResolution",128)

peppers.png displayed at a resolution of 96-by-128 pixels

Position

expand all

Placement along the _x_-axis, specified in one of these forms:

Note

If XData contains a vector with more than two elements, MATLAB uses the first and last elements and ignores the other elements.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | datetime (since R2023b) | duration (since R2023b) | categorical (since R2023b)

Placement along the _y_-axis, specified in one of these forms:

Note

If YData contains a vector with more than two elements, MATLAB uses the first and last elements and ignores the other elements.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | datetime (since R2023b) | duration (since R2023b) | categorical (since R2023b)

Interactivity

expand all

Data tip content, specified as a DataTipTemplate object. You can control the content that appears in a data tip by modifying the properties of the underlying DataTipTemplate object. For a list of properties, see DataTipTemplate Properties.

For an example of modifying data tips, see Create Custom Data Tips.

This property applies only to images with pinned data tips.

Note

The DataTipTemplate object is not returned byfindobj or findall, and it is not copied by copyobj.

Callbacks

Callback Execution Control

expand all

This property is read-only.

Parent/Child

expand all

Parent, specified as an Axes, Group, or Transform object.

Identifiers

expand all

This property is read-only.

Type of graphics object, returned as 'image'.

Object identifier, specified as a character vector or string scalar. You can specify a unique Tag value to serve as an identifier for an object. When you need access to the object elsewhere in your code, you can use the findobj function to search for the object based on the Tag value.

Version History

Introduced before R2006a

expand all

Now you can specify the XData and YData properties as datetime, duration, or categorical coordinate values. Previously, only numeric and logical coordinate values were supported.

Set the MaxRenderedResolution property when calling image or imagesc to control the maximum displayed resolution along the larger dimension of the image. The value affects the on-screen display, but it does not affect the image data, which is stored in theCData property of the image.

Setting or getting UIContextMenu property is not recommended. Instead, use the ContextMenu property, which accepts the same type of input and behaves the same way as theUIContextMenu property.

There are no plans to remove the UIContextMenu property, but it is no longer listed when you call the set, get, orproperties functions on the Image object.