Image Processing Toolbox User's Guide |
Specifying the Target Image
To associate a modular tool with a target image displayed in a MATLAB figure window, create the tool using the appropriate tool creation function, specifying a handle to the target image as an argument. The function creates the tool and automatically sets up the interactivity connection between the tool and the target image that the tool requires.
This section covers the following topics:
Associating Modular Tools with the Default Target Image
By default, most of the modular tool creation functions support a no-argument syntax that uses the image in the current figure as the target image. If the current figure contains multiple images, the tools associate themselves with the first image in the figure object's children (the last image created). impixelinfo
, impixelinfoval
and imdisplayrange
can work with multiple images in a figure.
For example, to use the Pixel Information tool with a target image, display the image in a figure window, using imshow
, and then call the impixelinfo
function to create the tool. In this example, the image in the current figure is the target image.
The following figure shows the target image in a figure with the Pixel Information tool in the lower left corner of the window. The Pixel Information tool automatically sets up a connection to the target image: when you move the cursor over the image, the tool displays the x- and y-coordinates and value of the pixel under the cursor.
Figure Window with Pixel Information Tool
Associating Modular Tools with a Particular Image
You can specify the target image of the modular tool when you create it. Pass a handle to the target image as an argument to the modular tool creation function. You can also specify a handle to a figure, axes, or uipanel object that contains the target image.
Continuing the example in the previous section, you might want to add the Display Range tool to the figure window that already contains the Pixel Information tool. To do this, call the imdisplayrange
function, specifying the handle to the target image. You could also have specified the handle of the figure, axes, or uipanel object containing the target image.
himage = imshow('pout.tif'); hpixelinfopanel = impixelinfo(himage) hdrangepanel = imdisplayrange(himage)
Note that the example retrieves handles to the uipanel objects created by the impixelinfo
and imdisplayrange
functions; both tools are uipanel objects. It can be helpful to get handles to the tools if you want to change their positioning. See Positioning the Modular Tools in a GUI for more information.
The following figure shows the target image in a figure with the Pixel Information tool in the lower left corner and the Display Range tool in the lower right corner of the window. The Display Range tool automatically sets up a connection to the target image: when you move the cursor over the image (or images) in the figure, the Display Range tool shows the display range of the image.
Figure Window with Pixel Information and Display Range Tools
Getting the Handle of the Target Image
The examples in the previous section use the optional imshow
syntax that returns a handle to the image displayed, himage
. When creating GUIs with the modular tools, having a handle to the target image can be useful. You can get the handle when you first display the image, using this optional imshow
syntax. You can also get a handle to the target image using the imhandles
function. The imhandles
function returns all the image objects that are children of a specified figure, axes, uipanel, or image object.
For example, imshow
returns a handle to the image in this syntax.
When you call the imhandles
function, specifying a handle to the figure (or axes) containing the image, it returns a handle to the same image.
Displaying the Target Image | Specifying the Parent of a Modular Tool |
© 1994-2005 The MathWorks, Inc.