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

Setting Toolbox Preferences

Setting Toolbox Preferences

In this section...

“Viewing and Changing Preferences Using the Preferences Dialog Box” on page 4-77

“Retrieving the Values of Toolbox Preferences Programmatically” on page 4-77

“Setting the Values of Toolbox Preferences Programmatically” on page 4-78

Viewing and Changing Preferences Using the Preferences Dialog Box

You can view and change Image Processing Toolbox Preferences in the Preferences dialog box. To open this dialog box, select Preferences > Image Processing in the File menu in the MATLAB desktop or in the Image Tool, or type iptprefs at the command line.

Retrieving the Values of Toolbox Preferences Programmatically

You can use Image Processing Toolbox preferences to control certain characteristics of how imshow and imtool display images on your screen. For example, using toolbox preferences, you can specify the initial magnification used by imtool and imshow.

To determine the current value of a preference, use the iptgetpref function. This example uses iptgetpref to determine the value of the

ImtoolInitialMagnification preference.

iptgetpref('ImtoolInitialMagnification')

ans =

100

Preference names are case insensitive and can be abbreviated. For a complete list of toolbox preferences, see the iptprefs reference page.

4-77

4 Displaying and Exploring Images

Setting the Values of Toolbox Preferences Programmatically

To specify the value of a toolbox preference, use the iptsetpref function. This example calls iptsetpref to specify that imshow resize the figure window so that it fits tightly around displayed images.

iptsetpref('ImshowBorder', 'tight');

For a table of the available preferences, see the iptprefs reference page.

4-78

5

Building GUIs with

Modular Tools

This chapter describes how to use the toolbox modular tools to create custom image processing applications.

“Overview” on page 5-2

“Displaying the Target Image” on page 5-10

“Creating the Modular Tools” on page 5-11

“Customizing Modular Tool Interactivity” on page 5-28

“Creating Your Own Modular Tools” on page 5-33

5 Building GUIs with Modular Tools

Overview

The toolbox includes several modular interactive tools that you can activate from the command line and use with images displayed in a MATLAB figure window, called the target image in this documentation. The tools are modular because they can be used independently or in combination to create custom graphical user interfaces (GUIs) for image processing applications. Using the tools typically involves the following steps.

 

Step

Description

Notes

 

 

1

Display the image to be

Use the imshow function to display

 

 

 

processed (called the target

the target image, see “Displaying

 

 

 

image) in a figure window.

the Target Image” on page 5-10.

 

 

2

Create the modular tool,

You use the modular tool creation

 

 

 

associating it with the target

functions to create the tools — see

 

 

 

image.

Summary of Modular Tools on page

 

 

 

 

5-3

 

 

 

 

Most of the tools associate

 

 

 

 

themselves with the image in the

 

 

 

 

current axes, by default, but you

 

 

 

 

can specify the handle to a specific

 

 

 

 

image object, or a handle to a

 

 

 

 

figure, axes, or uipanel object that

 

 

 

 

contains an image. See “Creating

 

 

 

 

the Modular Tools” on page 5-11.

 

 

 

 

Depending on how you designed

 

 

 

 

your GUI, you might also want

 

 

 

 

to specify the parent object of the

 

 

 

 

modular tool itself. This is optional;

 

 

 

 

by default, the tools either use the

 

 

 

 

same parent as the target image or

 

 

 

 

open in a separate figure window.

 

 

 

 

See “Specifying the Parent of a

 

 

 

 

Modular Tool” on page 5-15 for more

 

 

 

 

information.

 

 

 

 

You might need to specify the

 

 

 

 

position of the graphics objects in

 

 

 

 

 

 

5-2

Overview

Step

Description

Notes

 

 

 

 

 

the GUI, including the modular

 

 

tools. See “Positioning the Modular

 

 

Tools in a GUI” on page 5-18 for

 

 

more information.

3

Set up interactivity between

The modular tools all set up their

 

the tool and the target image.

interactive connections to the target

 

(Optional)

image automatically. However,

 

 

you can also specify custom

 

 

connectivity using modular tool

 

 

APIs. See “Customizing Modular

 

 

Tool Interactivity” on page 5-28 for

 

 

more information.

The following table lists the modular tools in alphabetical order. The table includes an illustration of each tool and the function you use to create it.

Note The Image Processing Toolbox GUI, Image Tool, uses these modular tools — see “Using the Image Tool to Explore Images” on page 4-11.

Summary of Modular Tools

 

Modular Tool

Example

Description

 

 

Adjust Contrast

 

Displays a histogram of the

 

 

tool

 

target image and enables

 

 

 

 

interactive adjustment of

 

 

 

 

contrast and brightness

 

 

 

 

by manipulation of the

 

 

 

 

display range.

 

 

 

 

Use the imcontrast

 

 

 

 

function to create the

 

 

 

 

tool in a separate figure

 

 

 

 

 

 

5-3

5 Building GUIs with Modular Tools

Summary of Modular Tools (Continued)

Modular Tool

Example

Description

 

 

 

 

 

window and associate it

 

 

with an image.

Choose Colormap

 

Allows you to change the

tool

 

colormap of the target

 

 

figure. You can select

 

 

one of the MATLAB

 

 

colormaps, select a

 

 

colormap variable from the

 

 

MATLAB workspace, or

 

 

enter a custom MATLAB

 

 

expression.

 

 

Use the imcolormaptool

 

 

function to launch the

 

 

tool in a separate figure

 

 

window.

Crop Image tool

 

Displays a draggable,

 

 

resizable rectangle on an

 

 

image. You can move

 

 

and resize the rectangle

 

 

to define the crop region.

 

 

Double-click to perform

 

 

the crop operation or

 

 

select Crop Image from the

 

 

context menu.

 

 

Use the imcrop function

 

 

to create the tool and

 

 

associate it with an image.

5-4

Overview

Summary of Modular Tools (Continued)

 

Modular Tool

Example

Description

 

 

Display Range

 

Displays a text string

 

 

tool

 

identifying the display

 

 

 

 

range values of the

 

 

 

 

associated image.

 

 

 

 

Use the imdisplayrange

 

 

 

 

function to create the tool,

 

 

 

 

associate it with an image,

 

 

 

 

and embed it in a figure or

 

 

 

 

uipanel.

 

 

Distance tool

 

Displays a draggable,

 

 

 

 

resizable line on an image.

 

 

 

 

Superimposed on the line

 

 

 

 

is the distance between the

 

 

 

 

two endpoints of the line.

 

 

 

 

The distance is measured

 

 

 

 

in units specified by

 

 

 

 

the XData and YData

 

 

 

 

properties, which is pixels

 

 

 

 

by default.

 

 

 

 

Use the imdistline

 

 

 

 

function to create the tool

 

 

 

 

and associate it with an

 

 

 

 

image.

 

5-5

5 Building GUIs with Modular Tools

Summary of Modular Tools (Continued)

 

Modular Tool

Example

 

Description

 

 

Image

 

 

Displays basic attributes

 

 

Information tool

 

 

about the target image. If

 

 

 

 

 

the image displayed was

 

 

 

 

 

specified as a graphics

 

 

 

 

 

file, the tool displays any

 

 

 

 

 

metadata that the image

 

 

 

 

 

file might contain.

 

 

 

 

 

Use the imageinfo

 

 

 

 

 

function to create the

 

 

 

 

 

tool in a separate figure

 

 

 

 

 

window and associate it

 

 

 

 

 

with an image.

 

 

Magnification box

 

 

Creates a text edit box

 

 

 

 

 

containing the current

 

 

 

 

 

magnification of the target

 

 

 

 

 

image. Users can change

 

 

 

 

 

the magnification of the

 

 

 

 

 

image by entering a new

 

 

 

 

 

magnification value.

 

 

 

 

 

Use immagbox to create

 

 

 

 

 

the tool, associate it with

 

 

 

 

 

an image, and embed it in

 

 

 

 

 

a figure or uipanel.

 

 

 

 

 

 

 

 

 

 

 

 

Note The target image

 

 

 

 

 

must be contained in a

 

 

 

 

 

scroll panel.

 

 

 

 

 

 

 

 

5-6

Overview

Summary of Modular Tools (Continued)

 

Modular Tool

Example

 

Description

 

 

Overview tool

 

 

Displays the target image

 

 

 

 

 

in its entirety with the

 

 

 

 

 

portion currently visible in

 

 

 

 

 

the scroll panel outlined by

 

 

 

 

 

a rectangle superimposed

 

 

 

 

 

on the image. Moving

 

 

 

 

 

the rectangle changes the

 

 

 

 

 

portion of the target image

 

 

 

 

 

that is currently visible in

 

 

 

 

 

the scroll panel.

 

 

 

 

 

Use imoverview to create

 

 

 

 

 

the tool in a separate figure

 

 

 

 

 

window and associate it

 

 

 

 

 

with an image.

 

 

 

 

 

Use imoverviewpanel to

 

 

 

 

 

create the tool in a uipanel

 

 

 

 

 

that can be embedded

 

 

 

 

 

within another figure or

 

 

 

 

 

uipanel.

 

 

 

 

 

 

 

 

 

 

 

 

Note The target image

 

 

 

 

 

must be contained in a

 

 

 

 

 

scroll panel.

 

 

 

 

 

 

 

 

5-7

5 Building GUIs with Modular Tools

Summary of Modular Tools (Continued)

 

Modular Tool

Example

Description

 

 

Pixel Information

 

Displays information

 

 

tool

 

about the pixel the mouse

 

 

 

 

is over in the target image.

 

 

 

 

Use impixelinfo to create

 

 

 

 

the tool, associate it with

 

 

 

 

an image, and display it in

 

 

 

 

a figure or uipanel.

 

 

 

 

If you want to display only

 

 

 

 

the pixel values, without

 

 

 

 

the Pixel info label, use

 

 

 

 

impixelinfoval.

 

 

Pixel Region tool

 

Display pixel values for

 

 

 

 

a specified region in the

 

 

 

 

target image.

 

 

 

 

Use impixelregion

 

 

 

 

to create the tool in a

 

 

 

 

separate figure window

 

 

 

 

and associate it with an

 

 

 

 

image.

 

 

 

 

Use impixelregionpanel

 

 

 

 

to create the tool as

 

 

 

 

a uipanel that can be

 

 

 

 

embedded within another

 

 

 

 

figure or uipanel.

 

5-8

Overview

Summary of Modular Tools (Continued)

 

Modular Tool

Example

Description

 

 

Save Image tool

 

Display the Save Image

 

 

 

 

dialog box. Use this to

 

 

 

 

specify the name of an

 

 

 

 

output image and choose

 

 

 

 

the file format used to

 

 

 

 

store the image.

 

 

 

 

Use imsave to create the

 

 

 

 

tool in a separate figure

 

 

 

 

window and associate it

 

 

 

 

with an image.

 

 

Scroll Panel tool

 

Display target image in a

 

 

 

 

scrollable panel.

 

 

 

 

Use imscrollpanel to

 

 

 

 

add a scroll panel to an

 

 

 

 

image displayed in a figure

 

 

 

 

window.

 

 

 

 

 

 

5-9

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