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 create an axes on top of the axes created by
imshow
by using thehold on
command after callingimshow
.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.