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?
The Fourier Transform is an important image processing tool which is used to decompose an image into its sine and cosine components. The output of the transformation represents the image in the Fourier or frequency domain, while the input image is the spatial domain equivalent.
Likewise, we can derive the Inverse Fourier Transform (i.e., the synthesis equation) by starting with the synthesis equation for the Fourier Series (and multiply and divide by T). As T→∞, 1/T=ω0/2π. Since ω0 is very small (as T gets large, replace it by the quantity dω). As before, we write ω=nω0 and X(ω)=Tcn.
The Fourier transform is a reversible, linear transform with many important properties.
The Fourier transform is a representation of an image as a sum of complex exponentials of varying magnitudes, frequencies, and phases. The Fourier transform plays a critical role in a broad range of image processing applications, including enhancement, analysis, restoration, and compression.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With