---
tags: Digital Image Processing
disqus: hackmd
---
# Part 11
## Image Enhancement (contd.): Frequency Domain Processing Techniques
Until now, we have performed convolution of the mask on the original image. We also know that the same can be extended to the multiplication of the same two masks and images respectively but in the frequency domain.
\begin{equation}
f(x,y) * h(x,y) \iff F(u,v).H(u,v) \\ f(x,y).h(x,y) \iff F(u,v) * H(u,v)
\end{equation}
In this case, Gaussian Function is used quite frequently since they can be modelled easily in mask and their Fourier Transform and IFT are Gaussian too.
The Gaussian Function in frequency domain for 1D can be represented as,
\begin{equation}
H(u) = Ae^{-u^2/2\sigma^2}
\end{equation}
Where $\sigma$ is standard deviation. Its inverse can be written as,
\begin{equation}
h(x) = \sqrt{2\pi}Ae^{-2\pi^2 \sigma^2 x^2}
\end{equation}
It can be seen that both these functions are Gaussian and behave in reciprocal fashion. As $\sigma \to \infty$, $H(u)$ tends to be a flat function and $h(x)$ tends to be an impulse functions. So, more flat or more spread $h(x)$ is, the lesser frequency band is covered. So, this type of function can be used in lowpass filters.
Consider two filters,
\begin{equation}
\frac{1}{9}
\begin{bmatrix}
1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1
\end{bmatrix},
\frac{1}{16}
\begin{bmatrix}
1 & 2 & 1 \\ 2 & 4 & 2 \\ 1 & 2 & 1
\end{bmatrix}
\end{equation}
For the box filter, the frequency domain is becoming narrower, so, many components are attenuated. Also, since the flatter kernel requires a larger size, it means more attenuation will take place.
Similarly, in the case of the use of highpass filter,
\begin{equation}
H(u) = A(1 - e^{-u^2/2\sigma^2}) \\
h(x) = A(\delta(x) - \sqrt{2\pi}Ae^{-2\pi^2 \sigma^2 x^2})
\end{equation}
So, it attenuates low-frequency components. An example is a Laplacian mask.
In the spatial domain, we know that the mask can be applied by direct multiplication when both of them are in the frequency domain.
### Ideal Lowpass Filter
\begin{equation}
H(u,v) =
\begin{cases}
1, D(u,v) \leq D_0 \\ 0, D(u,v) > D_0
\end{cases}
\end{equation}
So, frequency components within the circle of radius $D_0$ are considered, whereas the rest of them are suppressed. So,
\begin{equation}
D(u,v) = \sqrt{\bigg(u - \frac{M}{2}\bigg)^2 + \bigg(v - \frac{N}{2}\bigg)^2}
\end{equation}
Where the image is of size $M \times N$. An approximation of such kind of filter is a Butterworth filter (since an ideal case might not be possible to be fabricated with electronic components, however, it can work for software).
### Butterworth Lowpass Filter
A Butterworth filter of order $n$ can be defined as
\begin{equation}
H(u,v) = \frac{1}{1 + \bigg[\frac{D(u,v)}{D_0}\bigg]^{2n}}
\end{equation}
![Uploading file..._tj2nd8ixw]()
Here, it is seen that ideal lowpass filters have some ringing effect present below the letters. This is because when the IFT is taken for the same, we get sinc function like,
![Uploading file..._0kk24uyyx]()
So, there is a main component, but there are other secondary components too. As $D_0$ is reduced, the spread increases, causing more blurring. At the same time, secondary characteristics also increase.
On the other hand, Butterworth lowpass filter does not produce a ringing effect for first order, however, for higher orders, it may produce.
### Gaussian Lowpass Filter
\begin{equation}
H(u,v) = e^{-D^2(u,v)/2D_0^2}, \sigma = D_0
\end{equation}
Since the IFT of the Gaussian filter is Gaussian, there is no ringing effect.
### Ideal Highpass Filter
Just as lowpass filters are for smoothing, highpass filters are for sharpening.
\begin{equation}
H(u,v) =
\begin{cases}
0, D(u,v) \leq D_0 \\ 1, D(u,v) > D_0
\end{cases}
\end{equation}
### Butterworth Highpass Filter
\begin{equation}
H(u,v) = \frac{1}{1 + \bigg[\frac{D_0}{D(u,v)}\bigg]^{2n}}
\end{equation}
### Gaussian Highpass Filter
\begin{equation}
H(u,v) = 1 - e^{-D^2(u,v)/2D_0^2}, \sigma = D_0
\end{equation}
In general, given the lowpass filter response $H_{LP}(u,v)$, we have $H_{HP}(u,v) = 1 - H_{LP}(u,v)$.
### Laplacian Highpass Filter
In case of Laplacian, the Fourier Transform can be shown as,
\begin{equation}
\mathscr{F}[\nabla^2 f] = -(u^2 + v^2)F(u,v)
\end{equation}
So, if we consider $H(u,v) = -(u^2 + v^2)$, then the output with this mask will yield in Laplacian operation.
### Highboost Filter
\begin{equation}
f_{hb}(x,y) = (A - 1)f(x,y) + f_{hp}(x,y)
\end{equation}
In frequency domain,
\begin{equation}
H_{hb}(u,v) = (A - 1) + H_{hp}(u,v)
\end{equation}
### Homomorphic Filter
From the discussions during initial lectures, we know that the image is a product of intensity values and reflectivity as,
\begin{equation}
f(x,y) = i(x,y).r(x,y)
\end{equation}
We define,
\begin{equation}
z(x,y) = \ln{f(x,y)} = \ln{i(x,y)} + \ln{r(x,y)}
\end{equation}
In frequency domain, it is,
\begin{equation}
Z(u,v) = F_i(u,v) + F_r(u,v)
\end{equation}
If $H(u,v)$ is applied to it, we get,
\begin{equation}
S(u,v) = H(u,v).Z(u,v) = H(u,v).F_i(u,v) + H(u,v).F_r(u,v)
\end{equation}
It's IFT implies,
\begin{equation}
s(x,y) = i'(u,v) + r'(u,v) \implies g(x,y) = e^{s(x,y)} = e^{i'(u,v) + r'(u,v)} = e^{i'(x,y)}e^{r'(x,y)} = i_0(x,y)r_0(x,y)
\end{equation}
So, we can design a filter to vary high and low-frequency content. In general, illumination leads to low-frequency components, whereas reflectance leads to high-frequency components.
![Uploading file..._d7afbps4t]()
So, $\gamma_H$ and $\gamma_L$ can be varied accordingly.