import cv2
import numpy as np
# 读取图像
image = cv2.imread('input.jpg')
# 将图像从BGR转换为HSV
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# 提取S通道
s_channel = hsv_image[:, :, 1]
# 对S通道进行过滤,例如使用高斯滤波器
filtered_s_channel = cv2.GaussianBlur(s_channel, (5, 5), 0)
# 将过滤后的S通道重新放入HSV图像中
filtered_hsv_image = np.copy(hsv_image)
filtered_hsv_image[:, :, 1] = filtered_s_channel
# 将图像从HSV转换回BGR
filtered_image = cv2.cvtColor(filtered_hsv_image, cv2.COLOR_HSV2BGR)
# 保存处理过的图像到磁盘上
cv2.imwrite('output.jpg', filtered_image)
在opencv中对s通道进行过滤并保存图片
最新推荐文章于 2024-05-01 16:25:51 发布