【问题标题】:Difference between subImage and subplotsubImage 和 subplot 之间的区别
【发布时间】:2016-04-13 16:59:11
【问题描述】:

subImagesubplot 有什么区别?如果可能的话,请给我解释一个我使用每一个的例子。

另外,我有一个例子:

load trees
[X2,map2] = imread('forest.tif');
subplot(1,2,1), subimage(X,map)
subplot(1,2,2), subimage(X2,map2)`

这就是我不知道它们之间有什么区别的地方。

【问题讨论】:

    标签: image matlab plot matlab-figure axes


    【解决方案1】:

    subimage

    subimage(来自图像处理工具箱)允许您在同一个图形中拥有两个具有两个不同颜色图的图像。在旧版本的 MATLAB 中,不可能在同一个图中有两个索引图像具有不同的颜色图(例如 grayjet)。 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);
    

    【讨论】:

      猜你喜欢
      • 2019-02-12
      • 1970-01-01
      • 2021-12-25
      • 2020-05-10
      • 2014-09-20
      • 2010-10-28
      • 2015-10-04
      • 2012-08-12
      • 2011-02-18
      相关资源
      最近更新 更多