赞
踩
- import matplotlib.pyplot as plt
- import numpy as np
- import cv2
- from math import sqrt,pow
- def blpf(image,d):
- f = np.fft.fft2(image)
- fshift = np.fft.fftshift(f)
- transfor_matrix = np.zeros(image.shape)
- M = transfor_matrix.shape[0]
- N = transfor_matrix.shape[1]
- for u in range(M):
- for v in range(N):
-
- D = sqrt((u-M/2)**2+(v-N/2)**2)
-
- transfor_matrix[u,v]=1/(1+pow(D/d,16))
- new_img = np.abs(np.fft.ifft2(np.fft.ifftshift(fshift * transfor_matrix)))
- return new_img
- b_image = blpf(img,40)
- plt.subplot(133)
- plt.axis("off")
- plt.title("b")
- plt.imshow(b_image,cmap="gray")
- plt.show()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。