Image Processing Toolbox User's Guide Previous page   Next Page
getimage

Get image data from axes

Syntax

Description

A = getimage(h) returns the first image data contained in the Handle Graphics object h. h can be a figure, axes, or image. A is identical to the image CData; it contains the same values and is of the same class (uint8, uint16, double, or logical) as the image CData. If h is not an image or does not contain an image, A is empty.

[x,y,A] = getimage(h) returns the image XData in x and the YData in y. XData and YData are two-element vectors that indicate the range of the x-axis and y-axis.

[...,A,flag] = getimage(h) returns an integer flag that indicates the type of image h contains. This table summarizes the possible values for flag.

Flag
Type of Image
0
Not an image; A is returned as an empty matrix
1
Indexed image
2
Intensity image with values in standard range ([0,1] for single and double arrays, [0,255] for uint8 arrays, [0,65535] for uint16 arrays)
3
Intensity data, but not in standard range
4
RGB image
5
Binary image

[...] = getimage returns information for the current axes object. It is equivalent to [...] = getimage(gca).

Class Support

The output array A is of the same class as the image CData. All other inputs and outputs are of class double.

Note

For int16 and single images, the image data returned by getimage is of class double, not int16 or single. This is because the getimage function gets the data from the image object's CData property and image objects store int16 and single image data as class double.

For example, create an image object of class int16. If you retrieve the CData from the object and check its class, it returns double.

Therefore, if you get the image data using the getimage function, the data it returns is also of class double. The flag return value is set to 3.

The same is true for an image of class single. Getting the CData directly from the image object or by using getimage, the class of the returned data is double.

For images of class single, the flag return value is set to 2 because single and double share the same dynamic range.

Example

After using imshow or imtool to display an image directly from a file, use getimage to get the image data into the workspace.

See Also

imshow, imtool


Previous page  getheight getimagemodel Next page

© 1994-2005 The MathWorks, Inc.