Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

Creating the Modular Tools

For example, imshow returns a handle to the image in this syntax.

hfig = figure;

himage = imshow('moon.tif') himage =

152.0055

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.

himage2 = imhandles(hfig) himage2 =

152.0055

Specifying the Parent of a Modular Tool

When you create a modular tool, in addition to specifying the target image, you can optionally specify the object that you want to be the parent of the tool. By specifying the parent, you determine where the tool appears on your screen. Using this syntax of the modular tool creation functions, you can add the tool to the figure window containing the target image, open the tool in a separate figure window, or create some other combination.

Specifying the parent is optional; the modular tools all have a default behavior. Some of the smaller tools, such as the Pixel Information tool, use the parent of the target image as their parent, inserting themselves in the same figure window as the target image. Other modular tools, such as the Pixel Region tool or the Overview tool, open in separate figures of their own.

Tools With Separate Creation Functions

Two of the tools, the Pixel Region tool and the Overview tool, have a separate creation function to provide this capability. Their primary creation functions, imoverview and impixelregion, open the tools in a separate figure window. To specify a different parent, you must use the imoverviewpanel and impixelregionpanel functions.

5-15

5 Building GUIs with Modular Tools

Note The Overview tool and the Pixel Region tool provide additional capabilities when created in their own figure windows. For example, both tools include zoom buttons that are not part of their uipanel versions.

Example: Embedding the Pixel Region Tool in an Existing Figure

This example shows the default behavior when you create the Pixel Region tool using the impixelregion function. The tool opens in a separate figure window, as shown in the following figure.

himage = imshow('pout.tif') hpixelinfopanel = impixelinfo(himage); hdrangepanel = imdisplayrange(himage); hpixreg = impixelregion(himage);

Pixel Region tool

Pixel Region rectangle

Target Image with Pixel Region Tool in Separate Window (Default)

5-16

Creating the Modular Tools

To embed the Pixel Region tool in the same window as the target image, you must specify the handle of the target image’s parent figure as the parent of the Pixel Region tool when you create it.

The following example creates a figure and an axes object, getting handles to both objects. The example needs these handles to perform some repositioning of the objects in the figure to ensure their visibility. See “Positioning the Modular Tools in a GUI” on page 5-18 for more information. The example then creates the modular tools, specifying the figure containing the target image as the parent of the Pixel Region tool. Note that the example uses the impixelregionpanel function to create the tool.

hfig = figure;

hax = axes('units','normalized','position',[0 .5 1 .5]); himage = imshow('pout.tif')

hpixelinfopanel = impixelinfo(himage); hdrangepanel = imdisplayrange(himage); hpixreg = impixelregionpanel(hfig,himage);

set(hpixreg, 'Units','normalized','Position',[0 .08 1 .4]);

5-17

Соседние файлы в папке 2read