获取 imscollpanel 作为子图以及另一个图像

Getting an imscollpanel as a subplot along with another image

我试图生成一个视图,其中顶部有一个图像,下面有一组可水平滚动的图像。

为了显示一组图像,我将它们水平连接成一个图像,然后显示它。

我可以分别显示这两个图,但是当我尝试将它们合并为一个图(顶部有一个图,底部有一个可滚动视图)时,此代码无法完成工作.相反,它只给了我顶部的数字(如我所愿)和底部的图像(没有滚动条,这不是我想要的)。如何让滚动条进入底部图像?

这是我尝试过的(test3.png 是我想在顶部显示的,图像数组是我想要在底部水平滚动的):

hFig = figure('Toolbar','none','Menubar','none');
images{1} = imread('test1.png');
images{2} = imread('test2.png');
images{3} = imread('test1.png');
images{4} = imread('test2.png');
images{5} = imread('test1.png');
images{6} = imread('test2.png');
images{7} = imread('test1.png');
images{8} = imread('test2.png');
im = cat(2,images{:});
hIm = imshow(im);
hSP = imscrollpanel(hFig,hIm);

newFig = figure;
newhIm = imshow('test3.png');

figure;
subplot(2,1,1);
imshow('test3.png')
subplot(2,1,2);
imshow(getimage(hSP))

如有任何帮助,我们将不胜感激。

您需要 "add scrollbar to axis" 之类的东西才能与 subplot 一起使用。希望this 帮助...

这是一种方法。该技巧基于 this 答案,包括创建一个 uipanel,在其中添加一个轴,您可以在其中创建 scrollpanel.

根据您的情况进行了调整,如下所示:

clear
clc

%// Read demo images and create cell array.
a = imread('peppers.png');
a1 = a(:,:,1);
b = rgb2gray(imread('peppers.png'));

images{1} = a1;
images{2} = b;
images{3} = a1;
images{4} = b;
images{5} = a1;
images{6} = b;
images{7} = a1;
images{8} = b;
im = cat(2,images{:});

hf=figure; 

%// 1st subplot
hs1 = subplot(2,1,1);
imshow(a);

%// Create uipanel and place it below current image/subplot 1

hPanel= uipanel('Units','Normalized');

% Set the uipanel position to where the image is desired to be displayed.

set(hPanel,'position',[.05 0 .9 .5]);

%// Create an axes whose parent is the uipanel.
ax1 = axes('parent',hPanel,'position',[0 0 1 1],'Units','normalized');

%// Display image to get the handle.
him1 = imshow(im,'parent',ax1);

% Create the scroll panel
hSP = imscrollpanel(hPanel,him1); 

输出:

您可以微调坐标轴的位置...但这应该能让您入门。 祝你好运!