How do I change the image in my GUI by targeting an axis when using IMSCROLLPANEL function in Image Processing Toolbox 5.3 (R2006b)?

2 views (last 30 days)
I have a GUI in which I want to display an image using IMSCROLLPANEL. But IMSCROLLPANEL displays the image on the figure itself and does not let me specify the axis on which I want the image to be displayed.
Also, I want to be able to display subsequent scrollable images on this axis.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The IMSCROLLPANEL needs a UIPANEL to add horizontal and vertical scroll bars to enable navigation around the image.
Therefore, to target an axis when using the IMSCROLLPANEL function a uipanel needs to be created as a parent of the axis.
The code below shows an example of performing this operation:
hf=figure; %handle to the figure
% Create a UIPANEL (imscrollpanel needs a figure or uipanel handle to
% operate)
ppp = uipanel('Units','Pixels');
% Set the uipanel position to where the image is desired to be displayed.
set(ppp,'position',[20 20 400 400]);
% Axes have to be a child on the uipanel for imscrollpanel to operate
% normally.
ax1 = axes('parent',ppp,'position',[0 0 1 1],'Units','normalized');
%Create the two images
im1=imread('saturn.png');
im2 = im1(:,:,1);
% display first image and obtain the handle
him1 = image(im1,'parent',ax1);
% Create the scroll panel
hSP = imscrollpanel(ppp,him1);
% wait for user
input('enter')
% Clear the axes (which are now a child of the scrollpanel)
cla(ax1);
%wait for user
input('enter')
%display second image
him2=image(im2,'parent',ax1);

More Answers (0)

Tags

Products


Release

R2006b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!