Main Content

Build App for Navigating Large Images

This example shows how to build an app using modular tools that displays an image with navigation aids including scroll bars, and overview window, and a magnification box.

First, define a function that builds the app. This example defines a function called my_large_image_display at the end of the example.

After you define the function that builds the app, test the app. Read an image into the workspace.

I = imread('car1.jpg');

Display the image with navigation aids in the app.

 my_large_image_display(I)

Figure My Large Image Display Tool contains an axes object and other objects of type uipanel, uicontrol. The hidden axes object contains an object of type image.

Figure Overview (My Large Image Display Tool) contains an axes object and other objects of type uipanel, uitoolbar, uimenu. The hidden axes object contains 8 objects of type line, patch, image.

App Creation Function

The my_large_image_display function accepts an image as an argument and displays the image in a figure window with scroll bars, an Overview tool, and a magnification box. Note that the function suppresses the toolbar and menu bar in the figure window because scrollable navigation is incompatible with standard MATLAB™ figure window navigation tools.

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);

end

See Also

| |

Related Examples

More About