python傅里叶变化双谱重构
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img=cv.imread(r"C:\Users\Administrator\Desktop\lena.bmp", 0)
f=np.fft.fft2(img)
f_shift=np.fft.fftshift(f)
res=np.log(np.abs(f_shift))
phase=np.log(np.angle(f_shift)180/np.pi)
restructure=np.fft.ifft2(np.exp(1j(np.angle(f))))
restructure=np.real(restructure)#因为重构恢复的信号含有虚部,故只取实部
plt.figure()
plt.subplot(221), plt.title(‘img1’), plt.imshow(img, ‘gray’)
plt.axis(‘off’)
plt.subplot(222), plt.title(‘am spectrum’), plt.imshow(res, ‘gray’)
plt.axis(‘off’)
plt.subplot(223), plt.title(‘phase spectrum’), plt.imshow(phase, ‘gray’)
plt.axis(‘off’)
plt.subplot(224), plt.title(‘restructure’), plt.imshow(restructure, ‘gray’)
plt.axis(‘off’)
plt.show()