# 2D Fourier transform of Sobel kernel

Can someone explain me the highlighted text parts regarding this image ?

Here is a pseudo-code of how it was created:

kSobelX = zeros(100);
kSobelX(1:3,1:3) = [1,0,-1;2,0,-2;1,0,-1];
kSobelXfft = fft2(kSobelX);
clf; scale equal;
image(abs(kSobelXfft)/max(abs(kSobelXfft(:))));
print;


Pixels on the left of the square correspond to low frequencies along the x axis. Because the discrete Fourier transform is discrete in space, it's periodic in frequency: pixels on the right of the square correspond to low negative frequencies along the x axis. And because the spatial data is real, the frequency data is symmetric. The middle of the square correspond to the Nyquist frequency (half the sampling frequency). The regions at 1/4 and 3/4 positions correspond to the highest frequencies the filter operates at. Along the x axis, the light region means the Sobel filter is a highpass filter; along the y axis, the light regions are at low frequencies, i.e. the Sobel filter is a low-pass filter.

• One recommendation I would make is to perform fftshift on the transformed filter before displaying. i.e. replace your third line with kSobelXfft = fftshift(fft2(kSobelX)). This way, when you display the fourier transform, the image looks like what you would expect, with the zero frequency in the middle. Jan 2 '18 at 9:10

1. Because the discrete Fourier transform is discrete in space, it's periodic in frequency

Let's think of the Fourier Transform of a continuous, periodic function: FT explains the function as a projection of the signal onto a sum of sinusoidal basis functions, i.e. correlates the signal with a bunch of complex sinusoids, each with its own frequency. Thus, any data point contributes to a sinusoid with a particular frequency - data is encoded into the frequency. Thus FT becomes discrete. Now inverse also holds: If the space is discrete, one would require a periodic FT to represent that (non periodic signal on one domain causes continuous signal on the other).

I really like this animation showing the continuous FT.

Mathematically, it is always possible to show that for DFT, $X_K = X_{K+N}$ where $N$ is the period such as in here.

1. And because the spatial data is real, the frequency data is symmetric. The middle of the square correspond to the Nyquist frequency (half the sampling frequency).

I will greatly cite this stackexchange post and for completeness will include some shortened portion here:

Due to its definition, FT will generate symmetric responses for real data. Take the transform equation: $H(f) = \int h(t)e^{-j2\pi ft}dt$.

Using Euler's formula $e^{jx} = \cos(x) + j*\sin(x)$, we could modify the Fourier transform as follows: $$H(f) = \int h(t)(\cos(2\pi ft) - j\sin(2\pi ft))dt$$

FT for negative frequencies become: $$H(-f) = \int h(t)(\cos(2\pi (-f)t) - j\sin(2\pi (-f)t))dt \\ = \int h(t)(\cos(2\pi ft) + j\sin(2\pi ft))dt$$

Comparing the negative frequency version with the positive frequency version shows that the cosine is the same while the sine has phase inversion of $90^\circ$. Magnitude is the same. Due to this orthogonality, they will both respond to real signals in the same way.

Now for the Nyquist part:

The Nyquist frequency represents the highest frequency that can be represented by the sampling rate (differs from Nyquist rate). The DFT of a real series, i.e. zero imaginary part, results in a symmetric series about the Nyquist frequency - this is where the signal folds. In the image you have given, the mid-part is exactly about where the symmetry is created. This is also where the DC component lies.

I hope these bring in some clarification.

• Nice answer. A minor improvement would be to link more specifically to the Wikipedia page on DFT where the periodicity of DFT $X_K = X_{K+N}$ is shown: en.wikipedia.org/wiki/Discrete_Fourier_transform#Periodicity Jan 2 '18 at 9:45
• Wow! Thanks a lot for this awesome answer. Would you mind to explain the part with the "Nyquist frequency" a bit more in details in you answer ? I have understood the sampling theorem, but I don't understand why it should be found exactly in the middle of the image ? What do you mean by "the signal folds" ? Thanks a lot. Jan 2 '18 at 9:49
• @henry thanks for the input. done. Well james, I will now give a very vague intuition: Geometrically, this frequency is a locally maximal point. So it is a peak as shown in wiki page. Thus in all directions, frequency should decrease and naturally NF stands in the middle. Maybe there are some transformation taking it somewhere else, but the mirroring symmetry kind of dictates that there should be a point of reflection. Simplest is the middle. Jan 2 '18 at 12:54