图像模糊可以去除噪音。import cv2
import numpy as npimage = cv2.imread("dogcat1.jpg")
cv2.namedWindow("input image", cv2.WINDOW_AUTOSIZE)
cv2.imshow("input image", image)#均值模糊
dst = cv2.blur(image, (5, 5))
cv2.imshow("blur_demo", dst)#中值模糊
dst = cv2.medianBlur(image, 5)
cv2.imshow("median_blur_demo", dst)#自定义模糊
#kernel = np.ones([5, 5], np.float32)/25
kernel = np.array([[0, -1, 0],[-1, 5, -1],[0, -1, 0]], np.float32)
dst = cv2.filter2D(image, -1, kernel=kernel)
cv2.imshow("custom_blur_demo", dst)cv2.waitKey(0)
cv2.destroyAllWindows()