immagbox

Magnification box for scroll panel

Syntax

hbox = immagbox(hparent,himage)

Description

hbox = immagbox(hparent,himage) creates a Magnification box for the image displayed in a scroll panel created by imscrollpanel. hparent is a handle to the figure or uipanel object that will contain the Magnification box. himage is a handle to the target image (the image in the scroll panel). immagbox returns hbox, which is a handle to the Magnification box uicontrol object

A Magnification box is an editable text box uicontrol 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.

API Functions

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

api = iptgetapi(hbox)

The API for the Magnification box includes the following function.

Function

Description

setMagnification

Sets the magnification in units of screen pixels per image pixel.

  setMagnification(new_mag)

where new_mag is a scalar magnification factor. Multiply new_mag by 100 to get percent magnification. For example if you call setMagnification(2), the magnification box will show the string '200%'.

Examples

Add a magnification box to a scrollable image. Because the toolbox scrollable navigation is incompatible with standard MATLAB® figure window navigation tools, the example suppresses the toolbar and menu bar in the figure window. The example positions the scroll panel in the figure window to allow room for the magnification box.

hFig = figure('Toolbar','none',...
              'Menubar','none');
hIm = imshow('pears.png'); 
hSP = imscrollpanel(hFig,hIm);
set(hSP,'Units','normalized',...
            'Position',[0 .1 1 .9])

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

Change the magnification of the image in the scroll panel, using the scroll panel API function setMagnification. Notice how the magnification box updates.

apiSP = iptgetapi(hSP);
apiSP.setMagnification(2)
Was this topic helpful?