Main Content

images.compatibility.imtool.r2023b.imtool

(Not recommended) Open and return handle of Image Tool

Since R2023b

    images.compatibility.imtool.r2023b.imtool is not recommended in most situations. Use the Image Viewer app instead. Continue to use the images.compatibility.imtool.r2023b.imtool only when you want to return a figure that contains an Image Tool. For more information, see Version History.

    Description

    The images.compatibility.imtool.r2023b.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.

    hTool = images.compatibility.imtool.r2023b.imtool opens the Image Tool in an empty state and returns the figure hTool containing the tool. Use the File menu options Open or Import from Workspace to choose an image for display.

    hTool = images.compatibility.imtool.r2023b.imtool(I) displays the grayscale image I in the Image Tool, using the default display range of the image data type.

    hTool = images.compatibility.imtool.r2023b.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.

    hTool = images.compatibility.imtool.r2023b.imtool(RGB) displays the truecolor image RGB in the Image Tool.

    hTool = images.compatibility.imtool.r2023b.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.

    hTool = images.compatibility.imtool.r2023b.imtool(X,cmap) displays the indexed image X with colormap cmap in the Image Tool.

    hTool = images.compatibility.imtool.r2023b.imtool(filename) displays the image contained in the graphics file filename in the Image Tool.

    example

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

    Examples

    collapse all

    Display a grayscale image in the Image Tool and return the figure containing the tool.

    I = imread("cameraman.tif");
    h = images.compatibility.imtool.r2023b.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 the tool 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.

    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

    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: hTool = images.compatibility.imtool.r2023b.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 as in the syntax images.compatibility.imtool.r2023b.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 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 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

    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 Tool. R-Sets can also improve performance of Image Tool 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.

    Specify Default Display Behavior

    You can specify the default display behavior of Image Tool by using the Image Processing Preferences dialog box. To access the dialog, select File > Preferences in the MATLAB desktop or Image Tool menu. You can also set preferences programmatically by using the iptsetpref function.

    Preference

    Description

    "ImtoolInitialMagnification"

    Controls the initial magnification for image display. To override this toolbox preference, specify the "InitialMagnification" name-value argument when you call the images.compatibility.imtool.r2023b.imtool function, as follows:

    images.compatibility.imtool.r2023b.imtool( ...
        ___,"InitialMagnification",initial_mag)

    "ImtoolStartWithOverview"

    Controls whether the Overview tool opens automatically when you open an image using Image Tool. 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 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:

      images.compatibility.imtool.r2023b.imtool close all

    Version History

    Introduced in R2023b

    collapse all

    R2023b: images.compatibility.imtool.r2023b.imtool is not recommended

    In R2023b, the Image Viewer app was enhanced to provide more functionality and better ease of use than the Image Tool. In most situations, use the Image Viewer app instead of the images.compatibility.imtool.r2023b.imtool function.

    Unlike Image Tool, the Image Viewer app does not return a figure. Continue to use the images.compatibility.imtool.r2023b.imtool function only when you want to return the figure that contains the Image Tool.