Documentation Center

  • Trial Software
  • Product Updates

imgca

Get handle to current axes containing image

Syntax

h = imgca
h = imgca(hfig)

Description

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.)

Note

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.

Examples

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:

imtool(I)
hold(imgca,'on')
plot(imgca,centroids(:,1), centroids(:,2), 'r*')
hold(imgca,'off')

Centroids of Coins

See also

gca, gcf, imgcf, imhandles

Was this topic helpful?