数字图像处理与Python实现-图像降噪-指数型低通滤波

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/wujuxKkoolerter/article/details/102733378

指数型低通滤波

指数型低通滤波器的传递函数如下:

H ( u , v ) = exp ( ln ( 1 / 2 ) ( D ( u , v ) / D 0 ) n ) H(u,v) = \exp(\ln(1/\sqrt{2})(D(u,v) / D_0)^n)

其中, D 0 D_0 是截止频率, n n 为阶数。当 D ( u , v ) = D 0 , n = 1 D(u,v) = D_0,n=1 时,H(u,v)降为最大值的 1 / 2 1/\sqrt{2} ,由于指数型低通滤波器具有比较平滑的过滤带,经此平滑后的图像没有振铃现象;指数型滤波器具有更快的衰减特性,处理图像比巴特沃斯更加模糊些。
在这里插入图片描述

Python实现的代码如下:

def index_low_pass_kernel(img,D0,n=1):
    r,c = img.shape[1],img.shape[0]
    u = np.arange(r)
    v = np.arange(c)
    u, v = np.meshgrid(u, v)
    low_pass = np.sqrt( (u-r/2)**2 + (v-c/2)**2 )

    low_pass = np.exp(np.log(1 / np.sqrt(2)) * ((low_pass / D0)**n))

    # low_pass = np.clip(low_pass,0,1)
    return low_pass

def index_low_pass_filter(src,D0=5,n=1):
    assert src.ndim == 2
    kernel = index_low_pass_kernel(src,D0,n)
    gray = np.float64(src)
    gray_fft = np.fft.fft2(gray)
    gray_fftshift = np.fft.fftshift(gray_fft)
    dst = np.zeros_like(gray_fftshift)
    dst_filtered = kernel * gray_fftshift
    dst_ifftshift = np.fft.ifftshift(dst_filtered)
    dst_ifft = np.fft.ifft2(dst_ifftshift)
    dst = np.abs(np.real(dst_ifft))
    dst = np.clip(dst,0,255)
    return np.uint8(dst)

程序运行结果如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wujuxKkoolerter/article/details/102733378