0% found this document useful (0 votes)
52 views36 pages

Spatial Filters For Image Enhancement

This document discusses spatial filtering techniques in digital image processing. It describes how spatial filters operate on neighborhoods of pixels to modify or enhance images. Specific techniques covered include blurring, sharpening, edge detection, and median filtering. Blurring involves averaging pixel values in a neighborhood to reduce noise. Sharpening enhances edges using filters like unsharp masking or high-boost filtering. Edge detection filters like Sobel, Roberts, and Prewitt are derived from the first or second derivative to find edges. Median filtering reduces noise by replacing each pixel value with the median of neighboring pixels.

Uploaded by

Anuradha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views36 pages

Spatial Filters For Image Enhancement

This document discusses spatial filtering techniques in digital image processing. It describes how spatial filters operate on neighborhoods of pixels to modify or enhance images. Specific techniques covered include blurring, sharpening, edge detection, and median filtering. Blurring involves averaging pixel values in a neighborhood to reduce noise. Sharpening enhances edges using filters like unsharp masking or high-boost filtering. Edge detection filters like Sobel, Roberts, and Prewitt are derived from the first or second derivative to find edges. Median filtering reduces noise by replacing each pixel value with the median of neighboring pixels.

Uploaded by

Anuradha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

By,

Dr. Anuradha Phadke,


ECE, MIT-WPU, Pune
Spatial Filtering

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering:

Operation on the set of ‘neighborhoods’ N(x,y) of


each pixel

6 8 (Operator: sum)
12 200

6 8 2 0 226
12 200 20 10

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Neighborhood of a pixel p at position x,y is a


set N(p) of pixels defined relative to p.

Example 1:
N(p) = {(x,y): |x-xP|=1, |y-yP| = 1}

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

More examples of neighbourhoods:

P P P

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

• Usually neighbourhoods are used which are


close to discs, since properties of the Euclidean
metric are often useful.

• The most prominent neighbourhoods are the 4-


Neighborhood & the 8-Neighborhood

P P

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

We will define spatial filters on the


8-Neighborhood and their bigger relevants.

P
P
P

N8

N24

N48

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Carryout

• Blurring / Smoothing
• Sharpening
• Edge Detection

• Using different coefficients

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Blurring / Smoothing
((Sometimes also referred to as averaging or lowpass-filtering)

Average the values of the center pixel and its neighbours:

Purpose:

• Reduction of ‘irrelevant’ details


• Noise reduction
• Reduction of ‘false contours’ (e.g. produced by zooming)

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Blurring / Smoothing

1 1 1

1 1 1 * 1/9

1 1 1

Apply this scheme


to every single pixel !
Anuradha Phadke, ECE, MIT, Pune
Spatial Filtering

Example 2:
Weighted average

1 2 1

2 4 2 * 1/16

1 2 1

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Basic idea:
Weigh the center point the highest, decrease
weight by distance to center.

The general formula for weighted average:

P = i ai ni / i ai

Constant value, depending on mask, not on image !


Anuradha Phadke, ECE, MIT, Pune
Spatial Filtering

Blurring using different


radii (=size of
neighborhood)

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

EDGE DETECTION

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

EDGE DETECTION

Purpose:

• Preprocessing
• Sharpening

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Motivation: Derivatives

z
Spatial Filtering

First and second order derivative

1. 1st order generally produces thicker edges


2. 2nd order shows stronger response to detail
3. 1st order generally response stronger to gray level step
4. 2nd order produce double (pos/neg) response at step change

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Definition of 1 dimensional discrete 1st order derivative:

dF/dX = f(x+1) – f(x)

The 2nd order derivative is the derivative of the 1st order


derivative…

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

The 2nd order derivative is the derivative of the 1st order


derivative…

F(x-1) F(x) F(x+1)

derive

F(x)-F(x-1) F(x+1)-F(x) F(x+2)-F(x+1)

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Different variants of the Laplacian

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Edges detected by the Laplacian can be used to sharpen


the image !

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering
Spatial Filtering

Sharpening can be done in 1 pass:

0 -1 0 0 0 0 0 -1 0
-1 4 -1 + 0 1 0 = -1 5 -1
0 -1 0 0 0 0 0 -1 0

LAPLACIAN Original Image Sharpened Image

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Unsharp Masking
and

High Boost Filtering

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Basic Idea (unsharp masking):

Subtract a BLURRED version of an image


from the image itself !

F
sharp =F–F blurred

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Variation: emphasize original image


(high-boost filtering):
F = a*F – F
sharp blurred , a>=1

0 -1 0 0 0 0 0 1 0

-1

0
a-1

-1
-1

0
= 0

0 0
a 0

0
- 1

0
1

1
1

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Different Examples of High-Boost Filters:

0 -1 0
a=1
-1 0 -1
0 -1 0
0 -1 0
a=6
-1 5 -1
0 -1 0 0 -1 0
-1 b-1 -1 a=b

0 -1 0
Laplacian + Image !
Anuradha Phadke, ECE, MIT, Pune
Spatial Filtering

Prewitt Operators

Gx Gy
-1 -1 -1 -1 0 1

0 0 0 -1 0 1

1 1 1 -1 0 1

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Sobel Operators

Gx Gy

-1 -2 -1 -1 0 1

0 0 0 -2 0 2

1 2 1 -1 0 1

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Roberts Operators

Gx Gy
-1 0 0 -1

0 1 1 0

Anuradha Phadke, ECE, MIT, Pune


a b c
d e
a) Original image
b) Laplacian of gaussian
c) Sobel
d) Robets
e) Perwitts

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

In practice, multiple filters


are combined to enhance
images

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

MEDIAN FILTERING

The median M of a set of values is such that


half the values in the set are less than (or
equal to) M, and half are greater (or equal
to) M.

1 2 3 3 4 5 6 6 6 7 8 9 9

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Most important properties of the


median:

• less sensible to noise than mean


• an element of the original set of
values
• needs sorting (O(n log(n))

Anuradha Phadke, ECE, MIT, Pune


Spatial Filtering

Median vs. Mean

Anuradha Phadke, ECE, MIT, Pune


 Gonzalez and Woods, "Digital Image
Processing", Pearson Education, 3rd edition

We like to acknowledge Gonzalez and Woods


for the Images / figures used in this
presentation.

Anuradha Phadke, ECE, MIT, Pune

You might also like