OpenCV:图像的合并和切分

导包:

import numpy as np
import cv2
import matplotlib.pyplot as plt
def show(image):
    plt.imshow(image)
    plt.axis('off')
    plt.show()
def imread(image):
    image=cv2.imread(image)
    image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
    return image

打开图像:

image=imread('qwe.jpg')
image.shape
(R,G,B)=cv2.split(image)#将图像进行切分
print(R.shape)
print(G.shape)
print(B.shape)

输出:

(1729, 1080)
(1729, 1080)
(1729, 1080)
#现在开始图像的合并
merge=cv2.merge([R,G,B])
show(merge)
#分别显示三个通道当中的图片
cv2.imshow('R',R)#但是很遗憾我的服务器挂掉了,因为最开始我并没有后面这几句代码哈哈哈哈
cv2.waitKey(0)
cv2.destroyAllWindows()

 

posted @ 2019-06-26 18:29  Geeksongs  阅读(1548)  评论(0编辑  收藏  举报

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.