【问题标题】:How to Convert RGB imgage to NIR+RGB image? [closed]如何将 RGB 图像转换为 NIR+RGB 图像? [关闭]
【发布时间】:2021-12-15 06:05:24
【问题描述】:

是否可以将RGB图像转换为RGB+NIR图像?

【问题讨论】:

标签: python python-3.x numpy image-processing


【解决方案1】:

您可以像这样使用 OpenCV

import cv2

fourChannel = cv2.cvtColor(threeChannel, cv2.COLOR_RGB2RGBA)

或者您可以使用 Numpy 创建一个新的空通道,其大小和类型与原始通道相同,并将其堆叠到您的 3 通道图像上:

import numpy as np

newEmpty = np.zeros_like(threeChannel[...,0])
fourChannel = np.dstack((threeChannel, newEmpty))

【讨论】:

  • 您分享的第二种方法对我有用,至少我的代码接受了我从 3 通道转换为 4 通道的图像。您能解释一下您的方法中的第 4 个通道是什么吗?全部为零吗?
  • 是的,第四通道全为零。如果你想用那个值填充它,你可以添加 255。
  • 如果我想用任何其他浮点值或双倍的值填充新通道,我可以这样做吗?
  • 您可以使用fourChannel[..., 3] = 127 将新通道填充为127。
猜你喜欢
  • 1970-01-01
  • 2015-11-18
  • 2021-12-17
  • 1970-01-01
  • 2020-07-03
  • 2017-08-02
  • 2010-12-14
  • 1970-01-01
  • 2020-02-29
相关资源
最近更新 更多