import cv2 as cv
import matplotlib.pyplot as plt
# 1图像读取
img = cv.imread('./image/pic1.jpg')
# 2均值滤波
blur = cv.blur(img, (5, 5))
# 3图像显示
plt.rc("font", family='Microsoft YaHei')
plt.figure(figsize=(10, 8), dpi=100)
plt.subplot(121), plt.imshow(img[:, :, ::-1]), plt.title('原图')
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(blur[:, :, ::-1]), plt.title('均值滤波后结果')
plt.xticks([]), plt.yticks([])
plt.show()
# 1图像读取
img = cv.imread('./image/pic2.jpg')
# 2高斯滤波
blur = cv.GaussianBlur(img, (3, 3), 1)
# 3图像显示
plt.figure(figsize=(10, 8), dpi=100)
plt.subplot(121), plt.imshow(img[:, :, ::-1]), plt.title('原图')
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(blur[:, :, ::-1]), plt.title('高斯滤波后结果')
plt.xticks([]), plt.yticks([])
plt.show()
# 1图像读取
img = cv.imread('./image/pic2.jpg')
# 2中值滤波
blur = cv.medianBlur(img, 5)
# 3图像展示
plt.figure(figsize=(10, 8), dpi=100)
plt.subplot(121), plt.imshow(img[:, :, ::-1]), plt.title('原图')
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(blur[:, :, ::-1]), plt.title('中值滤波后结果')
plt.xticks(), plt.yticks()
plt.show()
THE END
暂无评论内容