spatial filtering techniques

36
Spatial Filtering Techniques

Upload: rraghu

Post on 16-Apr-2015

63 views

Category:

Documents


9 download

TRANSCRIPT

Page 1: Spatial Filtering Techniques

Spatial Filtering Techniques

Page 2: Spatial Filtering Techniques

Spatial filtering

The use of a spatial mark for image processing is called spatial filtering.

Two types of spatial filtering (i) Linear filters, (ii) Non linear filters.

(i) Linear Spatial Filter:– Linear filter means that the transfer function and the impulse or point spread

function of a linear system are inverse Fourier transforms of each other. 

Three types of linear filters are,– (a) Lowpass filter.– (b) Highpass filters, and– (c) Bandpass filter.

Page 3: Spatial Filtering Techniques

Spatial Linear Filters

(a)Lowpass filter:– It attenuates or eliminates high frequency components in the Fourier domain.

High frequency components characterize edges and others sharp details in an

image, so the low pass filter causes image blurring. 

(b) Highpass filters: – It attenuates or eliminates low frequency components. These components are

responsible for slowly varying characteristics of an image, such as overall

contrast and average intensity. 

(c) Bandpass filter: – It removes selected frequency regions between low and high frequencies. It is

used for image restoration.

Page 4: Spatial Filtering Techniques

Frequency Domain 

Fig.A. Frequency domain filters. • Fig represents the cross sections of circularly symmetric lowpass,

highpass and bandpass filters in the frequency domain and their corresponding spatial filters are shown below in fig. B

Page 5: Spatial Filtering Techniques

Spatial Domain

 

Fig. B Spatial domain filter.  The linear mask is the sum of the products between the mask coefficients

and the intensities of the pixels under the mask at a specific location in the image.

It is denoted by the gray levels of pixels under the mask at any location by Z1

Z2,…Z9. The response of a linear mask is

R=W1Z1 +W2Z2+ … +W9Z9

3 x3 mask coefficient is

Spatial Domain Filter

W1 W2 W3

W4 W5 W6

W7 W8 W9

Page 6: Spatial Filtering Techniques

This filter is based directly on the values of the pixels in the neighborhood and they did not use coefficients. 

Using nonlinear filter noise reduction can be achieved effectively.

The basic function of the nonlinear filter is to compute the median gray level value in the neighborhood in which the filter is located.

Other examples of nonlinear filters are max and min filter.

Max filter is used to find the brightest points in an image. Min filter is the opposite of max filter.

Spatial Nonlinear Filters

Page 7: Spatial Filtering Techniques

Smoothing Filters

Smoothing filters are used for blurring and noise reduction.

Blurring is used in preprocessing steps, such as removal of small details from large image and bridging of small gaps in lines and curves.

Noise reduction can be achieved by blurring with a linear filter and by nonlinear filter.

Page 8: Spatial Filtering Techniques

Types of Smoothing Filters

Lowpass Spatial Filtering Median Filtering Directional Smoothing

Lowpass Spatial Filtering

It shows that, the LP spatial filter have all positive coefficients. From this equation, R=W1Z1 +W2Z2+ … +W9Z9

Page 9: Spatial Filtering Techniques

Continue... The response will be the sum of gray levels of nine pixels which

could cause R to be out of the valid gray level range. Therefore the solution is to scale the sum by dividing R by 9. Generally, the response R would simply be the average of all the

pixels in the area of mask. Spatial lowpass filters of various sizes are shown in fig.

– 1/9 x 1/25 x

(a)

(b)

It is referred to as neighborhood averaging.

1 1 1

1 1 1

1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

Page 10: Spatial Filtering Techniques

Example – Averaging Filter

Page 11: Spatial Filtering Techniques

Example – Averaging Filter...

Page 12: Spatial Filtering Techniques

Example – Averaging Filter...

Page 13: Spatial Filtering Techniques

Example – Averaging Filter...

Page 14: Spatial Filtering Techniques

Median FilteringMedian filters are are statistical non linear filters are often described in spatial domain. A median filter smoothens the image by utilising the mediun of the neighbourhood. This concept was first introduced by Tukey in 1997. It’s extension into 2 dimension was first discussed by Pratt in 1978. The median Filter performs the following tasks to find each pixl value in the processed image.

1. All Pixels in the neighbourhood of pixel in the original image which are identified by the mask are stored in the asecnding or descending order.

2. The median of stored value is computed and is chosen as the pixel value for the processed image.

Page 15: Spatial Filtering Techniques

Median Filtering example

Page 16: Spatial Filtering Techniques

Effect of Median Filtering

Page 17: Spatial Filtering Techniques

Direction Smoothing

A directional averaging filter is used to protect the edges from blurring while smoothing.

Spatial averages V(m, n: θ) are calculated in various directions. Its equation is given below.

The direction θ* at which ׀ y(m, n) – V(m, n: θ*)׀ is minimum is noted. V(m, n) = V(m, n: θ*) can give the desired result.

Page 18: Spatial Filtering Techniques

Sharpening Filters Sharpening is used to highlight fine detail in an image.

Highpass Spatial Filtering

High-Boost Filtering

Derivative Filters

Highpass Spatial Filtering This highpass spatial filter indicates that, the impulse response of the filter should

have positive coefficients near its center and negative coefficients in the outer periphery.

For example consider, 3 x 3 mask

1/9 x

A highpass spatial filter Here, sum of coefficients is ‘0’. Thus, when the mask is over an area of constant

or slowly varying gray level, the output of the mask is zero or very small.

-1 -1 -1

-1 8 -1

-1 -1 -1

Page 19: Spatial Filtering Techniques

Continue...

Reducing the average value of an image to zero implies that the image must have some negative gray levels.

If we use positive gray levels, the result of highpass filtering involve some form of scaling or clipping, so the gray levels range of [0, L - 1] is used.

Therefore," positive values are not good. Negative value is better.

Page 20: Spatial Filtering Techniques

High-Boost Filtering To obtain the better result, rather than highpass spatial filtering, we use high-boost filtering.

The highpass filter image is Highpass = Original image - Lowpass filter image.

The definition of a high-boost or high-frequency emphasis filter is given by multiplying the original image by an amplification factor denoted by ‘A’.

Highboost = (A) (Original image) - Lowpass filter image = (A - l) (original image) + original image - Lowpass filter image. = (A - l) (original) + Highpass filter image.

When A = 1, It gives the standard highpass result.When A > 1, It gives the highboost image which looks more like

the original image.

Page 21: Spatial Filtering Techniques

High-Boost Filtering To obtain the better result, rather than highpass spatial filtering, we use high-boost filtering.

The highpass filter image is Highpass = Original image - Lowpass filter image.

The definition of a high-boost or high-frequency emphasis filter is given by multiplying the original image by an amplification factor denoted by ‘A’.

Highboost = (A) (Original image) - Lowpass filter image = (A - l) (original image) + original image - Lowpass filter image. = (A - l) (original) + Highpass filter image.

When A = 1, It gives the standard highpass result.When A > 1, It gives the highboost image which looks more like

the original image.

Page 22: Spatial Filtering Techniques

High-Boost Filtering To obtain the better result, rather than highpass spatial filtering, we use high-boost filtering.

The highpass filter image is Highpass = Original image - Lowpass filter image.

The definition of a high-boost or high-frequency emphasis filter is given by multiplying the original image by an amplification factor denoted by ‘A’.

Highboost = (A) (Original image) - Lowpass filter image = (A - l) (original image) + original image - Lowpass filter image. = (A - l) (original) + Highpass filter image.

When A = 1, It gives the standard highpass result.When A > 1, It gives the highboost image which looks more like

the original image.

Page 23: Spatial Filtering Techniques

High-Boost FilteringThe general process of subtracting a blurred image from an original is given below.

High = (A) (original) - Lowpass

This is known as “Unsharp masking".The center weight of the mask is

w = 9A - 1A≥ l which determines the nature of the filter. 

1/9 x

Mask for highboost spatial filter.

-1 -1 -1

-1 w -1

-1 -1 -1

Page 24: Spatial Filtering Techniques

Derivative FiltersAveraging of pixels produces blurred image.

Averaging is analogous to integration. But, differentiation produces the opposite effect i.e sharpen the image.

The most common method of differentiation in image processing applications is the "gradient".

For a function f(x. y), the gradient of at coordinates (x, y) is defined as the vector

The magnitude of this vector is

Page 25: Spatial Filtering Techniques

Derivative Filters

Z1 Z2 Z3

Z4 Z5 Z6

Z7 Z8 Z9

Page 26: Spatial Filtering Techniques

Derivative FiltersAnother method is to use cross differences in equation

---------3

---------4

Equation (1,2) and (3,4) can be implemented by using the masks of size 2 x 2.

For example, equation (4) can be implemented by taking the absolute value of the response of the two masks shown below, and summing the results. These masks are called “Roberts cross - gradient operators”.

If mask is 3 x 3, the neighborhood is

1 0

0 -1

0 1

-1 0

Page 27: Spatial Filtering Techniques

Derivative FiltersThe difference between the 3RD and 1st row of the 3 X 3 region approximates the derivative in the x direction and difference between the 3rd and 1st column approximates the derivative in the y direction called “prewitt operators” shown in fig. given below.

Prewitt operators

For approximating the magnitude of the gradient, another pair of masks can be used which are known as sobel operators.

Sobel operators

-1 -1 -1

0 0 0

1 1 1

-1 0 1

-1 0 1

-1 0 1

-1 0 1

-2 0 2

-1 0 1

-1 -2 -1

0 0 0

1 2 1

Page 28: Spatial Filtering Techniques

Laplacian FiltersLaplacian filter is used to enhance discontinuities.The laplacian of two dimensional image f(x, y) is defined as

For a 3 x 3 subimage, the digital form equivalent to the Laplacian operator is given as

From this equation, it is possible to define the digital laplacian mask. So, the co-efficient associated with center pixels should be positive and that associated with the outer pixels should be negative.

Moreover, the sum of the coefficients should be zero.The Laplacian response is sensitive to noise and is rarely used for edge detection. 

-1 0 1

-2 0 2

-1 0 1

-1 -2 -1

0 0 0

1 2 1

Page 29: Spatial Filtering Techniques

Laplacian FiltersMoreover, the sum of the coefficients should be zero.

The Laplacian response is sensitive to noise and is rarely used for edge detection.

The 3 x 3 Kernel is

 

(a) (b)

The mask is used to complete the laplacian.

-1 0 1

-2 0 2

-1 0 1

-1 -2 -1

0 0 0

1 2 1

Page 30: Spatial Filtering Techniques

Gaussian Filters

Page 31: Spatial Filtering Techniques

Gaussian Filters

Page 32: Spatial Filtering Techniques

Gaussian Filters

Page 33: Spatial Filtering Techniques

Gaussian Filters

Page 34: Spatial Filtering Techniques

Effect of Gausion Filtering

Page 35: Spatial Filtering Techniques

Reference Books

Digital Image Processing– S.Jayaraman– S.Esakkirajan– T.Veerakumar

Digital Image Processing – R C Gonzalez 

Page 36: Spatial Filtering Techniques

THANK YOU