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
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:
'nearest'
— This method is best when there are a small number of pixel values that represent distinct categories, or when you want to see individual pixels in a highly zoomed-in view. The value of a pixel located at (x, y) is the value of the pixel that is closest to (x,y) in the original image.'bilinear'
— This method is best in almost all other situations. The value of a pixel located at (x, y) is a weighted average of the surrounding pixels in the original image. To minimize display artifacts, additional smoothing is applied when you shrink the image.
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)
Position
Placement along the _x_-axis, specified in one of these forms:
- Two-element vector — Use the first element as the location for the center of
CData(1,1)
and the second element as the location for the center ofCData(m,n)
, where[m,n] = size(CData)
. Evenly distribute the centers of the remainingCData
elements between those two points.
The width of each pixel is determined by the expression:
(XData(2)-XData(1))/(size(CData,2)-1)
IfXData(1)
>XData(2)
, then the image is flipped left-right. - Scalar — Center
CData(1,1)
at this location and each following element one unit apart.
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:
- Two-element vector — Use the first element as the location for the center of
CData(1,1)
and the second element as the location for the center ofCData(m,n)
, where[m,n] = size(CData)
. Evenly distribute the centers of the remainingCData
elements between those two points.
The height of each pixel is determined by the expression:
(YData(2)-YData(1))/(size(CData,1)-1)
IfYData(1)
>YData(2)
, then the image is flipped up-down. - Scalar — Center
CData(1,1)
at this location and each following element one unit apart.
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
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
This property is read-only.
Parent/Child
Parent, specified as an Axes
, Group
, or Transform
object.
Identifiers
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
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.