发布时间:2021-09-02 22:28:26编辑:run阅读(5040)
高斯差分(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低通滤波器
47604
45983
36909
34467
29079
25713
24565
19714
19245
17756
5564°
6155°
5690°
5737°
6703°
5482°
5484°
5988°
5965°
7295°