Main Content

Image Viewer

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.

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 imtool function.


Display Different Types of Images

Display a color image from a file.


Display an indexed image.

[X,map] = imread('trees.tif');

Display a grayscale image.

I = imread('cameraman.tif');

Display a grayscale image, adjusting the display range.

h = imtool(I,[0 80]);

Related Examples

Programmatic Use

expand all

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(I) opens Image Viewer and displays the grayscale, RGB, or binary image I. Specify 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.

imtool(X,cmap) open Image Viewer and displays the indexed image X with colormap cmap.

  • Specify X as an m-by-n matrix of data type single, double, uint8, or logical.

  • Specify cmap as a c-by-3 numeric matrix containing the RGB values of c colors. cmap can be of data type single, double, uint8, or uint16, or int16.

imtool(filename) opens Image Viewer and displays the image file with file name filename. Specify 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. Specify 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 parula or jet.

For example, imtool(I,'Colormap',parula) displays grayscale image I using the parula colormap.

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 these values.

  • 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.

    For example, imtool(I,'DisplayRange',[15 140]) scales the display range of grayscale image I of data type uint8 such that pixels less than or equal to 15 appear black and pixels greater than or equal to 140 appear white.

  • []Image Viewer sets the display range to [min(I(:)) max(I(:))]. The minimum value in I is displayed as black, and the maximum value is displayed as white.

    For example, imtool(I,'DisplayRange',[]) scales the display range of grayscale image I of data type double such that pixels with the minimum value appear black and pixels with the maximum value appear white.

imtool(___,'InitialMagnification',initMag) displays the image with initial magnification initMag. Specify 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).

    For example, imtool(I,'InitialMagnification',50) displays image I at 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 interpolation technique interp used to resize the image. Specify interp as "nearest" for nearest neighbor interpolation or "bilinear" for bilinear interpolation. The default interpolation technique is "nearest".

For example, imtool(I,'Interpolation',"bilinear") resizes image I using bilinear interpolation.

hfigure = imtool(___) returns hfigure, the figure object created by Image Viewer.

imtool close all closes all open instances of Image Viewer.

More About

expand all


  • 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 imtool with a file name, as in the syntax imtool(filename,'DisplayRange',[low high]).

  • Image Viewer does not close when you call the close all command. If you want to close multiple instances of the Image Viewer app, use the syntax imtool close all or select Close all from the Image Viewer File menu. You can close a specific Image Viewer specified by the handle hfigure by using the command close(hfigure).

See Also



Introduced in R2014b