import cv2

# 读入图像
img = cv2.imread("img.jpg")

# 分离
b, g, r = cv2.split(img)

# 合并
merged = cv2.merge([b, g, r])