自适应中值滤波(支持不同窗口大小)
This commit is contained in:
parent
9acae91953
commit
a6d562984b
@ -7,17 +7,34 @@ from adaptive_median_filter import adaptive_median_filter
|
|||||||
#读取照片
|
#读取照片
|
||||||
image_saltandpep = cv2.imread("file/circuitboard-saltandpep.tif", cv2.IMREAD_GRAYSCALE)
|
image_saltandpep = cv2.imread("file/circuitboard-saltandpep.tif", cv2.IMREAD_GRAYSCALE)
|
||||||
|
|
||||||
# 自适应中值滤波
|
#设置窗口大小
|
||||||
image_saltandpep2 = adaptive_median_filter(image_saltandpep)
|
kernel_size_windows1 = 3
|
||||||
|
kernel_size_windows2 = 7
|
||||||
|
kernel_size_windows3 = 15
|
||||||
|
|
||||||
plt.subplot(1,2,1)
|
# 自适应中值滤波
|
||||||
|
image_saltandpep2 = adaptive_median_filter(image_saltandpep,kernel_size_windows1)
|
||||||
|
image_saltandpep3 = adaptive_median_filter(image_saltandpep,kernel_size_windows2)
|
||||||
|
image_saltandpep4 = adaptive_median_filter(image_saltandpep,kernel_size_windows3)
|
||||||
|
|
||||||
|
plt.subplot(2,2,1)
|
||||||
plt.imshow(image_saltandpep, cmap='gray')
|
plt.imshow(image_saltandpep, cmap='gray')
|
||||||
plt.title('3.胡椒噪声和盐噪声')
|
plt.title('3.胡椒噪声和盐噪声')
|
||||||
plt.axis('off')
|
plt.axis('off')
|
||||||
|
|
||||||
plt.subplot(1,2,2)
|
plt.subplot(2,2,2)
|
||||||
plt.imshow(image_saltandpep2, cmap='gray')
|
plt.imshow(image_saltandpep2, cmap='gray')
|
||||||
plt.title('3.自适应中值滤波_胡椒噪声和盐噪声')
|
plt.title('3.自适应中值滤波_胡椒噪声和盐噪声(窗口大小3)')
|
||||||
|
plt.axis('off')
|
||||||
|
|
||||||
|
plt.subplot(2,2,3)
|
||||||
|
plt.imshow(image_saltandpep3, cmap='gray')
|
||||||
|
plt.title('3.自适应中值滤波_胡椒噪声和盐噪声(窗口大小7)')
|
||||||
|
plt.axis('off')
|
||||||
|
|
||||||
|
plt.subplot(2,2,4)
|
||||||
|
plt.imshow(image_saltandpep4, cmap='gray')
|
||||||
|
plt.title('3.自适应中值滤波_胡椒噪声和盐噪声(窗口大小15)')
|
||||||
plt.axis('off')
|
plt.axis('off')
|
||||||
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user