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

Creating the Modular Tools

Creating the Modular Tools

In this section...

“Overview” on page 5-11

“Associating Modular Tools with a Particular Image” on page 5-12 “Getting the Handle of the Target Image” on page 5-14 “Specifying the Parent of a Modular Tool” on page 5-15 “Positioning the Modular Tools in a GUI” on page 5-18

“Build a Pixel Information GUI” on page 5-19 “Adding Navigation Aids to a GUI” on page 5-22

Overview

To associate a modular tool with a target image displayed in a MATLAB figure window, you must create the tool using the appropriate tool creation function. You specify a handle to the target image as an argument to the tool creation function. The function creates the tool and automatically sets up the interactivity connection between the tool and the 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.

imshow('pout.tif'); impixelinfo

5-11

5 Building GUIs with Modular Tools

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 pointer over the image, the tool displays the x- and y-coordinates and value of the pixel under the pointer.

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 by passing 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

5-12

Creating the Modular Tools

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” on page 5-18 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 pointer over the image (or images) in the figure, the Display Range tool shows the display range of the image.

5-13

5 Building GUIs with Modular Tools

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.

5-14

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