imgca - Get handle to current axes containing image

Syntax

hax = imgca
hax = imgca(hfig)

Description

hax = imgca returns the handle of the of the current axes that contains an image. The current axes may 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.

hax = 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 getting 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

Label the coins in the image, compute their centroids, and superimpose the centroid locations on the image. View the results using imtool and imgca.

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

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

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

Display original image and superimpose centroids.

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

See also

gca, gcf, imgcf, imhandles

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS