赞
踩
import cv2 as cv from matplotlib import pyplot as plt import numpy as np from scipy import ndimage from skimage import data, util, color import math img = cv.imread("111.jpg") img = np.double(cv.cvtColor(img, cv.COLOR_RGB2GRAY)) m, n = img.shape rL = 0.5 rH = 2 c =2 d0 = 20 A1 = np.log(img+1) FI = np.fft.fft2(A1) n1 = np.floor(m/2) n2 = np.floor(n/2) D = np.zeros((m, n)) H = np.zeros((m, n)) for i in range(m): for j in range(n): D[i, j] = ((i-n1)**2 + (j-n2)**2) H[i, j] = (rH-rL) * (np.exp(c * (-D[i, j] / (d0**2))))+rL A2 = np.fft.ifft2(H*FI) A3 = np.real(np.exp(A2)) plt.figure() plt.imshow(img, cmap='gray') plt.figure() plt.imshow(A3, cmap='gray') plt.show()
如果想了解更多物联网、智能家居项目知识,可以关注我的项目实战专栏。
或者关注公众号。
编写不易,感谢支持。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。