opencv 通道分离合并



import matplotlib.pyplot as plot
def show_data(r,g,b,a,img):
    fig = plot.figure()
    ax = fig.add_subplot(321)
    ax.imshow(r, cmap='Greys_r')
    ax2 = fig.add_subplot(322)
    ax2.imshow(g)
    a3 = fig.add_subplot(323)
    a3.imshow(b)
    a4 = fig.add_subplot(324)
    a4.imshow(a)
    a4 = fig.add_subplot(325)
    a4.imshow(img)
    plot.show()

# img_file2 = io.imread('tpl_324.png')#skimage读图片
# show_data(img_file2)

img=cv2.imread("tpl_1.png",-1)

b,g,r,a = cv2.split(img)
img2 = cv2.merge([b,g,r,a])

show_data(r,g,b,a,img2)

cv2.imshow("1",r)
cv2.imshow("2",g)
cv2.imshow("3",b)
cv2.imshow("4",a)
cv2.waitKey()

你可能感兴趣的:(python,opencv基础)