发布时间:2021-09-02 22:28:26编辑:run阅读(4837)
高斯差分(Difference of Gaussian, DOG)核可用作一种带通滤波器(Band-Pass Filter,BPF),允许保留某一频段内的频率分量,而丢弃其余所有频率分量。DOG核可以与fftconvolve()一起实现带通滤波器。
from skimage import data, img_as_float import matplotlib.pylab as pylab import numpy as np from scipy import signal # 指定默认字体 pylab.rcParams['font.sans-serif'] = ['KaiTi'] # 解决保存图像是负号'-'显示为方块的问题 pylab.rcParams['axes.unicode_minus'] = False im = img_as_float(pylab.imread(r'D:\image_processing\image3\R-C.jpg')) pylab.figure() pylab.imshow(im) pylab.title('原始图像', size=15) pylab.axis('off') pylab.show() x = np.linspace(-10, 10, 15) kernel_ld = np.exp(-0.005*x**2) kernel_ld /= np.trapz(kernel_ld) gauss_kernell = kernel_ld[:, np.newaxis] * kernel_ld[np.newaxis, :] kernel_ld = np.exp(-5*x**2) kernel_ld /= np.trapz(kernel_ld) gauss_kernel2 = kernel_ld[:, np.newaxis] * kernel_ld[np.newaxis, :] DoGKernel = gauss_kernell[:,:,np.newaxis] - gauss_kernel2[:,:,np.newaxis] im = signal.fftconvolve(im, DoGKernel, mode='same') pylab.figure() pylab.imshow(np.clip(im, 0, 1)) pylab.title('应用高斯差分带通滤波器图', size=15) pylab.axis('off') pylab.show()
上一篇: python3-scipy低通滤波器
47357
45585
36640
34153
28850
25471
24314
19498
18966
17523
5347°
5941°
5436°
5525°
6418°
5256°
5256°
5768°
5738°
7034°