import cv2 as cv
import numpy as np
def blur_demo(image):
dst = cv.blur(image, (1, 3))#,前后为xy轴模糊的程度
cv.imshow("blur_demo", dst)
src = cv.imread("D:/.......")
cv.namedWindow("input image",cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)
blur_demo(src)
cv.waitKey(0)
cv.destroyALLWindows()
import cv2 as cv
import numpy as np
def median_blur_demo(image):
dst = cv.medianBlur(image, 5)#5代表模糊的程度
cv.imshow("median_blur_demo", dst)
src = cv.imread("D:/.......")
cv.namedWindow("input image",cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)
median_blur_demo(src)
cv.waitKey(0)
cv.destroyALLWindows()
import cv2 as cv
import numpy as np
def custom_blur_demo(image):
#kernel = np.ones([5,5],np.float32)/25 均值
#kernel = np.ones([[0, -1, 0],[-1, 5, -1],[0, -1, 0]], np.float32) 锐化 加和等于1或0
dst = cv.filter2D(image,-1,kernel=kernel)
cv.imshow("median_blur_demo", dst)
src = cv.imread("D:/.......")
cv.namedWindow("input image",cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)
custom_blur_demo(src)
cv.waitKey(0)
cv.destroyALLWindows()
dst = cv.GaussianBlur(src, (5,5), 0)
cv.imshow("Gaussian Blur",dst)
区分好椒盐噪声与高斯噪声,椒盐噪声为黑白像素点,高斯噪声为不规律的像素点。