python - 傅里叶逆变换不给出初始图像
问题描述
我的目标是在傅里叶变换图像上绘制一个黑色矩形并应用傅里叶逆变换。问题在于从幅度和相位构建图像。即使在进行任何更改之前,我仍然没有得到初始图像。
# Fourier Transform function
def compute_mag_phase(toBeTransfromed):
dft = np.fft.fft2(toBeTransfromed)
dft_shift = np.fft.fftshift(dft)
mag = np.abs(dft_shift)
ang = np.angle(dft_shift)
return mag, and
## reconstruction function
def reconstruct(mag,ang):
combined = np.multiply(mag, np.exp(1j*ang))
fftx = np.fft.ifftshift(combined)
ffty = np.fft.ifft2(fftx)
imgCombined = np.abs(ffty)
return imgCombined
mag , ph = compute_mag_phase(img)
mag = 20*np.log(mag)
mag = cv2.convertScaleAbs(mag)
final = reconstruct(mag,ph)
解决方案
推荐阅读
- docker - 无法拉取 docker tomcat 镜像
- javascript - Electron 退出而不发出 render-process-gone 事件
- python - seaborn 没有在定义的子图中绘制
- java - Java:递归函数不生成集合的幂集
- java - 设计和解决问题 - Spring Boot with Kafka Application
- ios - ios数据自动删除
- clojure - Clojure/leiningen 找不到依赖项
- html - 打开我的网站时不会加载css文件
- r - 从多列中仅获取值(非 0、非 NA)
- reactjs - 目标容器不是 DOM 元素。在用玩笑测试 ReactDOM.render 时