# Filters in spatial domain and frequency domains

**Introduction of Spatial domain filtering :**

Spatial Domain Filtering techniques are among the most widely used in Image Processing. Images are 2D functions f(x,y) in spatial coordinates (x,y) in an image plane. Each function describes how colours or grey values brightness or intensities which vary in space:

The term Spatial Domains refers to the grid of pixels that represent an image. In particular, the relative positions and the values of a local neighbourhood of pixels are important to Spatial Domain techniques. This is in contrast to the Histogram methods where pixels of values but not positions are important, and Frequency or spatial Domain methods.

The main idea behind Spatial Domains Filtering is to convolve a mask with the image.

The convolution f(u) * g(x − u)du

A convolving recipe of a function is as follows:

1. Take a mirror reflection of g(x) by flipping it around the vertical y-axis.

2. Translate to every position from the flipped g(x) on the horizontal x-axis.

3. At every translation of g(x) which is flipped, multiplies the two functions,

An alternative image representation is based on spatial frequencies of grey value or colour variations over that plane image. That dual representation with the help of a spectrum of different frequency components is completely equivalent to the representation conventional spatial ,the conversion of a 2D spatial function f(x,y) into 2D spectrum that is F(u,v) of the spatial frequencies and the reverse conversion of the latter into a representation of spatial f(x,y) are less loss, i.e. involve no loss in the information. This spectral representation simplifies image processing. In the images of Spatial Domain , an operation which is similar to convolution is based upon masks. A mask is a small sub image, often of size 3 × 3 pixels. Other common names for masks are: sub image , template, window, kernel, and structuring element.

To convolve a mask with an image:

1. Translate the mask to every image location.

• translate in both the vertical and horizontal directions

• it includes all the locations where centre pixel of mask intersects with any image pixel

• at the image borders, some mask elements will therefore fall outside of the image boundary,

so this must be accommodated somehow

2. At each translation, multiply the underlying image pixels with the overlying mask pixels, and

sum their values.

3. Replace the image pixel located at the mask centre with this summed value.

In the discrete domain, convolving of the image f(x, y) with mask w(s, t) is effectively smaller than f(x, y) to result in image g(x, y).

Masks are usually of odd size, so that they have a well-defined centre, and often m = n = 3. In addition to being symmetric, some masks are isotropic, for this they don’t favour any specific direction. In particular, to 90_ rotations isotropic masks are invariant.

**Fourier transform: **

The key idea of Fourier’s theory is periodic function, complex it is along that period, which can be exactly i.e. with no information loss represented as a weighted sum of simple sinusoidal. Ir-respectively of how irregular can be the image, it may be decomposed into sinusoidal components having each well-defined frequency. The sine and cosine functions for the decomposition are known as the basis functions of decomposition. The weighted sum of these basis functions is called a Fourier series ,where the weighting factors for each sine (an) and cosine (bn) function are the coefficients of Fourier , and the index n specifies the number of cycles of the sinusoidal which fit within one period that is L of the function f(x) is a dimensionless frequency of basis function. An 1D function with period L is represented by 2 infinite sequences of the coefficients.

**Spectra and filtering :**

Real, R(u,v), and imaginary, I(u,v) parts of the complex number F(u,v) is not informative ; more important representation is obtained by representing each complex coefficient F(u,v) with its magnitude, |F(u,v)|, and phase, φ(u,v) . If an array of complex coefficients is decomposed into an array of magnitudes and phases array , the magnitudes which corresponds to the amplitudes of the basis images in the Fourier representation. The array of magnitudes is called the amplitude spectrum of the image, as well as the array of phases is called the phase spectrum.

**Question answers:**

Q1: What is Spatial Domain Filtering ?

Ans: Spatial Domain Filtering techniques are among the most widely used in Image Processing. Images are 2D functions f(x,y) in spatial coordinates (x,y) in an image plane.

Q2: What are the convolving recipe of a functions?

Ans: A convolving recipe of a function is as follows:

1. Take a mirror reflection of g(x) by flipping it around the vertical y-axis.

2. Translate to every position from the flipped g(x) on the horizontal x-axis.

3. At every translation of g(x) which is flipped, multiplies the two functions.

Q3: What do you understand by Fourier’s theory?

Ans: The key idea of Fourier’s theory is periodic function, complex it is along that period, which can be exactly i.e. with no information loss represented as a weighted sum of simple sinusoidal. Ir-respectively of how irregular can be the image, it may be decomposed into sinusoidal components having each well-defined frequency. The sine and cosine functions for the decomposition are known as the basis functions of decomposition. The weighted sum of these basis functions is called a Fourier series .

Q4: What are the common names for masks ?

Ans: Other common names for masks are: sub image , template, window, kernel, and structuring element.

Q5: Which are known as basis functions of decomposition ?

Ans: The sine and cosine functions for the decomposition are known as the basis functions of decomposition.

This article gives the idea about Filters in spatial domain and frequency domains.Electronic filters are electronic circuits which perform signal processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both.

This post comprises of information related to filter and its types. These are the topics related to digital image processing. These topics are very much fruitful for the engineering students .