彩色图像通道拆分与合并
- 待处理图像 ML.jpg
1. 使用 opencv
import cv2
import matplotlib.pyplot as plt
import numpy as np
# 读取图像
# 读取图像
image = cv2.imread('ML.jpg')
plt.imshow(image)
print(type(image)) # 输出:<class 'numpy.ndarray'>
print(image.shape) # 输出:(152, 150, 3)
b,g,r = cv2.split(image)
print(b.shape,g.shape,r.shape) # 输出:(152, 150) (152, 150) (152, 150)
# 使用matplotlib显示拆分后的通道
plt.figure(figsize=(12, 4))
plt.subplot(1,3,1),plt.imshow(b,cmap='gray'),plt.title('Blue Channel')
plt.subplot(1