Spatial Filtering ppt1
Spatial Filtering ppt1
Background
Fundamental steps and Components of Digital
Image Processing
Image Sampling and Quantization: Basic concepts
in Sampling and Quantization
Representing Digital images, Spatial and intensity
resolution
Relationship between Pixels
Histogram Processing: Definition, Histogram
Equalization
Spatial Filtering
Generating Spatial, Filter Masks, Noise Model
Smoothing Spatial Filters: Linear filters – Mean filters
Non‐linear (Order Statistic filters): Median, Mode,
Max, Min filters,
Image Enhancement by Frequency Domain Methods:
Basic steps for Filtering in Frequency Domain
Frequency Domain low pass (Smoothing), High pass
(Sharpening)
Spatial Domain
(image plane) Frequency Domain
•Image Negative
•Log Transformation
•Powerlaw Transformation
•Contrast stretching
•Gray level Slicing
•Bit plane slicing
•Histogram Based Processing Techniques
• Histogram equalisation
By Prof. Datta Deshmukh
• Histogram specification
Spatial domain Image Enhancement
Image Enhancement
Spatial Domain
Frequency Domain
(image plane)
Neighbourhood
Point Processing
Processing
a1H(f1)
a1 f1 H a1H(f1)+a2H(f2)
f1 +
+ H f2 H
H(a1f1+f2a2) a2H(f2)
f2 a2
mask/kernel/template or window)
the values in a mask/filter (subimage) are W(0,-1) W(0,0) W(0,1)
It can be written as
1 1
g ( x, y ) w(s, t ) f ( x s, y t )
s 1 t 1
Averaging/Mean Median/Min/Max
95 90 85
* 1/9
1 1 1 99 98 98
1 1 1 95 90 85
Original Image Filter
Pixels
f(x,y)=(1/9)*(104+100+108+99+106+98+95+90+85)=98.33
By Prof. Datta Deshmukh
Averaging Filters: Equation form
a b
w(s, t ) f ( x s, y t )
g ( x, y ) s a s b
a b
w(s, t )
s a s b
1 1 1
(1/9) X 1 1 1 3 X 3 Averaging Mask
1 1 1
1 1 1 1 1
1 1 1 1 1
(1/25) X 1 1 1 1 1 Similarly we can have 5 X5 or 7 X 7 Masks
1 1 1 1 1
1 1 1
By Prof. Datta Deshmukh 1 1
Strange Things Happen At The Edges!
e e e
By Prof. Datta Deshmukh
y Image f (x, y)
Strange Things Happen At The Edges!
There are a few approaches to dealing with
missing edge pixels:
Omit missing pixels
Pad the image
Typically with either all white or all black pixels
Replicate border pixels
Origin x
Filtered Image:
Zero Padding
Original
Image
Filtered Image:
Replicate Edge Pixels
Strange Things Happen At The Edges!
Strange Things Happen At The Edges!
Example
10 10 10 10 10 10
1 1 1
10 10 10 10 10 10
(1/9) X 1 1 1
10 10 10 10 10 10
50 50 50 50 50 50 1 1 1
50 50 50 50 50 50
50 50 50 50 50 50
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
Resultant Image
By Prof. Datta Deshmukh
Example
10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
Resultant Image
10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 23.3 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 36.6 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 36.6 36.6 50
50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
Resultant Image
By Prof. Datta Deshmukh
Example
10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
10 10 10 10 10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50
Resultant Image
These kinds ofDatta
By Prof. averaging
Deshmukh filters are excellent when the image contains Gaussian
Noise
Image corrupted by Image after noise
Gaussian Noise reduction by averaging
filter
By Prof. Datta Deshmukh
Original image Noisy image (salt and Image after applying
pepper noise) averaging filter
0 1 0 1 2 1
(1/6) X 1 2 1 (1/16) X 2 4 2
0 1
By Prof. Datta Deshmukh
0 1 2 1
Disadvantages of Linear Filters....
Linear filters (Averaging filter) removes the
noise by blurring it but it also blurs the edges.
Bigger the mask more is blurring.
If image contain Salt and peeper noise
averaging filter blurs the noise but also blurs the
edges.
Because of this blurring, linear filters are
seldom used in practice for noise reduction.
TheBybest
Prof. Dattaexample
Deshmukh is Median Filter 52
Steps to perform Median Filtering
original
By Prof. Datta image
Deshmukh with noise 3x3 median filtered 54
Example
Before Filtering
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 250 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 250 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
By Prof. Datta Deshmukh
Median Filtering Example
After Filtering
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
By Prof. Datta Deshmukh
Function of Median Filtering
Original
Averaging
Filter
Median
Filter