Products & Services Industries Academia Support User Community Company

Learn more about Image Processing Toolbox   

Using the Image Tool to Explore Images

Image Tool Overview

The Image Tool is an image display and exploration tool that presents an integrated environment for displaying images and performing common image-processing tasks. The Image Tool provides access to several other tools:

In addition, the Image Tool provides several navigation aids that can help explore large images:

The following figure shows the image displayed in the Image Tool with many of the related tools open and active.

Image Tool and Related Tools

Opening the Image Tool

To start the Image Tool, use the imtool function. You can also start another Image Tool from within an existing Image Tool by using the New option from the File menu.

The imtool function supports many syntax options. For example, when called without any arguments, it opens an empty Image Tool.

imtool

To bring image data into this empty Image Tool, you can use either the Open or Import from Workspace options from the File menu — see Importing Image Data from the Workspace.

You can also specify the name of the MATLAB workspace variable that contains image data when you call imtool, as follows:

moon = imread('moon.tif');
imtool(moon)

Alternatively, you can specify the name of the graphics file containing the image. This syntax can be useful for scanning through graphics files.

imtool('moon.tif');

Specifying the Initial Image Magnification

The imtool function attempts to display an image in its entirety at 100% magnification (one screen pixel for each image pixel) and always honors any magnification value you specify. If the image is too big to fit in a figure on the screen, the Image Tool shows only a portion of the image, adding scroll bars to allow navigation to parts of the image that are not currently visible. If the specified magnification would make the image too large to fit on the screen, imtool scales the image to fit, without issuing a warning. This is the default behavior, specified by the imtool 'InitialMagnification' parameter value 'adaptive'.

To override this default initial magnification behavior for a particular call to imtool, specify the InitialMagnification parameter. For example, to view an image at 150% magnification, use this code.

pout = imread('pout.tif');
imtool(pout, 'InitialMagnification', 150)

You can also specify the text string 'fit' as the initial magnification value. In this case, imtool scales the image to fit the default size of a figure window.

Another way to change the default initial magnification behavior of imtool is to set the ImtoolInitialMagnification toolbox preference. The magnification value you specify will remain in effect until you change it. To set the preference, use iptsetpref or open the Image Processing Preferences panel by calling iptprefs or by selecting File > Preferencesin the Image Tool menu. To learn more about toolbox preferences, see iptprefs.

When imtool scales an image, it uses interpolation to determine the values for screen pixels that do not directly correspond to elements in the image matrix. For more information, see Specifying the Interpolation Method.

Specifying the Colormap

A colormap is a matrix that can have any number of rows, but must have three columns. Each row in the colormap is interpreted as a color, with the first element specifying the intensity of red, the second green, and the third blue.

To specify the color map used to display an indexed image or a grayscale image in the Image Tool, select the Choose Colormap option on the Tools menu. This activates the Choose Colormap tool. Using this tool you can select one of the MATLAB colormaps or select a colormap variable from the MATLAB workspace.

When you select a colormap, the Image Tool executes the colormap function you specify and updates the image displayed. You can edit the colormap command in the Evaluate Colormap text box; for example, you can change the number of entries in the colormap (default is 256). You can enter your own colormap function in this field. Press Enter to execute the command.

When you choose a colormap, the image updates to use the new map. If you click OK, the Image Tool applies the colormap and closes the Choose Colormap tool. If you click Cancel, the image reverts to the previous colormap.

Image Tool Choose Colormap Tool

Importing Image Data from the Workspace

To import image data from the MATLAB workspace into the Image Tool, use the Import from Workspace option on the Image Tool File menu. In the dialog box, shown below, you select the workspace variable that you want to import into the workspace.

The following figure shows the Import from Workspace dialog box. You can use the Filter menu to limit the images included in the list to certain image types, i.e., binary, indexed, intensity (grayscale), or truecolor.

Image Tool Import from Workspace Dialog Box

Exporting Image Data to the Workspace

To export the image displayed in the Image Tool to the MATLAB workspace, you can use the Export to Workspace option on the Image Tool File menu. (Note that when exporting data, changes to the display range will not be preserved.) In the dialog box, shown below, you specify the name you want to assign to the variable in the workspace. By default, the Image Tool prefills the variable name field with BW, for binary images, RGB, for truecolor images, and I for grayscale or indexed images.

If the Image Tool contains an indexed image, this dialog box also contains a field where you can specify the name of the associated colormap.

Image Tool Export Image to Workspace Dialog Box

Using the getimage Function to Export Image Data

You can also use the getimage function to bring image data from the Image Tool into the MATLAB workspace.

The getimage function retrieves the image data (CData) from the current Handle Graphics image object. Because, by default, the Image Tool does not make handles to objects visible, you must use the toolbox function imgca to get a handle to the image axes displayed in the Image Tool. The following example assigns the image data from moon.tif to the variable moon if the figure window in which it is displayed is currently active.

moon = getimage(imgca);

Saving the Image Data Displayed in the Image Tool

To save the image data displayed in the Image Tool, select the Save as option from the Image Tool File menu. The Image Tool opens the Save Image dialog box, shown in the following figure. Use this dialog box to navigate your file system to determine where to save the image file and specify the name of the file. Choose the graphics file format you want to use from among many common image file formats listed in the Files of Type menu. If you do not specify a file name extension, the Image Tool adds an extension to the file associated with the file format selected, such as .jpg for the JPEG format.

Image Tool Save Image Dialog Box

Closing the Image Tool

To close the Image Tool window, use the Close button in the window title bar or select the Close option from the Image Tool File menu. You can also use the imtool function to return a handle to the Image Tool and use the handle to close the Image Tool. When you close the Image Tool, any related tools that are currently open also close.

Because the Image Tool does not make the handles to its figure objects visible, the Image Tool does not close when you call the MATLAB close all command. If you want to close multiple Image Tools, use the syntax

imtool close all

or select Close all from the Image Tool File menu.

Printing the Image in the Image Tool

To print the image displayed in the Image Tool, select the Print to Figure option from the File menu. The Image Tool opens another figure window and displays the image. Use the Print option on the File menu of this figure window to print the image. See Printing Images for more information.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS