0 matlab plot image axes matlab-figure
这之间有什么区别subImage和subplot?如果有可能,请向我解释一个我使用每个例子的例子.
另外,我有一个例子,其中两个:
load trees
[X2,map2] = imread('forest.tif');
subplot(1,2,1), subimage(X,map)
subplot(1,2,2), subimage(X2,map2)`
Run Code Online (Sandbox Code Playgroud)
这是我不知道它们之间有什么区别的地方.
subimagesubimage(来自图像处理工具箱)允许您在同一图中使用两个不同的颜色图具有两个图像.在较旧版本的MATLAB中,不可能在同一图中使用不同的色图(例如gray和jet)使用两个索引图像.subimage允许你拥有它.然而,这与将索引图像首先转换为RGB图像实际上没有区别.
rgbimage = ind2rgb(indexedimage, colormap);
imshow(rgbimage);
Run Code Online (Sandbox Code Playgroud)
作为一个例子:
subplot(1,2,1);
imshow(ind2rgb(X, map));
subplot(1,2,2);
imshow(ind2rgb(X2, map2));
Run Code Online (Sandbox Code Playgroud)
在较新版本的MATLAB中,您可以为每个轴指定不同的色彩映射,以便您可以:
ax1 = subplot(1,2,1);
imagesc(X)
colormap(ax1, map);
ax2 = subplot(1,2,2);
imagesc(X2);
colormap(ax2, map2);
Run Code Online (Sandbox Code Playgroud)
subplotsubplot不是任何工具箱的一部分,并允许您轻松组织axes图形的网格.这些轴可以包含图像,但它们也可以包含常规线图或任何图形对象.
subplot(1,2,1)
plot(rand(10,1))
subplot(1,2,2)
imagesc(rand(10))
axis image
Run Code Online (Sandbox Code Playgroud)
在您的示例中,您可以轻松使用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);
Run Code Online (Sandbox Code Playgroud)