Fourier

Complex numbers and Fourier transformation.

Reference: Lecture from Jon Sporring

Complex Numbers

Complex numbers consist of a real and an imaginary part:

\[z = x + iy\]

The real part of $z$ is $Re(z) = x$, and the imaginary part of $z$ is $Im(z) = y$.

Complex numbers are sitting in the $x-y$ plane $\R^2$ where $x$ the real part gives you the $x$ coordinate and $y$ the imaginary part gives you the y coordinate.

image-20230220112925630

Now, if you think of complex numbers in this way, then vector addition is defined in the same way as if you were working in $\R^2$ with vectors $(x, y)$.

image-20230220113243128

Complex numbers have the same vector addition and scalar multiplication as vectors in $\mathbb{R}^2$:

Addition

\[(a + ib) + (c + id) = (a+c) + i(b+d)\]

Multiplication

\[i^2 = -1, i = \sqrt{-1}\] \[\begin{align*} (a + ib)(c + id) &= a(c+id) + ib(c+id) \\& = (ac+aid) + (ibc + i^2bd) \\&= ac - bd + i(ad + bc) \end{align*}\]

Complex conjugate

\[(a+ib)^* = a - ib\]

Length squared

\[(a + ib)^*(a + ib) = (a - ib)(a+ib) = a^2 + b^2\]

Division

\[\begin{align*}\frac{a + ib}{c + id} & = \frac{(a+ib)(c + id)^*}{(c+id)(c+id)^*} \\&= \frac{(a+ib)(c-id)}{c^2 + d^2} \\&= \frac{ac + bd + i(cb - ad)}{c^2 + d^2}\end{align*}\]

Alternative Form

We like to work with two different representations of complex numbers.

The first one is the one we just discussed where you think of your complex numbers as a two-dimensional vector for the x coordinate is the real part and the y coordinate is the imaginary part.

However, you can also think of complex numbers as being described by the arrow that points from the origin to the point that represents the complex number => Polar coordinates.

image-20230220135723979

This arrow has a length $r$, and the angle $\theta$. These two numbers, the length and the angle with the x-axis describe a complex number uniquely. We often write this on an exponential form $z = re^{i\theta} = r(\cos \theta, \sin\theta)$.

Euler’s formula

指数级
\[re^{i\theta} = r(\cos\theta + i\sin\theta)\]

We have the two equivalent representations $z = x + iy = re^{i\theta}$, where $x$ and $y$ are the coordinates of $z$. By the definition of the cosine, we have

\[x = r\cos \theta,\]

and by the definition of the sine, we have

\[y = r\sin \theta.\]

In particular, $r = 1$ gives rise to Euler’s formula

\[e^{i\theta} = \cos \theta + i \sin \theta\]

Multiplication of complex numbers

image-20230220140832445

Multiplication of complex numbers is easy in polar coordinates: $r_1e^{i\theta_1} \cdot r_2e^{i\theta_2}$

\[\begin{align*} r_1e^{i\theta_1} \cdot r_2e^{i\theta_2} & = r_1r_2e^{i\theta_1}e^{i\theta_2} \\ & = r_1r_2(\cos\theta_1 + i\sin\theta_1)(\cos\theta_2 + i\sin\theta_2) \\ & = r_1r_2(\cos\theta_1\cos\theta_2 - \sin\theta_1\sin\theta_2 + i(\sin\theta_1\cos\theta_2 + \cos\theta_1\sin\theta_2)) \\ & = r_1r_2(\cos(\theta_1 +\theta_2) + i\sin(\theta_1 + \theta_2)) \\ & = r_1r_2 e^{i(\theta_1 + \theta_2)} \end{align*}\]

In the last step, use the Euler formula to go back to the polar coordinate form.

In other words, the usual exponential algebra holds also for complex numbers.

Moreover, we get a geometric interpretation of the multiplication of complex numbers.

Fourier Transform and series

Basis

This is the mathematical trick if you want to express the basis for our signal transform.

You need to notice that

  1. through the exponential complex, the cosine and sine come in pairs and they have the same frequency.

  2. frequency is the inverse of the wavelength.

    It has a face that is a measure of how far it’s been shifted from its origin.

    But by the combination of this cosine and sine, we are explicitly modeling the frequency with $2\pi ux$ but implicitly modeling the face by how much is there of this cosine versus how much is there if this sine is in a particular signal. => Don’t show it here.

  3. I like to think of the frequency is by multiplying by $2\pi$, some others prefer to combine $2\pi u$ into $w$. This is just a scaling. It doesn’t matter but when we start to integrate, scaling matters they become constants in front of the integration as we’ve seen.

\[e^{-i2\pi ux} = \cos(2\pi ux) - i\sin(2\pi ux)\]

Transform

The key concept of a transform is that you can take a signal or an image and change it into one thing, or one thing and then change it back.

This is different than for example, projection. What you do with your camera when you take a picture of the room captures some information in the room, but you cannot reconstruct the room from your picture. You are shattering the person behind. So I only have partial information when I take a projected image.

A transformation is different, you can go back and you can go forward. You don't lose any information.

  1. In the continuous version (the transformation is this integral in the part of Transform), I take a function $f(x)$ and I multiplied by this cosine sine pair or the complex exponential. And up here, they are both $x$ and $u$.

    So it’s a complex exponential both in the original domain and the resulting domain. But we only integrate the $x$ away. This integral removes $x$, that’s the reason why only $u$ left here.

  2. The first one is typically called forward, while the second one is called backward. => Question of Perspective. Normally, we think of standing in the special $x$ domain going into the frequency domain $u$. But these are just names. You should notice that there’s a minus in the forward direction and a plus in the other.

\[\begin{align*} F(u) & = \int^{\infty}_{-\infty}f(x)e^{-i2\pi ux}dx \ (forward) \\ f(x) & = \int^{\infty}_{-\infty}F(u)e^{i2\pi xu}du \ (inverse) \end{align*}\]

You should also keep in mind that this is integral and not every function is integrable. So we are only talking about a subset of functions that have a Fourier transformation.

Series

The series are discrete versions of these transforms. Those are the ones that are with some signs down here.

\[\begin{align*} F(u) & =\frac{1}{N} \sum^{N-1}_{x = 0} f(x)e^{-i2\pi ux/N} \\ f(x) & =\frac{1}{N} \sum^{N-1}_{u = 0}F(u)e^{i2\pi xu/N} \end{align*}\]

All the discrete signals have Fourier series. All the ones that we get on a computer can be Fourier transformed.

However, if you’re modeling it as a continuous function, it might not be shown. I think most you will work with will have Fourier transform.

我的理解是,傅立叶变换是给连续可积的函数信号用的,而傅立叶系列,针对离散函数,大多数为我们的图像所用。

You should notice that it’s implied that $f(x)$ is a discrete sample signal, and there are $n$ points to it. For now, just imagine this as $N$ points that you’ve sampled, temperature, and the like. And what you can get out of it are $N$ values in the Fourier transform domain.

Then, we take the basis function and this becomes a matrix that you can multiply with your sample function $f(x)$. And as such all that’s going on here is a base change and it turns out that this base is invertible.

So that is the language of Fourier transformation.

Power spectrum, length, angle

There are some key derived functions that we use all the time.

Power / Power spectrum

We take the power spectrum is that we take the Fourier transform on each individual complex number. For every value $u$ coming out of this and we calculate the length squared. For example, by multiplying by the complex conjugator.

\[P(u) = |F(u)|^2\]

We also often talk about the length, and an angle => From the perspective of the vector.

\[len(u) = \sqrt{P(u)}, \ angle = \tan^{-1}\frac{Im(F(u))}{Re(F(u))}\]
对图像进行傅立叶变换,可以先将图片表示为一个复数序列,然后将其与一个复数矩阵(即旋转因子矩阵)进行乘积并求和,得到傅里叶变换的结果。
对图像进行傅里叶变换,可以将图像从空域(即图像本身)转换到频域。频域中的每个点表示了空域中对应位置的信号的频率成分和相位信息。对于二维傅里叶变换来说,这意味着将图像分解为一系列正弦和余弦波的和,每个波的频率、方向和强度不同,这些波组合起来就形成了原始图像。更具体地说,傅里叶变换将图像分解成不同频率分量的信号。图像中的低频分量通常包含了图像的大部分能量,而高频分量通常包含图像中的细节信息。因此,通过分析频域中的不同分量,可以得到图像的许多信息,例如图像的亮度、对比度、纹理等特征。通过傅里叶变换,可以对图像进行滤波、去噪、增强等操作。例如,可以将频域中的高频分量滤除,从而消除图像中的噪声。也可以对频域中的某些频率成分进行增强,从而突出图像中的某些特征。因此,傅里叶变换是图像处理中非常重要的工具之一。

Odd and even functions

Thinking of functions as a combination of even and odd turns out to be extremely useful in this context.

The property of an even function is that,

\[\epsilon(x) = \epsilon(-x)\]

If you look at the corresponding negative position, you have the same value.

While for the odd functions, just like the sine. It’s the same value but negative.

\[o(x) = - o(-x)\]

Maybe you haven’t thought of this, but all functions can be written as a combination of an odd function and an even function.

Any $f$:

\[f(x) = \epsilon(x) + o(x) \\ \begin{align*} \epsilon (x) &= \frac{1}{2}(f(x) + f(-x)) \\ o(x) & = \frac{1}{2}(f(x) - f(-x)) \end{align*}\]

But what about an even function times an odd function?

On the positive side of the axis, we have even one value and odd another value. These two values on the other side of the axis where the even is the same but the odd has a switch sign. So I add these two, I get $0$.

So, if I constantly pair the multiplication of an even and odd function and just add these two together, I always get $0$.

The key thing to realize here is that we are going to look at functions that we will multiply by an even and an odd function. => $\cos(2\pi ux) - i\sin(2\pi ux)$

Basis

\[F = \mathcal{F}(f) \\ f(x) \Join F(u) \\ (f * g)(x) = \int^{\infty}_{-\infty}f(\alpha)g(x - \alpha)d\alpha\]

Fourier transform

\[\begin{align*}\mathcal{F}\{\epsilon(x) + o(x) \} &= \int^\infty{-\infty}(\epsilon(x) + o(x))(\cos (2\pi ux) - i\sin(2\pi ux))dx \\ &= \int^\infty{-\infty}\epsilon(x)\cos(2\pi ux)dx - i\int^\infty{-\infty}o(x)\sin(2\pi ux)dx\end{align*}\]

Because both $f$ and the alternative way for exponential form one is (even and odd) and they get paired, the result still can be thought of as even and odd.

Consequences

image-20230220173311986

2D Fourier Transform and series

Basis

\[e^{-i 2\pi (ux+vy)} = e^{-i2\pi ux}e^{-i2\pi vy}\]

Transform

image-20230220183925257

Linear separable => You can transform on all rows and then do the other one.

Series

image-20230220183337122

Fourier series assumes periodicity

image-20230220184427442

We use this picture to do the Fourier transformation in the computer, and that is the Fourier series assumes the signal is periodic.

The impolication of that is when I do Fourier transformation of my image, the right-most pixel is the left-most pixel. So when you see the image, you should think of it as sort of wrapping around in both $x$ and $y$.

image-20230220184659721

Cosine noise has 2 peaks in the Fourier Domain

image-20230220185750686

In the left picture, I have two dots here and they are running on a circle. That means, I have changed my original image by adding a cosine function to it because when I add these two dots in my fourier domain, that’s the same as adding a cosine function in the real domain.

The right picture shows you some of these waves that the image is built up.

Or, if I have an image where there’s such a high frequency noise on it. It is very easy to remove. Because I fourier my image and set the corresponding frequencies to $0$, then, it goes away. You can’t see that you also remove the frequency from the original image as it is really neat. => Hence, this type of noise is very easy to remove.

Convolution Theorem

image-20230220191129169
image-20230220191215317

$\alpha$ is a new integration variable.

You want an image or a signal and then you have your kernel and you flip the kernel and then you move it around.

傅里叶变换和卷积的关系是密切的。傅里叶变换可以将一个信号从时域转换到频域,卷积则是一种在时域上对信号进行操作的方式。在频域中,卷积运算相当于两个信号的傅里叶变换相乘,然后再进行反傅里叶变换得到的结果。
具体来说,对于两个信号 $f(x)$ 和 $g(x)$ ,它们的卷积运算可以表示为:
\[(f * g)(x) = ∫f(y)g(x-y)dy\]
其中 $*$ 表示卷积运算,$y$ 是积分变量。将 $f(x)$ 和 $g(x)$ 分别进行傅里叶变换,得到它们在频域中的表示 $F(u)$ 和 $G(u)$ ,则有:
\[f(x) ⇔ F(u) \\ g(x) ⇔ G(u)\]
将上式代入卷积运算式中得到:
\[(f * g)(x) = F^{-1}(F(u)G(u))\] 其中$F^{-1}$ 表示傅里叶逆变换,$F(u)G(u)$ 表示 $F(u)$ 和 $G(u)$ 的点乘。因此,卷积运算可以看作是在频域中对信号进行点乘操作,然后再通过逆傅里叶变换将结果转换回时域。 由此可见,傅里叶变换和卷积是相互关联的。傅里叶变换可以将卷积运算转化为频域中的点乘运算,从而简化了卷积运算的处理过程。同时,在频域中对信号进行处理也可以更方便地实现。