# Bi-dimensional Discrete Cosine Transform¶

Overview and implementation of bi-dimensional discrete space cosine transform.

$O(n²)$ >> The running time is going to be quite long

## 1. Discrete space Cosine transform¶

Transforming from spatial to frequency domain using Discrete Cosine Transform, defined by:

$$\large X(\omega_1,\omega_2)=\lambda(\omega_1)\lambda(\omega_2)\sum_{n_1=0}^{N_1-1}\sum_{n_2=0}^{N_2-1}x(n_1,n_2) \cos\left(\pi\omega_1\frac{2 n_1+1}{2 N1}\right) \cos\left(\pi\omega_2\frac{2 n_2+1}{2 N2}\right)$$

where:

$$\large \lambda(\omega)= \begin{cases} \sqrt{\frac{1}{N}}, \text{ if } \omega=0\\ \sqrt{\frac{2}{N}}, \text{ otherwise} \end{cases}$$

## 2. Inverse discrete space Cosine transform¶

Transforming from frequency to spatial domain using Inverse Discrete Cosine Transform, defined by:

$$\large X(n_1,n_2)=\sum_{k_1=0}^{N_1-1}\sum_{k_2=0}^{N_2-1}\lambda(k_1)\lambda(k_2)x(k_1,k_2) \cos\left(\pi k_1\frac{2 n_1+1}{2 N1}\right) \cos\left(\pi k_2\frac{2 n_2+1}{2 N2}\right)$$

## 3. DCT Spectrum Filtering¶

In spite of DCT be mostly used for image compression, let's take a look at how it seems when we apply some filter on the DCT spectrum.

$$\large F(u,v)=H(u,v)X(u,v)$$

e.g.: Given the spatial-frequency filter $H$ as:

$$\large H(r,\theta)=e^{-\beta r^2}\left[\frac{cos(\gamma\theta)}{2}+\frac{1}{2}\right]$$