This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Get current axes containing image


h = imgca
h = imgca(fig)


h = imgca returns the current axes that contains an image. The current axes can be in a regular figure window or in an Image Tool window.

If no figure contains an axes that contains an image, imgca creates a new axes.

h = imgca(fig) returns the current axes that contains an image in the specified figure. (It need not be the current figure.)


imgca can be useful in returning the axes object in the Image Tool. You cannot retrieve this axes using gca.


Compute the centroid of each coin, and superimpose its location on the image. View the results using imtool and imgca.

I = imread('coins.png');
figure, imshow(I)

Original Image

bw = im2bw(I, graythresh(getimage));
figure, imshow(bw)

Binary Image

bw2 = imfill(bw,'holes');
s  = regionprops(bw2, 'centroid');
centroids = cat(1, s.Centroid);

Display original image I and superimpose centroids:

plot(imgca,centroids(:,1), centroids(:,2), 'r*')

Centroids of Coins

See also

gca, gcf, imgcf, imhandles

Introduced before R2006a

Was this topic helpful?