【问题标题】:Get RGB channels from a list of arrays从数组列表中获取 RGB 通道
【发布时间】:2020-03-31 10:51:03
【问题描述】:

我有 RGB 图像列表,我想从列表中的图像中获取每个通道并对其进行整形。 但是,我在从数组列表中提取通道时遇到问题。

请参考以下代码;

difference[0].shape

输出;

(1280,720,3)

在我尝试的列表中的第一个图像中获取第一个通道widthheight

difference[0][0].shape

但我得到了答案; (720,3)width 和通道数。我想要得到的是(1280,720) 作为输出。

有人能帮我解决这个问题吗?

【问题讨论】:

    标签: python arrays python-3.x list numpy


    【解决方案1】:

    假设difference[0] 是一个形状为(1280,720,3) 的numpy 数组,您可以使用difference[0][:,:,0] 访问第一个维度的所有数据。

    difference[0][:,:,0].shape 会给你(1280, 720)

    difference[0][:,:,0].shape 会给你红色数据。
    difference[0][:,:,1].shape 会给你绿色数据。
    difference[0][:,:,2].shape 会给你蓝色数据。

    【讨论】:

      猜你喜欢
      • 2022-10-14
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      • 2011-06-12
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      相关资源
      最近更新 更多