python - 从图像中提取单个帧

标签 python opencv python-2.7 numpy

我目前是 python 新手,我想从图像中分别提取 R、G 和 B 帧。

例如,存储我的图像的变量是img

我想知道什么;

如何制作Rimg = img (:,:,1) Gimg = img (:,:,2) Bimg = img (:,:,3) 当然,这些是 MATlab 伪代码,Rimg、Gimg 和 Bimg 只是变量。

最佳答案

Numpy 风格:

Bimg = img[:,:,0]
Gimg = img[:,:,1]
Rimg = img[:,:,2]

OpenCV 风格:

B,G,R = cv2.split(img)

关于python - 从图像中提取单个帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16448656/

相关文章:

python - 如何使用 Pandas 将csv转换为字典

Python 将字符串写入内存并使用其他 Python 程序读取内存

python - Django REST - @action 装饰器 "Unresolved reference ' Action '”

python - 如何制作 python-mysqldb 模板?

python-2.7 - 读取、处理和显示 .EXR 格式图像中的像素

opencv - 如何在 OpenCV 中找到直线的端点?

python - 无法使用 cv2.imread() 读取图像

python - 为 QLineEdit 中输入的部分文本添加语法突出显示

python - 使用 self.sender() 检查 PyQt QPushButton 是否被检查

python - pty多路复用器