【问题标题】:Overlaying Images in MATLAB with different color channel在 MATLAB 中用不同的颜色通道覆盖图像
【发布时间】:2015-04-11 06:25:02
【问题描述】:

我有三个由 MATLAB 创建的二进制图像(使用zeros(height, width) 生成),分别具有 R、G 和 B 通道。现在我想将它们重叠在一起形成彩色图像。

使用什么命令可以生成重叠图像并同时应用不同的通道?

谢谢。

【问题讨论】:

    标签: matlab image-processing


    【解决方案1】:

    在 MATLAB 中,RGB 图像通过n3 数组保存为m,其中mn 是图像的高度和宽度。因此图像部分是:

    rgbImage(:,:,1) = redImage;
    rgbImage(:,:,2) = greenImage;
    rgbImage(:,:,3) = blueImage;
    

    当然,您应该首先预先分配图像以提高性能。您可以为此类数组做的一个技巧是通过

    创建它
    rgbImage(:,:,3) = blueImage;
    rgbImage(:,:,2) = greenImage;
    rgbImage(:,:,1) = redImage;
    

    这样,在第一步中分配了m by n by 3 数组,并且在接下来的步骤中不必扩展该数组。

    【讨论】:

      【解决方案2】:

      您还可以使用cat 将单通道图像连接成多通道(彩色)图像:

      rgbImage = cat(3, redImage, greenImage, blueImage);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-23
        • 2021-03-26
        • 2014-03-03
        • 1970-01-01
        • 2020-11-05
        • 1970-01-01
        • 2016-01-24
        • 1970-01-01
        相关资源
        最近更新 更多