Main Content

Get Started with Image Viewer App

The Image Viewer app presents an integrated environment for displaying images and performing common image processing tasks. The workflow for using Image Viewer typically involves a combination of these steps:

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

Grayscale image displayed in Image Viewer with the Distance tool open in the app figure window. An Overview tool, Adjust Contrast tool, Pixel Region tool, and Image Information tool are open in separate figure windows.

Note

You can also access individual tools outside the Image Viewer app. To do so, display an image in a figure window using a function such as imshow, then create one or more tools using toolbox functions. For example, you can build an image processing app with custom layout and behavior using a combination of individual tools. For more information, see Interactive Tool Workflow

Open Image Viewer App

There are three ways to open the Image Viewer app. In each case, you can select an image from a variable in the workspace or specify the name of the image file. Image Viewer can open any file that can be read by imread.

  • You can open the Image Viewer app from the command line by using the imtool function. Use this function when you want to control various aspects of the initial image display, such as the initial magnification, colormap, or display range. For example, this code opens Image Viewer and loads the image with file name cameraman.tif.

    imtool("cameraman.tif")
  • You can open the Image Viewer app from the Apps tab, under Image Processing and Computer Vision. To bring image data into Image Viewer from a file name, select Open from the File menu. To bring image data into Image Viewer from the workspace, select Import from Workspace from the File menu. Optionally filter the variables in the workspace to show only images of a desired type, such as binary, indexed, intensity (grayscale), or truecolor (RGB) images.

    Import from Workspace menu showing the names, sizes, and data types of all workspace variables that represent viable image data.

  • You can start a new Image Viewer from within an existing Image Viewer by using the New option from the File menu.

Note

When you specify a file name, Image Viewer does not save the image data in a workspace variable. However, you can export the image from Image Viewer to the workspace. For more information, see Save and Export Results.

Navigate Image in Image Viewer App

After you open Image Viewer, the image appears in the app window. Image Viewer provides navigation aids and tools that can help you explore images in detail.

ActionTools and Navigation AidsDepiction of Tool
See image overview

To see what portion of the image is currently visible when the image is magnified, use the Overview tool. The Overview tool displays the entire image, scaled to fit. Superimposed over this view of the image is a detail rectangle that indicates which portion of the image is currently visible in Image Viewer.

You can pan and zoom the image visible in the Image Viewer window by moving and resizing the detail rectangle in the Overview tool.

To achieve better contrast of the detail rectangle against the underlying image, you can change the color of rectangle. Right-click anywhere inside the rectangle and select a color from the Set Color option on the context menu.

To get the current position and size of the detail rectangle, right-click anywhere inside the rectangle and select Copy Position from the context menu. The tool copies the position as a four-element vector of the form [xmin ymin width height] to the clipboard. You can paste this position vector into the workspace or another application.

To print the view of the image displayed in the Overview tool, select the Print to Figure option from the Overview tool File menu. See Print Images for more information.

Overview tool with blue detail rectangle over a portion of the image.
Magnify image

To enlarge or shrink an image by specifying a scale factor, use the Magnification option on the Tools menu.

To enlarge or shrink an image by clicking the image, use the Zoom tool. The tool centers the new view of the image on the spot where you clicked.

Note

You can also zoom by using the Ctrl+Plus or Ctrl+Minus keys. These are the Plus(+) and Minus(-) keys on the numeric keypad of your keyboard.

When Image Viewer 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 about interpolation methods used for resizing images, see imresize.

 
Pan image

To pan an image that is too large to fit in the Image Viewer window, use scroll bars or the Pan tool.

 
Choose image colormap

To enhance the visibility of features in grayscale and indexed images, you can change the image colormap using the Choose Colormap tool. You can select a MATLAB® colormap or a colormap variable from the workspace. You can also create a colormap by entering a MATLAB command.

Image Viewer does not provide a color bar. To add a color bar, open the image in another figure window. For more information, see Save and Export Results.

Choose Colormap tool with a list of MATLAB colormap functions.

Get Information about Image Data

Image Viewer provides tools that can help you get information about pixel values and other aspects of the image data.

ToolDescriptionDepiction of Tool
Pixel Information tool

Get the (x, y) coordinates and the value of a single pixel under the pointer. For more information, see Determine Individual Pixel Values in Image Viewer.

Pixel Information tool in the bottom left corner of the figure window, displaying the (x, y) coordinates and the value of the pixel under the pointer.
Display Range tool

Determine the display range of grayscale image data. The tool is not enabled for RGB, indexed, or binary images. For more information, see Determine Image Display Range in Image Viewer.

Display Range tool displaying a two-element numeric vector whose values vary with data type.
Pixel Region tool

Get information about a group of pixels. For more information, see Determine Pixel Values in an Image Region.

Pixel Region tool displays the numeric pixel value over each pixel in a magnified region.
Distance tool

Measure the Euclidean distance between two pixels. For more information, see Measure Distance Between Pixels in Image Viewer App

Distance tool displaying a blue line of length 128.97 pixels over an image.
Image Information tool

Get information about image and image file metadata.

The Image Information tool always provides basic information about the width, height, data type, and image type. For grayscale and indexed images, this information includes the minimum and maximum intensity values.

If you select an image to open in Image Viewer by specifying a file name, then the Image Information tool also displays image metadata. This metadata is the same information returned by the imfinfo function or the dicominfo function.

Image Information tool displaying image details and metadata.

Modify Image Data

Image Viewer provides tools that can help you adjust the image contrast and crop an image.

By default, when you close Image Viewer, the app does not save the modified image data. However, you can export the modified image to a file or save the modified data in a workspace variable. For more information, see Save and Export Results.

ToolDescriptionDepiction of Tool
Adjust Contrast toolAdjust the contrast of an image by setting a window over a histogram of pixel values. For more information, see Adjust Image Contrast in Image Viewer App.Adjust Contrast tool with sliders and editable fields that enable you to adjust the histogram of pixel values.
Window/Level toolAdjust the contrast of an image by interacting with the image. For more information, see Adjust Image Contrast in Image Viewer App. 
Crop Image toolCrop an image to a rectangular region of interest. For more information, see Crop Image Using Image Viewer App.Crop Image tool displaying the blue border of a region to be cropped, with controls that enable resizing and moving the crop window.

Save and Export Results

Image Viewer enables you to export image data to the workspace, save the image data to file, and open images in a new figure window. When saving and exporting image data, changes to the display range are not preserved. If you would like to preserve your changes, then use the imcontrast function.

DestinationProcedure
Create workspace variable

There are three ways to create a workspace variable from the image data in Image Viewer.

  • You can use the Export to Workspace option on the Image Viewer File menu.

  • If you start the app by using the imtool function and specify a handle to the tool, then you can use the getimage function and specify the handle to the tool. For example, this code opens the image with file name moon.tif in an Image Viewer then exports the image to the variable moon.

    t = imtool("moon.tif");
    moon = getimage(t);
  • If you start the app without specifying a handle to the tool, then you can use the getimage function and specify a handle to the image object within the figure. For example, this code opens the image with file name moon.tif in an Image Viewer then exports the image to the variable moon.

    imtool("moon.tif")
    moon = getimage(imgca);

Save to file

Use the Save Image tool by selecting the Save as option on the Image Viewer File menu. This tool enables you to navigate your file system to determine where to save the file, specify the file name, and choose the file format.

Save Image tool showing the contents of the current directory with controls to change the directory and specify the filename and filetype.

Open new figure window

Select the Print to Figure option from the File menu. You can use this figure window to see a color bar and print the image. For more information, see Add Color Bar to Displayed Grayscale Image and Print Images.

See Also

Related Topics