首页 > 解决方案 > 傅里叶逆变换不给出初始图像

问题描述

我的目标是在傅里叶变换图像上绘制一个黑色矩形并应用傅里叶逆变换。问题在于从幅度和相位构建图像。即使在进行任何更改之前,我仍然没有得到初始图像。

# 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)

标签: pythonimage-processingfft

解决方案


推荐阅读