24 lines
667 B
Python
24 lines
667 B
Python
import cv2
|
|
import matplotlib.pyplot as plt
|
|
plt.rcParams['font.sans-serif'] = ['simHei']
|
|
plt.rcParams['axes.unicode_minus'] = False
|
|
from adaptive_median_filter import adaptive_median_filter
|
|
|
|
#读取照片
|
|
image_saltandpep = cv2.imread("file/circuitboard-saltandpep.tif", cv2.IMREAD_GRAYSCALE)
|
|
|
|
# 自适应中值滤波
|
|
image_saltandpep2 = adaptive_median_filter(image_saltandpep)
|
|
|
|
plt.subplot(1,2,1)
|
|
plt.imshow(image_saltandpep, cmap='gray')
|
|
plt.title('3.胡椒噪声和盐噪声')
|
|
plt.axis('off')
|
|
|
|
plt.subplot(1,2,2)
|
|
plt.imshow(image_saltandpep2, cmap='gray')
|
|
plt.title('3.自适应中值滤波_胡椒噪声和盐噪声')
|
|
plt.axis('off')
|
|
|
|
plt.tight_layout()
|
|
plt.show() |