Get handle to current axes containing image


h = imgca
h = imgca(hfig)


h = imgca returns the handle of 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(hfig) returns the handle to 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 handle to the Image Tool axes. Because the Image Tool turns graphics object handle visibility off, you cannot retrieve a handle to the tool figure 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?