Main Content

getimage

Image data from axes

Description

I= getimage(h)returns the first image data contained in the graphics objecth.

[x,y,I] = getimage(h)also returns the image extent in thexandydirection.

[___,flag] = getimage(h)also returns a flag that indicates the type of image thathcontains.

example

[___] = getimagereturns information for the current axes object.

Examples

collapse all

Display image directly from a file usingimshowand create a variable in the workspace that contains the image data.

imshowrice.png

Figure contains an axes object. The axes object contains an object of type image.

I = getimage;

Display image directly from a file using the Image Viewer app (imtool) and create a variable in the workspace that contains the image data.

h = imtool('cameraman.tif');

Figure Image Tool 1 - cameraman.tif contains an axes object and other objects of type uimenu, uitoolbar, uipanel. The axes object contains an object of type image.

I = getimage(imgca);

Input Arguments

collapse all

Handle to a figure, axes, uipanel, or image graphics object, specified as a handle. Ifhis an axes or figure handle containing multiple images, thengetimageuses the first image returned byfindobj(h,'Type','image').

Output Arguments

collapse all

Image data, returned as a numeric array.Iis identical to the imageCData; it contains the same values and is of the same class as the imageCData. Ifhis not an image or does not contain an image, thenIis empty.

Image extent in thexdirection, returned as a 2-element numeric vector of the form[xmin xmax].xis identical to the imageXData.

Data Types:double

Image extent in theydirection, returned as a 2-element numeric vector of the form[ymin ymax].yis identical to the imageYData.

Data Types:double

Image type, returned as an integer with one of these values:

Flag

Type of Image

0

Not an image;Iis returned as an empty matrix

1

Indexed image

2

Intensity image with values in standard range. The standard range forsingleanddoubleimages is [0,1].

3

Intensity data, but not in standard range

4

RGB image

5

Binary image

Data Types:double

版本历史

Introduced before R2006a

See Also

|