Main Content

imtool

(To be removed) Open Image Tool

imtool will be removed in a future release. Use the Image Viewer app instead. For more information, see Version History.

Description

The imtool function opens the Image Tool, which enables you to display images and perform common image processing tasks.

The tool provides all the image display capabilities of imshow, which optimizes figure, axes, and image object property settings for image display. The tool 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 Tool 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 Tool, using the default display range of the image data type.

imtool(I,range) displays the grayscale image I in the Image Tool, specifying the display range as range. The tool 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 tool uses the default number of gray levels.

imtool(RGB) displays the truecolor image RGB in the Image Tool.

imtool(BW) displays the binary image BW in the Image Tool. 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 Tool.

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

example

imtool(___,Name=Value) displays the image, specifying name-value arguments that control various aspects of the image display.

hTool = imtool(___) returns the figure hTool containing the Image Tool.

Examples

collapse all

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)

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 Tool displays pixels with the value low (and any value less than low) as black. Image Tool displays pixels with the value high (and any value greater than high) as white.

[]

Image Tool 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.

Note

If you specify both the range argument and the DisplayRange name-value argument, then imtool sets the display range according to DisplayRange and ignores the value of range.

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

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

Note

If you specify both the cmap argument and the Colormap name-value argument, then imtool sets the colormap according to Colormap and ignores the value of cmap.

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

Filename 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 Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

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

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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

Colormap, specified as 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 a 2-element vector of the form [low high].

Note

To set the display range when you call imtool with a filename, you must specify the DisplayRange name-value argument using the syntax imtool(filename,DisplayRange=[low high]).

Initial magnification, specified as 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 Tool displays the image at the largest magnification that fits on the screen.
"fit"

Image Tool scales the entire image to fit in the window.

numeric scalar

Image Tool scales the entire image as a percentage of the original image size. For example, if you specify 100, then Image Tool 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 Tool 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 setting by using the iptsetpref function or by opening the Image Processing Toolbox™ Settings panel. For more information about the Settings panel, see iptprefs.

Interpolation technique used when scaling an image, specified as one of the following values.

ValueDescription
"nearest"Nearest neighbor interpolation
"bilinear"Bilinear interpolation

Output Arguments

collapse all

Image Tool figure, returned as a Figure object.

More About

collapse all

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 close a specific Image Tool specified by the figure hTool by using this command:

    close(hTool)

    You can close all open instances of Image Tool by using this command:

    imtool close all

Version History

Introduced before R2006a

collapse all