|Image Processing Toolbox User's Guide|
Adding Navigation Aids to a GUI
|Note The toolbox modular navigation tools are incompatible with standard MATLAB figure window navigation tools. When using these tools in a GUI, suppress the toolbar and menu bar in the figure windows to avoid conflicts between the tools.|
The toolbox includes several modular tools that you can use to add navigation aids to a GUI application:
The Scroll Panel is the primary navigation tool; it is a prerequisite for the other navigation tools. When you display an image in a Scroll Panel, the tool displays only a portion of the image, if it is too big to fit into the figure window. When only a portion of the image is visible, the Scroll Panel adds horizontal and vertical scroll bars, to enable viewing of the parts of the image that are not currently visible.
Once you create a Scroll Panel, you can optionally add the other modular navigation tools: the Overview tool and the Magnification tool. The Overview tool displays a view of the entire image, scaled to fit, with a rectangle superimposed over it that indicates the part of the image that is currently visible in the scroll panel. The Magnification Box displays the current magnification of the image and can be used to change the magnification.
The following sections provide more details.
Understanding Scroll Panels
When you display an image in a scroll panel, it changes the object hierarchy of your displayed image. This diagram illustrates the typical object hierarchy for an image displayed in an axes object in a figure object.
The following figure shows this object hierarchy.
Object Hierarchy of Image Displayed in a Figure
When you call the
imscrollpanel function to put the target image in a scrollable window, this object hierarchy changes. For example, this code adds a scroll panel to an image displayed in a figure window, specifying the parent of the scroll panel and the target image as arguments. The example suppresses the figure window toolbar and menu bar because they are not compatible with the scroll panel navigation tools.
hfig = figure('Toolbar','none',... 'Menubar', 'none'); himage = imshow('concordaerial.png'); hpanel = imscrollpanel(hfig,himage);
The following figure shows the object hierarchy after the call to
imscrollpanel. Note how
imscrollpanel inserts new objects (shaded in gray) into the hierarchy between the figure object and the axes object containing the image.
Object Hierarchy of Image Displayed in Scroll Panel
The following figure shows how these graphics objects appear in the scrollable image as it displayed on the screen.
Components of a Scroll Panel
Example: Building a Navigation GUI for Large Images
If your work typically requires that you view large images, you might want to create a custom image display function that includes the modular navigation tools.
This example creates a tool that accepts an image as an argument and displays the image in a scroll panel with an Overview tool and a Magnification box.
|Note 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.|
function my_large_image_display(im) % Create a figure without toolbar and menubar. hfig = figure('Toolbar','none',... 'Menubar', 'none',... 'Name','My Large Image Display Tool',... 'NumberTitle','off',... 'IntegerHandle','off'); % Display the image in a figure with imshow. himage = imshow(im); % Add the scroll panel. hpanel = imscrollpanel(hfig,himage); % Position the scroll panel to accommodate the other tools. set(hpanel,'Units','normalized','Position',[0 .1 1 .9]); % Add the Magnification box. hMagBox = immagbox(hfig,himage); % Position the Magnification box pos = get(hMagBox,'Position'); set(hMagBox,'Position',[0 0 pos(3) pos(4)]); % Add the Overview tool. hovervw = imoverview(himage);
To use the tool, pass it a large image that is already in the MATLAB workspace.
The tool opens a figure window, displaying the image in a scroll panel with the other modular navigation tools: the Overview tool and the Magnification Box tool.
Custom Image Display Tool with Navigation Aids
|Example: Building a Pixel Information GUI||Making Connections for Interactivity|
© 1994-2005 The MathWorks, Inc.