基于OpenCV+Python的均值滤波,高斯滤波,中值滤波,双边滤波

图像平滑可采用:
均值滤波,高斯滤波,
中值滤波,双边滤波
来达到我们想要的效果


import cv2
import numpy as np
import matplotlib.pyplot as plt

img=cv2.imread("G:\OpenCV\Project/11.jpg",cv2.CV_64F)
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# 均值滤波
img_mean = cv2.blur(img, (25,25))

# 高斯滤波
img_Gaussian = cv2.GaussianBlur(img,(15,15),5)

# 中值滤波
img_median = cv2.medianBlur(img, 25)

# 双边滤波
img_bilater = cv2.bilateralFilter(img,59,95,95)

cv2.imshow("Oirignal Trawing",img)
cv2.imshow("blur",img_mean)
cv2.imshow("GaussianBlur",img_Gaussian)
cv2.imshow("medianBlur",img_median)
cv2.imshow("bilateralFilter",img_bilater)

cv2.waitKey(0)
cv2.destroyAllWindows()

效果图:

你可能感兴趣的:(OpenCV学习)