仅幅度重建看起来不正确,我是否正确解释了这一点?

Magnitude only reconstruction doesn't look correct, am I interpreting this correctly?

我已经实现了 "Phase retrieval from the magnitude of the Fourier transforms of nonperiodic objects" 论文中的方法,网址为:https://pdfs.semanticscholar.org/4796/592751aaa5b316aaefbd5eab09ca51fad580.pdf

其中作者通过过采样重建对象,然后使用 HIO 迭代过程后的幅度。

阅读论文的图形部分指出:"Examples of image reconstruction from the magnitude of the Fourier transforms of complex-valued objects by oversampling;"

当我仅使用幅度进行重建时,我得到了看起来像空白图像的图像。我这样做正确吗?我是不是误解了论文的意思?

import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage as nd

img = nd.imread("einstein.bmp", flatten=True)

numIters = 500

# Pad image to simulate oversampling
initSize = img.shape
pad_len = 64
padded = np.pad(img, ((pad_len, pad_len), (pad_len, pad_len)), 'constant')

# Get initial magnitude
targetImg = np.fft.fftshift(np.fft.fft2(padded))
F_mag = np.abs(targetImg)
# Save for plotting later
startMag = np.abs(np.fft.ifft2(np.fft.ifftshift(F_mag)))
startPhase = np.angle(targetImg)

# keep track of where the image is vs the padding
mask = np.ones((initSize[0], initSize[1]))
mask = np.pad(mask, ((pad_len, pad_len), (pad_len, pad_len)), 'constant')

# Paper uses random phase for phase, adding noise here
noise = np.random.normal(0,1.5,(initSize[0], initSize[1]))
noise = np.pad(noise, ((pad_len, pad_len), (pad_len, pad_len)), 'constant')
source = F_mag * np.exp(1j * (startPhase + noise))

# Shift first then transform for inverse
imgWithNoise = np.abs(np.fft.ifft2(np.fft.ifftshift(source))) * mask
sourceImg = np.abs(np.fft.ifft2(np.fft.ifftshift(source))) * mask

# Test for proper image
# imgplot = plt.imshow(sourceImg)
# plt.show()

beta=0.8
for i in range(numIters):
    print "Progress on: " + str(i) + " Of " + str(numIters)
    G_k = np.fft.fftshift(np.fft.fft2(sourceImg))
    G_k_phase = np.angle(G_k)
    G_k_prime = F_mag * np.exp(1j*G_k_phase)
    g_k_prime = np.fft.ifft2(np.fft.ifftshift(G_k_prime))

    # In support i.e non negative real and imaginary
    real_g_k = np.real(g_k_prime)
    imag_g_k = np.imag(g_k_prime)
    # x_e_S = np.where(((real_g_k > 0) & (imag_g_k > 0)))
    x_e_notS = np.where(((real_g_k <= 0) & (imag_g_k <= 0) & (mask == 1)) | (mask == 0))

    tmp = g_k_prime
    beta_g_k_prime = beta * g_k_prime[x_e_notS]
    tmp[x_e_notS] = sourceImg[x_e_notS] - beta_g_k_prime
    sourceImg = tmp

G_k = np.fft.fftshift(np.fft.fft2(sourceImg))
finalMag = np.abs(G_k)
finalMagImg = np.abs(np.fft.ifft2(np.fft.ifftshift(finalMag)))

# Show magnitude plot
plt.subplot(231),plt.imshow(padded)
plt.title('Input Image'), plt.xticks([]), plt.yticks([])
plt.subplot(232),plt.imshow(np.abs(imgWithNoise))
plt.title('Image with Noise'), plt.xticks([]), plt.yticks([])
plt.subplot(233),plt.imshow(np.abs(sourceImg))
plt.title('Image after HIO'), plt.xticks([]), plt.yticks([])
plt.subplot(234),plt.imshow(startMag)
plt.title('Start Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
plt.subplot(235),plt.imshow(finalMagImg)
plt.title('End Magnitude Spectrum Img'), plt.xticks([]), plt.yticks([])
plt.subplot(236),plt.imshow(finalMag)
plt.title('End Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
plt.show()

你确实误解了这篇论文。他们仅使用幅度信息检索相位,这与仅使用幅度信息应用​​ IDFT 不同。

您的 FinalMagImg 不是空的,它的左上角有一个峰。应用 fftshift 将其移至中心,并应用对数映射以查看其余数据。如果相位全为零,这就是逆 DFT 的样子。