二维傅立叶变换:FFT 与傅立叶光学

2d Fourier Transforms: FFT vs Fourier Optics

我正在尝试使用编程来增加我对傅立叶光学的理解。我知道在物理和数学上傅里叶变换的傅里叶变换是反转的 -> F{F{f(x)} = f(-x)。我有两个问题 1) 除了简单的高斯情况(这使它更加混乱)和 2 之外,第二个变换与原始函数没有任何相似之处) 似乎有一些缩放因子需要我“放大”并将转换后的图像扭曲到一点帮助不大的程度(如下图所示)。 **根据@Cris Luengo

的建议编辑

#%% Playing with 2d Fouier Transform

import numpy as np
from scipy import fftpack
import matplotlib.pyplot as plt
import LightPipes

wavelength = 792*nm
size = 15*mm
N = 600
w0=3*mm

# Fields
sq = np.zeros([100,100])
sq[25:75, 25:75] = 1
F=Begin(size,wavelength,N)
I0 = Intensity(0,GaussBeam(F, w0, LG=True, n=0, m=0))
I1 = Intensity(0,GaussBeam(F, w0, LG=False, n=0, m=1))+Intensity(0,GaussBeam(F, w0, LG=False, n=1, m=0))

# Plot transforms
f = sq
F = np.fft.fftshift(fftpack.fft2(f))
F_F = fftpack.fft2((F))

plt.subplot(331), plt.imshow(f)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(332), plt.imshow(np.abs(F))
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(333), plt.imshow(np.abs(F_F))
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

# plt.subplot(331), plt.imshow(f)
# plt.title(r'f'), plt.xticks([]), plt.yticks([])
# plt.subplot(332), plt.imshow(np.abs(F))
# plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
# plt.subplot(333), plt.imshow(np.abs(F_F))
# plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

f = I0
F = np.fft.fftshift(fftpack.fft2(f))
F_F = fftpack.fft2((F))

plt.subplot(334), plt.imshow(f)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(335), plt.imshow(np.abs(F))
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(336), plt.imshow(np.abs(F_F))
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

f = I1
F = fftpack.fft2(f)
F_F = fftpack.fft2(F)

plt.subplot(337), plt.imshow(f)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(338), plt.imshow(np.abs(F))
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(339), plt.imshow(np.abs(F_F))
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

plt.tight_layout()
plt.show()

和Cris聊过后,好像没有比例因子,这种DFT好像就是这样。所以我找到的解决方案是将像素增加到可以放大并获得足够清晰图像的程度。这不是一个很好的解决方案,但与 LightPipes 搭配使用,现在可以了解光模式的变换是什么样子,并说明它们在镜头系统的图像平面上的外观在前焦场做了。

#%% Playing with 2d Fourier Transform

import numpy as np
import matplotlib.pyplot as plt
import LightPipes
from scipy.fftpack import fft2 as fft
from numpy.fft import fftshift, ifftshift

wavelength = 792*nm
size = 100*mm
N = 1000
w0=3*mm

# Fields
sq = np.zeros([100,100])
sq[25:75, 25:75] = 1
F=Begin(size,wavelength,N)
I0 = Intensity(0,GaussBeam(F, w0, LG=True, n=0, m=0))
I1 = Intensity(0,GaussBeam(F, w0, LG=False, n=0, m=1))+Intensity(0,GaussBeam(F, w0, LG=False, n=1, m=0))

# Plot transforms
f = sq
F = fftshift(fft(ifftshift(f)))
F_F = fftshift(fft(ifftshift(F)))

plt.subplot(331), plt.imshow(f,cmap = cmap)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(332), plt.imshow(np.abs(F),cmap = cmap)
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(333), plt.imshow(np.abs(F_F),cmap = cmap)
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

f = I0
F = fftshift(fft(ifftshift(f)))
F_F = fftshift(fft(ifftshift(F)))

plt.subplot(334), plt.imshow(f[450:550,450:550],cmap = cmap)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(335), plt.imshow(np.abs(F)[450:550,450:550],cmap = cmap)
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(336), plt.imshow(np.abs(F_F)[450:550,450:550],cmap = cmap)
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

f = I1
F = fftshift(fft(ifftshift(f)))
F_F = fftshift(fft(ifftshift(F)))

plt.subplot(337), plt.imshow(f[450:550,450:550],cmap = cmap)
plt.title(r'f'), plt.xticks([]), plt.yticks([])
plt.subplot(338), plt.imshow(np.abs(F)[450:550,450:550],cmap = cmap)
plt.title(r'F\{f\}'), plt.xticks([]), plt.yticks([])
plt.subplot(339), plt.imshow(np.abs(F_F)[450:550,450:550],cmap = cmap)
plt.title('F\{F\{f\}\}'), plt.xticks([]), plt.yticks([])

plt.tight_layout()
plt.show()