This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Get current figure containing image


hfig = imgcf


hfig = imgcf returns the current figure that contains an image. The figure may be a regular figure window that contains at least one image or an Image Tool window.

If none of the figures currently open contains an image, imgcf creates a new figure.


imgcf can be useful in getting the figure used by the Image Tool. You cannot retrieve the tool figure using gcf.


% In this example, use the handle of a figure containing an Image Tool window to center the window on the screen.
imtool rice.png
sz = get(groot,'ScreenSize');
pos = get(imgcf,'Position');
pos = [(sz(3)-pos(3))/2 (sz(4)-pos(4))/2 pos(3) pos(4)];

See also

gca, gcf, imgca, imhandles

Introduced before R2006a