Fourier filtering, going back to an image

Viewed 329

I have a repeating fringe pattern on my data and I am trying to get it out by Fourier transforming it and deleting the pattern. However I can't seem to find the correct way back to image space.

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

taper is just an array that smooths the edges to get rid of the edge effects while doing an FFT. Then I FFT the array and filter out the gunk very roughly. However going back does not seem to work. Am I tripping up somewhere?

1 Answers

The problem arises on the following line:

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

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
Related