View and explore images
The Image Viewer app presents an integrated environment for displaying images and performing common image processing tasks.
Image Viewer provides all the image display capabilities of
imshow, which optimizes figure, axes, and image object property settings
for image display. Image Viewer also provides access to several tools for
navigating and exploring images, such as the Pixel Region tool, Image Information tool,
and the Adjust Contrast tool. To learn more about the available tools, see Get Started with Image Viewer App.
Open the Image Viewer App
MATLAB® Toolstrip: On the Apps tab, under Image Processing and Computer Vision, click the Image Viewer app icon.
MATLAB command prompt: Use the
Display Different Types of Images
Display a color image from a file.
Display an indexed image.
[X,map] = imread("trees.tif"); imtool(X,map)
Display a grayscale image.
I = imread("cameraman.tif"); imtool(I)
Display a grayscale image, adjusting the display range.
h = imtool(I,[0 80]); close(h)
imtool opens Image Viewer in an empty state.
To load an from a file, select File > Open.
To load an image stored as a variable in the workspace, select File > Import from Workspace.
imtool( opens Image Viewer
and displays the grayscale, RGB, or binary image
I as one of these values.
An m-by-n numeric matrix representing a grayscale image. Image Viewer displays the image using the default display range of the image data type.
An m-by-n-by-3 numeric array representing an RGB image.
An m-by-n logical matrix representing a binary image.
Image Viewer and displays the indexed image
Xas an m-by-n matrix of data type
cmapas a c-by-3 numeric matrix containing the RGB values of c colors.
cmapcan be of data type
imtool( opens Image
Viewer and displays the image file with file name
filename as a
character vector or string scalar.
imtool(___,"Colormap",cmap) displays the
grayscale or binary image in Image Viewer using the colormap
cmap. Setting the colormap of an RGB image has no effect.
cmap as a c-by-3 numeric matrix with
values in the range [0, 1], where c is the number of colors in
the colormap. You can also create a colormap matrix using a predefined colormap
function, such as
imtool(I,"Colormap",parula) displays grayscale
I using the
imtool(___,"DisplayRange",dispRange) displays a
grayscale or indexed image in Image Viewer and scales the display range
to the values in
dispRange. Setting the display range of an RGB
or binary image has no effect. Specify
dispRange as one of
2-element vector of the form
[low high]— Image Viewer displays pixels with the value low (and any value less than low) as black. Image Viewer displays pixels with the value high (and any value greater than high) as white. Pixel values within the display range are displayed as intermediate shades of gray using the default number of gray levels.
imtool(I,"DisplayRange",[15 140])scales the display range of grayscale image
Iof data type
uint8such that pixels less than or equal to
15appear black and pixels greater than or equal to
Image Viewersets the display range to
[min(I(:)) max(I(:))]. The minimum value in
Iis displayed as black, and the maximum value is displayed as white.
imtool(I,"DisplayRange",)scales the display range of grayscale image
Iof data type
doublesuch that pixels with the minimum value appear black and pixels with the maximum value appear white.
displays the image with initial magnification
initMag as one of these values.
"adaptive"— The entire image is visible on initial display. If the image is too large to display on the screen, then Image Viewer displays the image at the largest magnification that fits on the screen.
"fit"— Image Viewer resizes the entire image to fit in the window.
A positive number — Image Viewer resizes the entire image as a percentage of the original image size. For example, if you specify 100, then Image Viewer displays the image at 100% magnification (one screen pixel for each image pixel).
Iat 50% of the original image dimensions.
When the image aspect ratio is such that less than one pixel would be displayed in either dimension at the requested magnification, Image Viewer issues a warning and displays the image at 100% magnification.
By default, the initial magnification is set to the value returned by
iptgetpref("ImtoolInitialMagnification"). To change the
default initial magnification behavior, see Specify Default Display Behavior.
imtool(___,"Interpolation",interp) specifies the
interp used to resize the image.
"nearest" for nearest
neighbor interpolation or
"bilinear" for bilinear interpolation.
The default interpolation technique is
imtool(I,"Interpolation","bilinear") resizes image
I using bilinear interpolation.
hfigure = imtool(___)
hfigure = imtool(___)
hfigure, the figure object created by Image
imtool close all
imtool close all closes all open instances of Image
Specify Default Display Behavior
You can specify the default display behavior of Image Viewer by using
the Image Processing Preferences dialog box. To access the dialog, select File > Preferences in the MATLAB desktop or Image Viewer menu. You can also set preferences
programmatically by using the
Controls the initial magnification for image display. To
override this toolbox preference, specify the
Controls whether the Overview tool opens automatically when you open an image using Image Viewer. Possible values:
For more information about these preferences, see
Large Data Support
To view very large TIFF or NITF images that will not fit into memory, you can use
rsetwrite to create a reduced
resolution dataset (R-Set) viewable in Image Viewer. R-Sets can also
improve performance of Image Viewer for large images that fit in
The following tools can be used with an R-Set: Overview, Zoom, Pan, Image Information, and Distance. Other tools, however, will not work with an R-Set. You cannot use the Pixel Region, Adjust Contrast, Crop Image, and Window/Level tools. Please note that the Pixel Information tool displays only the x and y coordinates of a pixel and not the associated intensity, index, or RGB values.
If you want to set the display range when calling
imtool, then the
"DisplayRange"name is optional unless you specify the image using a file name. The syntax
imtool(I,[low high])is equivalent to
imtool(I,"DisplayRange",[low high]). However, you must specify the
"DisplayRange"argument when calling
imtoolwith a file name, as in the syntax
Image Viewer does not close when you call the
close allcommand. If you want to close multiple instances of the Image Viewer app, use the syntax
imtool close allor select Close all from the Image Viewer File menu. You can close a specific Image Viewer specified by the handle
hfigureby using the command
Introduced before R2006a