傅里叶滤波,回到图像

Coo*_*rab 5 python filtering fft

我的数据上有重复的条纹图案,我试图通过傅立叶变换它并删除图案来将其取出。但是我似乎无法找到返回图像空间的正确方法。

red_cube_array = (cube_array - np.median(cube_array)) * taper

im_fft  = (fftpack.fft2(red_cube_array))
im_po   = fftpack.fftshift((np.conjugate(im_fft) * im_fft).real)

mask = np.empty_like(im_po[0])*0 + 1
mask[417:430, 410:421] = 0
mask[430:443, 438:450] = 0

im_po_mask = im_po * mask

im_ifft = fftpack.ifft2(fftpack.ifftshift(im_po_mask))
Run Code Online (Sandbox Code Playgroud)

taper只是一个在执行 FFT 时平滑边缘以消除边缘效应的数组。然后我对数组进行 FFT 并非常粗略地过滤掉垃圾。然而,回去似乎不起作用。我是不是在某个地方绊倒了?

Sle*_*Eye 4

The problem arises on the following line:

im_po = fftpack.fftshift((np.conjugate(im_fft) * im_fft).real)
Run Code Online (Sandbox Code Playgroud)

This essentially computes the magnitude of the signal (in the frequency-domain), throwing away the phase information. Without the phase information, the spatial-domain image cannot be uniquely reconstructed.

To resolve the problem simply apply the mask on the complex-valued frequency-domain im_fft data:

im_po = fftpack.fftshift(im_fft)

mask = np.empty_like(im_po[0])*0 + 1
mask[417:430, 410:421] = 0
mask[430:443, 438:450] = 0

im_po_mask = im_po * mask
Run Code Online (Sandbox Code Playgroud)