subimage
subimage(来自图像处理工具箱)允许您在同一个图形中拥有两个具有两个不同颜色图的图像。在旧版本的 MATLAB 中,不可能在同一个图中有两个索引图像具有不同的颜色图(例如 gray 和 jet)。 subimage 允许你拥有它。然而,这实际上与首先将索引图像转换为 RGB 图像没有什么不同。
rgbimage = ind2rgb(indexedimage, colormap);
imshow(rgbimage);
举个例子:
subplot(1,2,1);
imshow(ind2rgb(X, map));
subplot(1,2,2);
imshow(ind2rgb(X2, map2));
在较新版本的 MATLAB 中,您可以为每个轴指定不同的颜色图,以便您可以这样做:
ax1 = subplot(1,2,1);
imagesc(X)
colormap(ax1, map);
ax2 = subplot(1,2,2);
imagesc(X2);
colormap(ax2, map2);
subplot
subplot 不是任何工具箱的一部分,它允许您在图形上轻松组织axes 的网格。这些轴可以包含图像,但也可以包含常规线图或任何图形对象。
subplot(1,2,1)
plot(rand(10,1))
subplot(1,2,2)
imagesc(rand(10))
axis image
在您的示例中,您可以轻松地使用axes 而不是subplot。
ax1 = axes('Position', [0 0 0.5 1]);
subimage(X, map);
ax2 = axes('Position', [0.5 0 0.5 1]);
subimage(X2, map2);