Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fourier filtering, going back to an image

Tags:

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?

like image 364
Coolcrab Avatar asked Aug 27 '18 16:08

Coolcrab


People also ask

What does a Fourier transform do to an image?

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.

How do you reverse a Fourier transform?

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.

Is the Fourier transform reversible?

The Fourier transform is a reversible, linear transform with many important properties.

What is the Fourier transform of the Fourier transform of an image?

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.


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
like image 76
SleuthEye Avatar answered Oct 14 '22 00:10

SleuthEye