import cv2 import numpy as np img = cv2.imread('image.png') # 使用中值滤波去噪,核大小为3 dst = cv2.medianBlur(img, 3) cv2.imwrite('output.png', dst)