# signals – Custom Fourier frequency matrix gives wierd results

I am trying to play around with Fourier transform and there is something I do not understand.

What I think I understand:

• So when you transform your images to the frequency domain using np.fft.fft2 and np.fft.fftshift, the centre pixel represents the zero frequency. The further the pixel from the centre the higher frequency it represents.

• The resulting frequency image contains complex numbers that include phase and amplitude information.

So I try to create a custom frequency image and study the results. Consider the following code snippet.

import numpy as np

frequency = np.zeros((501,501), dtype=np.complex)
frequency[250,250+5] = 437500+0j
frequency[250,250-5] = -437500-0j
image1 = abs(np.fft.ifft2(np.fft.fftshift(frequency)))
image1 = np.uint8(image/np.max(image1)*255)

frequency = np.zeros((501,501), dtype=np.complex)
frequency[250,250+125] = 437500+0j
frequency[250,250-125] = -437500-0j
image2 = abs(np.fft.ifft2(np.fft.fftshift(frequency)))
image2 = np.uint8(image/np.max(image2)*255)

frequency = np.zeros((501,501), dtype=np.complex)
frequency[250,250+250] = 437500+0j
frequency[250,250-250] = -437500-0j
image3 = abs(np.fft.ifft2(np.fft.fftshift(frequency)))
image3 = np.uint8(image/np.max(image3)*255)

frequency = np.zeros((501,501), dtype=np.complex)
frequency[250,250+249] = 437500+0j
frequency[250,250-249] = -437500-0j
image3_5 = abs(np.fft.ifft2(np.fft.fftshift(frequency)))
image3_5 = np.uint8(image/np.max(image3_5)*255)


What I expect is that the first image will contain evenly but substantially spaced vertical sinusoids (which it does). I expect the same from the following two images but with more closely spaced sinusoids. The second image kind of does that but not the third.

What I do not understand:

• Why does the second image tend to be grayer towards the center? Should the amplitude of the sinusoide be constant?
• Why does the 3rd image contain very high frequency sinusoid?
• Why does the last image looks subtancially different from the 3rd one? In the frequeny image I just moved one pixel closer to the center.

Note that there is nothing specific about the value -437500-0j. Its imaginary part is 0 therefore the phase is 0. What remains is the real part which in this way becomes the magnitude of the complex vector and hance the amplitude.    