Magnification box for image displayed in scroll panel
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
hbox = immagbox(hparent,himage)
creates a magnification box for an image displayed
in a scroll panel.
hbox = immagbox(
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
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.
hparent— Handle to figure or uipanel object
Handle to a figure or uipanel object that contains the magnification box, specified as a handle.
hbox— Handle to magnification box
Handle to magnification box, returned as a handle. A magnification box is a type of uipanel object.
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
api = iptgetapi(hbox)
This table lists the magnification box API functions, in the order they appear in the structure.
Set the magnification of the target image in units of screen pixels per image pixel.
mag = api.setMagnification(new_mag)