一、 仅噪声存在的空间滤波图像复原
-
当一幅图像中唯一存在的退化是噪声时,退化模型简化为
当仅存在加性随机噪声时,可以采用空间滤波方法来估计原图像 f ( x , y ) ,即对退化图像 g ( x , y ) 去除噪声。
- 空间滤波方法在《空间域图像滤波》中进行了详细介绍,本章简要讨论空间滤波的降噪性能。
二、几何均值滤波器(Geometric mean filter)
- 使用几何均值滤波器复原图像,复原图像
在点 ( x , y ) 的值是邻域中的像素的几何平均值:
- 几何均值滤波器实现的平滑与算术平均滤波器相当,但损失的图像细节更少。
三、例程
- 9.9:几何均值滤波器
import cv2
import numpy as np
from matplotlib import pyplot as plt
# 9.9: 几何均值滤波器 (Geometric mean filter)
img = cv2.imread(r"E:/OpenCV/Fig0507b.tif", 0) # flags=0 读取为灰度图像
img_h = img.shape[0]
img_w = img.shape[1]
# 算术平均滤波 (Arithmentic mean filter)
kSize = (3,3)
kernalMean = np.ones(kSize, np.float32) / (kSize[0]*kSize[1]) # 生成归一化盒式核
imgAriMean = cv2.filter2D(img, -1, kernalMean)
# 几何均值滤波器 (Geometric mean filter)
m, n = 3, 3
order = 1/(m*n)
kernalMean = np.ones((m,n), np.float32) # 生成盒式核
hPad = int((m-1) / 2)
wPad = int((n-1) / 2)
imgPad = np.pad(img.copy(), ((hPad, m-hPad-1), (wPad, n-wPad-1)), mode="edge")
imgGeoMean = img.copy()
for i in range(hPad, img_h + hPad):
for j in range(wPad, img_w + wPad):
prod = np.prod(imgPad[i-hPad:i+hPad+1, j-wPad:j+wPad+1]*1.0)
imgGeoMean[i-hPad][j-wPad] = np.power(prod, order)
plt.figure(figsize=(9, 6))
plt.subplot(131), plt.axis('off'), plt.title("Original")
plt.imshow(img, cmap='gray', vmin=0, vmax=255)
plt.subplot(132), plt.axis('off'), plt.title("Arithmentic mean filter")
plt.imshow(imgAriMean, cmap='gray', vmin=0, vmax=255)
plt.subplot(133), plt.axis('off'), plt.title("Geometric mean filter")
plt.imshow(imgGeoMean, cmap='gray', vmin=0, vmax=255)
plt.tight_layout()
plt.show()
四、资料
youcans_的博客:
https://blog.csdn.net/youcans/article/details/122834842











网友评论