在3D空间中分层多个图像

Vid*_*dar 9 matlab plot visualization image

假设我们有一个大小为49x49x5的矩阵I,对应于沿着第三维堆叠的5个大小为49x49的图像,因此我们总共有5个图像.这些图像应该可视化3D空间中的气体密度,因此我们可以将每个图像视为不同位置的房间的剖面.

有没有办法在MATLAB中制作一个图形,其中所有5个图像都显示为悬挂在它们"来自"的3D空间中?

这是一张希望让我更清楚自己所追求的图像: 5个图像haning在3D空间

Amr*_*mro 12

请考虑以下示例.它使用低级SURFACE功能绘制堆积图像:

%# create stacked images (I am simply repeating the same image 5 times)
img = load('clown');
I = repmat(img.X,[1 1 5]);
cmap = img.map;

%# coordinates
[X,Y] = meshgrid(1:size(I,2), 1:size(I,1));
Z = ones(size(I,1),size(I,2));

%# plot each slice as a texture-mapped surface (stacked along the Z-dimension)
for k=1:size(I,3)
    surface('XData',X-0.5, 'YData',Y-0.5, 'ZData',Z.*k, ...
        'CData',I(:,:,k), 'CDataMapping','direct', ...
        'EdgeColor','none', 'FaceColor','texturemap')
end
colormap(cmap)
view(3), box on, axis tight square
set(gca, 'YDir','reverse', 'ZLim',[0 size(I,3)+1])
Run Code Online (Sandbox Code Playgroud)

我正在使用索引彩色图像(使用直接颜色映射),但可以轻松更改为使用灰度图像(使用缩放颜色映射).

现在,如果您想要像在问题中显示的那样排列3D空间,只需交换Y和Z尺寸(沿Y维而不是Z维堆叠的图像).

通常,要对视角进行更多控制,请使用相机操作功能.

screenshot_zstacked_indexed screenshot_ystacked_grayscale