imtool

Open Image Viewer app

Description

The imtool function opens the Image Viewer app. The 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.

imtool opens the Image Viewer app in an empty state. Use the File menu options Open or Import from Workspace to choose an image for display.

imtool(I) displays the grayscale image I in the Image Viewer app, using the default display range of the image data type.

imtool(I,range) displays the grayscale image I in the Image Viewer app, specifying the display range as range. The app clips pixel values outside the display range to black or white and displays pixel values within the display range as intermediate shades of gray. The app uses the default number of gray levels.

imtool(RGB) displays the truecolor image RGB in the Image Viewer app.

imtool(BW) displays the binary image BW in the Image Viewer app. Pixel values of 0 display as black; pixel values of 1 display as white.

imtool(X,cmap) displays the indexed image X with colormap cmap in the Image Viewer app.

example

imtool(filename) displays the image contained in the graphics file filename in the Image Viewer.

imtool(___,Name,Value) displays the image, specifying parameters and corresponding values that control various aspects of the image display.

hfigure = imtool(___) returns hfigure, a handle to the figure created by the Image Viewer app.

imtool close all closes all open instances of Image Viewer.

Examples

Display Different Types of Images

Display a color image from a file.

imtool('board.tif')

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)

Input Arguments

collapse all

2-D grayscale image, specified as an m-by-n numeric matrix.

Data Types: single | double | int16 | uint8 | uint16

Display range of the grayscale image I, specified as one of these values.

Value

Description

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

[]

Image Viewer automatically 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.

2-D RGB image, specified as an m-by-n-by-3 numeric matrix.

Data Types: single | double | uint8 | uint16

2-D binary image, specified as an m-by-n logical matrix.

Data Types: logical

2-D indexed image, specified as an m-by-n numeric matrix.

Data Types: single | double | uint8 | logical

Color map associated with indexed image X, specified as a c-by-3 numeric matrix containing the RGB values of c colors.

Data Types: single | double | int16 | uint8 | uint16

File name of the graphics file containing the image, specified as a character vector. The file must contain an image that can be read by imread or dicomread or a reduced resolution dataset (R-Set) created by rsetwrite. If the file contains multiple images, the first one is displayed. The file must be in the current directory or on the MATLAB® path.

Data Types: char | string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: imtool(I,'Colormap',jet) displays the grayscale image I using the jet colormap.

Color map, specified as the comma-separated pair consisting of 'Colormap' and a v-by-3 numeric matrix with values in the range [0, 1]. You can also create a colormap matrix using a predefined colormap function, such as parula or jet.

Example: 'Colormap',repmat([1:256]',1,3);

Example: 'Colormap',jet

Example: 'Colormap',parula(128)

Data Types: double

Display range, specified as the comma-separated pair consisting of 'DisplayRange' and a 2-element vector of the form [low high].

Note

Including the parameter name is optional, except when the image is specified by a file name. The syntax imtool(I,[low high]) is equivalent to imtool(I,'DisplayRange',[low high]). However, the 'DisplayRange' parameter must be specified when calling imtool with a file name, as in the syntax imtool(filename,'DisplayRange',[low high]).

Initial magnification, specified as the comma-separated pair consisting of 'InitialMagnification' and one of these values.

Parameter

Value

'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 scales the entire image to fit in the window.

numeric scalar

Image Viewer scales 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).

Note

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

By default, the initial magnification parameter is set to the value returned by iptgetpref('ImtoolInitialMagnification'). To change the default initial magnification behavior, set the ImtoolInitialMagnification toolbox preference by using the iptsetpref function or by opening the Image Processing Toolbox™ Preferences panel. For more information about the Preferences panel, see iptprefs.

Interpolation technique used when scaling an image, specified as the comma-separated pair consisting of 'Interpolation' and one of the following values.

ValueDescription
'nearest'Nearest neighbor interpolation (default)
'bilinear'Bilinear interpolation

Output Arguments

collapse all

Handle to Image Viewer figure, returned as a handle.

More About

collapse all

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

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.

Related Toolbox Preferences

You can use the Image Processing Preferences dialog box to set toolbox preferences that modify the behavior of Image Viewer. To access the dialog, select File > Preferences in the MATLAB desktop or Image Viewer menu. You can also set preferences programmatically with iptsetpref:

Preference

Description

'ImtoolInitialMagnification'

Controls the initial magnification for image display. To override this toolbox preference, specify the 'InitialMagnification' parameter when you call imtool, as follows:

imtool(...,'InitialMagnification',initial_mag)

'ImtoolStartWithOverview'

Controls whether the Overview tool opens automatically when you open an image using Image Viewer. Possible values:

  • true — Overview tool opens when you open an image.

  • false — Overview tool does not open when you open an image. This is the default behavior.

For more information about these preferences, see iptprefs.

Tips

  • For grayscale images having integer types, the default display range is [intmin(class(I)) intmax(class(I))].

    For grayscale images of class single or double, the default display range is [0 1]. If the data range of a single or double image is much larger or smaller than the default display range, you might need to experiment with setting the display range to see features in the image that would not be visible using the default display range.

  • You can access Image Viewer through the Apps tab. Navigate to the Image Processing and Computer Vision group and select Image Viewer.

  • You can close a specific Image Viewer specified by the handle hfigure by using the command close(hfigure).

Introduced before R2006a