immagbox

Magnification box for image displayed in scroll panel

Description

Use the immagbox function to add a magnification box to the same figure as an image contained in a scroll panel. A magnification box is an editable text box that contains the current magnification of the target image. When you enter a new value in the magnification box, the magnification of the target image changes. When the magnification of the target image changes for any reason, the magnification box updates the magnification value.

example

hbox = immagbox(hparent,himage) creates a magnification box for an image displayed in a scroll panel. himage is a handle to the target image in the scroll panel. hparent is a handle to the figure or uipanel object that will contain the magnification box. The function returns hbox, a handle to the magnification box.

Examples

collapse all

Display an image in a figure. The example suppresses the standard toolbar and menubar in the figure window because these do not work with the scroll panel.

hFig = figure('Toolbar','none','Menubar','none');
hIm = imshow('pears.png');

Create a scroll panel to contain the image.

hSP = imscrollpanel(hFig,hIm);
set(hSP,'Units','normalized','Position',[0 .1 1 .9])

Add a magnification box to the figure. Set the position of the magnification box to the lower left corner of the figure.

hMagBox = immagbox(hFig,hIm);
pos = get(hMagBox,'Position');
set(hMagBox,'Position',[0 0 pos(3) pos(4)])

Get the scroll panel API so that you can control the view programmatically.

apiSP = iptgetapi(hSP);

Set the magnification of the image to 200% by using the scroll panel API function setMagnification. Notice how the magnification box updates.

apiSP.setMagnification(2)

Input Arguments

collapse all

Handle to a figure or uipanel object that contains the magnification box, specified as a handle.

Handle to target image, specified as a handle. The image must be displayed in a scroll panel created by imscrollpanel.

Output Arguments

collapse all

Handle to magnification box, returned as a handle. A magnification box is a type of uipanel object.

More About

collapse all

Magnification Box API Structure

A magnification box contains a structure of function handles, called an API. You can use the functions in this API to manipulate the magnification box. To retrieve this structure, use the iptgetapi function, as in the following example.

api = iptgetapi(hbox)

This table lists the magnification box API functions, in the order they appear in the structure.

Function

Description

setMagnification

Set the magnification of the target image in units of screen pixels per image pixel.

mag = api.setMagnification(new_mag)

new_mag is a scalar magnification factor.

Introduced before R2006a