Main Content

开始使用图像查看器应用程序

TheImage Viewerapp presents an integrated environment for displaying images and performing common image processing tasks. The workflow for usingImage Viewertypically involves a combination of these steps:

The figure shows an image displayed inImage Viewerwith 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

您也可以访问以外的单个工具Image Viewer应用程序。为此,请使用诸如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, seeInteractive Tool Workflow

Open Image Viewer App

There are three ways to open theImage Viewer应用程序。In each case, you can select an image from a variable in the workspace or specify the name of the image file.Image Viewercan open any file that can be read byimread.

  • You can open theImage Viewerapp from the command line by using theImtool功能。当您要控制初始图像显示的各个方面时,请使用此功能,例如初始放大倍率,colormap或显示范围。例如,此代码打开Image Viewer和loads the image with file namecameraman.tif.

    imtool('cameraman.tif')
  • You can open theImage Viewerapp from the Apps tab, under Image Processing and Computer Vision. To bring image data intoImage Viewerfrom a file name, selectOpenfrom the文件菜单。将图像数据带入Image Viewer在工作区中,选择Import from Workspacefrom the文件菜单。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.

    从工作区菜单中导入所有工作空间变量的名称,大小和数据类型,这些变量代表可行的图像数据。

  • You can start a newImage Viewerfrom within an existingImage Viewerby using theNewoption from the文件菜单。

Note

When you specify a file name,Image Viewerdoes not save the image data in a workspace variable. However, you can export the image fromImage Viewerto the workspace. For more information, see保存和导出结果.

Navigate Image in Image Viewer App

打开后Image Viewer, the image appears in the app window.Image Viewerprovides navigation aids and tools that can help you explore images in detail.

Action Tools and Navigation Aids Depiction 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 adetail rectanglethat indicates which portion of the image is currently visible inImage Viewer.

您可以在Image Viewerwindow 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 theSet Color上下文菜单上的选项。

To get the current position and size of the detail rectangle, right-click anywhere inside the rectangle and selectCopy Positionfrom 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 thePrint to Figureoption from the Overview tool文件菜单。See打印图像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放大选项Tools菜单。

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 theCtrl+Plus或者Ctrl+Minuskeys. These are thePlus(+)Minus(-)keys on the numeric keypad of your keyboard.

WhenImage Viewerscales 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, seeimresize.

Pan image

To pan an image that is too large to fit in theImage Viewerwindow, 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 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 Viewerdoes not provide a color bar. To add a color bar, open the image in another figure window. For more information, see保存和导出结果.

Colormap tool listing default MATLAB colormpa functions.

Get Information about Image Data

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

Tool Description Depiction of Tool
Pixel Information tool

Get the (x,y) coordinates and the value of a single pixel under the pointer. For more information, see确定图像查看器中的单个像素值.

图像窗口左下角的像素信息工具。
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, seeDetermine Image Display Range in Image Viewer.

Display Range tool in the bottom right corner of the figure window.
Pixel Region tool

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

Pixel Region tool displaying the values of all pixels of a 5-by-8 pixel region.
Distance tool

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

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

获取有关图像和图像文件元数据的信息。

图像信息工具始终提供有关宽度,高度,数据类型和图像类型的基本信息。对于灰度和索引图像,此信息包括最小和最大强度值。

If you select an image to open inImage Viewerby specifying a file name, then the Image Information tool also displays image metadata. This metadata is the same information returned by theimfinfofunction or thedicominfo功能。

Image Information tool displaying image details and metadata.

Modify Image Data

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

默认情况下,当您关闭时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保存和导出结果.

Tool Description Depiction of Tool
Adjust Contrast tool Adjust the contrast of an image by setting a window over a histogram of pixel values. For more information, seeAdjust Image Contrast in Image Viewer App. Adjust Contrast tool displaying a histogram of pixel values and window and level controls.
窗口/等级工具 Adjust the contrast of an image by interacting with the image. For more information, seeAdjust Image Contrast in Image Viewer App.
Crop Image tool Crop an image to a rectangular region of interest. For more information, seeCrop 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.

保存和导出结果

Image Viewerenables 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 theimcontrast功能。

目的地 Procedure
Create workspace variable

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

  • You can use theExport to Workspace选项Image Viewer文件菜单。

  • If you start the app by using theImtoolfunction and specify a handle to the tool, then you can use thegetimagefunction and specify the handle to the tool. For example, this code opens the image with file namemoon.tifin anImage Viewerthen exports the image to the variablemoon.

    t = imtool('moon.tif');月亮= getimage(t);
  • 如果你开始没有指定应用程序ing a handle to the tool, then you can use thegetimage功能并指定图中图像对象的句柄。例如,此代码用文件名打开图像moon.tifin anImage Viewerthen exports the image to the variablemoon.

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

Save to file

Use the Save Image tool by selecting theSave as选项Image Viewer文件菜单。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.

保存图像工具显示卡伦牌的内容t directory with controls to change the directory and specify the file name and file type.

Open new figure window

Select thePrint to Figureoption from the文件菜单。您可以使用此图形窗口查看颜色栏并打印图像。有关更多信息,请参阅Add Color Bar to Displayed Grayscale Image打印图像.

See Also

相关话题