imshow - Display image

Syntax

imshow(I)
imshow(I,[low high])
imshow(RGB)
imshow(BW)
imshow(X,map)
imshow(filename)
himage = imshow(...)
imshow(..., param1, val1, param2, val2,...)

Description

imshow(I) displays the grayscale image I.

imshow(I,[low high]) displays the grayscale image I, specifying the display range for I in [low high]. The value low (and any value less than low) displays as black; the value high (and any value greater than high) displays as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. If you use an empty matrix ([]) for [low high], imshow uses [min(I(:)) max(I(:))]; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white.

imshow(RGB) displays the truecolor image RGB.

imshow(BW) displays the binary image BW. imshow displays pixels with the value 0 (zero) as black and pixels with the value 1 as white.

imshow(X,map) displays the indexed image X with the colormap map. A color map matrix may have any number of rows, but it must have exactly 3 columns. Each row is interpreted as a color, with the first element specifying the intensity of red light, the second green, and the third blue. Color intensity can be specified on the interval 0.0 to 1.0.

imshow(filename) displays the image stored in the graphics file filename. The file must contain an image that can be read by imread or dicomread. imshow calls imread or dicomread to read the image from the file, but does not store the image data in the MATLAB® workspace. If the file contains multiple images, imshow displays the first image in the file. The file must be in the current directory or on the MATLAB path.

himage = imshow(...) returns the handle to the image object created by imshow.

imshow(..., param1, val1, param2, val2,...) displays the image, specifying parameters and corresponding values that control various aspects of the image display. The following table lists all imshow parameters in alphabetical order. Parameter names can be abbreviated, and case does not matter.

Parameter

Value

'Border'

Text string that controls whether imshow includes a border around the image displayed in the figure window. Valid strings are 'tight' and 'loose'.

Note: There can still be a border if the image is very small, or if there are other objects besides the image and its axes in the figure.

By default, the border is set to the value returned by iptgetpref('ImshowBorder').

'Colormap'

2–D, real, m-by-3 matrix specifying a colormap. imshow uses this to set the figure's colormap property. Use this parameter to view grayscale images in false color. If you specify an empty colormap ([]), imshow ignores this parameter.

'DisplayRange'

Two-element vector [LOW HIGH] that controls the display range of a grayscale image. See the imshow(I,[low high]) syntax for more details about how to set this parameter.

    Note   Including the parameter name is optional, except when the image is specified by a filename. The syntax imshow(I,[LOW HIGH]) is equivalent to imshow(I,'DisplayRange',[LOW HIGH]). However, the 'DisplayRange' parameter must be specified when calling imshow with a filename, for example imshow(filename,'DisplayRange'[LOW HIGH]).

'InitialMagnification'

A numeric scalar value, or the text string 'fit', that specifies the initial magnification used to display the image. When set to 100, imshow displays the image at 100% magnification (one screen pixel for each image pixel). When set to 'fit', imshow scales the entire image to fit in the window.

On initial display, imshow always displays the entire image. If the magnification value is large enough that the image would be too big to display on the screen, imshow warns and displays the image at the largest magnification that fits on the screen.

By default, the initial magnification parameter is set to the value returned by iptgetpref('ImshowInitialMagnification').

If the image is displayed in a figure with its 'WindowStyle' property set to 'docked', imshow warns and displays the image at the largest magnification that fits in the figure.

Note: If you specify the axes position (using subplot or axes), imshow ignores any initial magnification you might have specified and defaults to the 'fit' behavior.

When used with the 'Reduce' parameter, only 'fit' is allowed as an initial magnification.

'Parent'

Handle of an axes that specifies the parent of the image object that will be created by imshow.

'Reduce'

Logical value that specifies whether imshow subsamples the image in filename. The 'Reduce' parameter is only valid for TIFF images and you must specify a file name. Use this parameter to display overviews of very large images.

'XData'

Two-element vector that establishes a nondefault spatial coordinate system by specifying the image XData. The value can have more than two elements, but only the first and last elements are actually used.

'YData'

Two-element vector that establishes a nondefault spatial coordinate system by specifying the image YData. The value can have more than two elements, but only the first and last elements are actually used.

Class Support

A truecolor image can be uint8, uint16, single, or double. An indexed image can be logical, uint8, single, or double. A grayscale image can be logical, uint8, int16, uint16, single, or double. A binary image must be of class logical.

For grayscale images of class single or double, the default display range is [0 1]. If your image's data range 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. For all grayscale images having integer types, the default display range is [intmin(class(I)) intmax(class(I))].

If your image is int8, int16, uint32, int32 or single, the CData in the resulting image object will be double. For all other classes, the CData matches the input image class.

Related Toolbox Preferences

You can use the iptsetpref function to set several toolbox preferences that modify the behavior of imshow.

For more information about these preferences, see iptsetpref.

Remarks

imshow is the toolbox's fundamental image display function, optimizing figure, axes, and image object property settings for image display. imtool provides all the image display capabilities of imshow but also provides access to several other tools for navigating and exploring images, such as the Pixel Region tool, Image Information tool, and the Adjust Contrast tool. imtool presents an integrated environment for displaying images and performing some common image processing tasks.

The imshow function is not supported when MATLAB is started with the -nojvm option.

Examples

Display an image from a file.

imshow('board.tif')

Display an indexed image.

[X,map] = imread('trees.tif');
imshow(X,map)

Display a grayscale image.

I = imread('cameraman.tif');
imshow(I)

Display the same grayscale image, adjusting the display range.

h = imshow(I,[0 80]);

See Also

imread, imtool, iptgetpref, iptsetpref, subimage, truesize, warp

image, imagesc in the MATLAB Function Reference

For more information, see Displaying and Exploring Images.

  


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