共计 525 个字符,预计需要花费 2 分钟才能阅读完成。
PS:该实验过程或有错误,请谨慎参考
实验内容:彩色图像处理算法:提取一张彩色图像中红色,用 HIS 模型处理,RGB 模型对比显示
导入图像
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
img = cv.imread("1.png", 1)
img = cv.cvtColor(img, cv.COLOR_BGR2RGB)
plt.imshow(img)
HIS
hsi_img = cv.cvtColor(img, cv.COLOR_BGR2HSV_FULL)
h, s, i = cv.split(hsi_img)
i = np.zeros(i.shape, dtype=np.uint8)
# print(h)
s = np.zeros(s.shape, dtype=np.uint8)
hsi_img = cv.merge([h, s, i])
plt.imshow(hsi_img)
RGB
r, g, b = cv.split(img)
g = np.zeros(g.shape, dtype=np.uint8)
b = np.zeros(b.shape, dtype=np.uint8)
r_img = cv.merge((r, g, b))
plt.imshow(r_img)
正文完