imshow
Display image
Syntax
Description
imshow(
displays the grayscale
image I
)I
in a figure. imshow
uses the
default display range for the image data type and optimizes figure, axes, and
image object properties for image display.
imshow(
displays the grayscale image I
,[low high]
)I
, specifying the display
range as a two-element vector, [low high]
. For more
information, see the DisplayRange
argument.
imshow(
displays the grayscale
image I
,[])I
, scaling the display based on the range of pixel
values in I
. imshow
uses
[min(I(:)) max(I(:))]
as the display range.
imshow
displays the minimum value in
I
as black and the maximum value as white. For more
information, see the DisplayRange
argument.
imshow(
displays the binary image
BW
)BW
in a figure. For binary images,
imshow
displays pixels with the value
0
(zero) as black and 1
as
white.
imshow(___,
displays an image, using name-value arguments to control aspects of the
operation. Name=Value
)
returns the image object created by himage
= imshow(___)imshow
.
Examples
Input Arguments
Output Arguments
Tips
To change the colormap after you create the image, use the
colormap
command.You can display multiple images with different colormaps in the same figure using
imshow
with thetiledlayout
andnexttile
functions.You can use the Image Viewer app as an integrated environment for displaying images and performing common image processing tasks.
You can set Image Processing Toolbox™ preferences that modify the behavior of
imshow
by using theiptsetpref
function.The
imshow
function is not supported when you start MATLAB with the-nojvm
option.Figure titles can appear cut off in the Live Editor. To ensure the whole title is visible, set the
PositionContraint
property of the parent axes object to"outerposition"
. Update the property value after theimshow
function and before thetitle
function.If you specify the parent axes using theI = imread("peppers.png"); imshow(I) ax = gca; ax.PositionConstraint = "outerposition"; title("Peppers");
Parent
name-value argument, set thePositionConstraint
property of the specified parent axes object. For more details about axes position properties, see Control Axes Layout.In some cases,
imshow
deletes the current axes and creates new axes. If a figure contains only one axes of default size,imshow
retains the axes the first time you call it, but deletes the axes and creates a new axes if you callimshow
again. To retain a persistent axes, such as when updating the image displayed in a graphical user interface, callhold on
after the first call toimshow
. Alternatively, you can update the image without callingimshow
multiple times by updating theCData
property of theImage
object returned byimshow
, instead.