Professional Documents
Culture Documents
i=0
i=n-1
f
x-m+i, y-m-j
h
ij
j=0
j=n-1
i=0
i=n-1
1 1 1
1 1 1
1 1 1
9
1
Smoothing Examples: 55 Blur
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
25
1
Smoothing Examples: 99 Blur
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 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 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
81
1
Smoothing Examples: 1717 Blur
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 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 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 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 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 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 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 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 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 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
289
1
Image Smoothing Examples
Original Smoothed
Noise Suppression Example
Noise Suppression Example
Calculating the effective noise reduction
Example
Applying a 3 x 3
smoothing filter with
unit coefficients
results in a factor 3
reduction in the
noise.
g
xy
f
xy
9
9
g
f
g
f
9
P(f)
1
2
e
(f )
2
2
2
mean and standard deviation
,
Gaussian Distribution
f
P(f)
The Median Filter
Smoothing filters can be used to reduce the impact of the noise in an
image but also cause unwanted blurring. The larger the dimension
of the smoothing mask the greater the noise reduction factor but
also the greater the blurring.
Non-linear filters, such as the Median Filter, can to some degree
decouple these two effects but in a way which is hard to quantify.
133
133
140
147
152
154
163
164
171
The median filter would
replace the central value with
the median value contained
within the mask (or window)
region.
Suppression of Impulsive Noise
Smoothing Filter
Median Filter
Suppression of Impulsive Noise
6.2 Sharpening Filters
Smoothing Averaging Sharpening Differencing
In practice with discrete
variables differencing is
equivalent to differentiation
and both the 1
st
and 2
nd
differentials can be used to
mark the position in an
image where there are
rapid changes in gray level
(ie edges).
f (x) + f (x)
f (x) f (x)
f (x)
f (x)
f (x)
Continuous variables
The objective is to enhance the detail in the image by accentuating
edges and boundaries.
Types of Filters Used in Image Sharpening - I
Pairs of masks of various formats which give the vertical (a
xy
)
and horizontal (b
xy
) gradients:
(i) The Roberts Operators
(ii)
(iii) The Prewitt Operators
1 1
b
xy
=f
x,y+1
-f
xy
1
1
a
xy
=f
x+1,y
-f
xy
1 0 1
b
xy
=f
x,y+1
-f
x,y-1
1
0
1
a
xy
=f
x+1,y
-f
x-1,y
1 0 1
1 0 1
1 0 1
g
xy
= a
xy
2
+b
xy
2
or
g
xy
= a
xy
+ b
xy
Where the final
gradient image is
calculated as:
1 1 1
0 0 0
1 1 1
Image Sharpening Examples
Consider an image consisting of:
Applying the following filters gives:
(i)
(ii)
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 0 0 0 0 ..
0 0 0 0 0 0 0 ..
0 0 0 0 0 0 0 ..
0 0 0 0 0 0 0 ..
1 0 1
1 0 1
1 0 1
0 0 0 3 3 0 0 ..
0 0 0 3 3 0 0 ..
0 0 0 3 3 0 0 ..
0 0 0 3 3 0 0 ..
1 1 1
0 0 0
1 1 1
Calculating the Gradient Image
Lena
The Sobel Operators
Calculating the Gradient Image
1 2 1
0 0 0
1 2 1
1 0 1
2 0 2
1 0 1
Types of Filters Used in Image Sharpening - II
(i)
(ii)
(iii)
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
1 2 1
1
2
1
For discrete data :
f
x
'
f
x
-f
x-1
f
x
' '
f
x
'
-f
x-1
'
(f
x
-f
x-1
) (f
x-1
-f
x-2
)
= f
x
2f
x-1
+f
x-2
f
x-1
+2f
x
f
x+1
Masks which give the 2
nd
differential or Laplacian image
2f
xy
-f
x,y-1
-f
x,y+1
4f
xy
-
f
x-1,y
-f
x+1,y
-
f
x,y-1
-f
x,y+1
f
xy
0
255
-255
510
2 -1 -1
2
-1
-1
4 -1 -1
-1
-1
The 1-d and 2-d Laplacian Mask in Action
2f
xy
-f
x-1,y
-f
x+1,y
The Image Sharpening Process
In image sharpening the usual approach is to add the
derived gradient or Laplacian image to the original
image in a process known as high frequency emphasis.
Thus:
Final image = original image + gradient or Laplacian image
0 1 0
1 5 1
0 1 0
1 1 1
1 9 1
1 1 1
For the Laplacian case this can be achieved in one
step by modifying the 2-d mask to:
or
Image Sharpening Examples
Consider an image consisting of:
Applying the following filters gives:
(i)
(ii)
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 0 1 1 1 ..
0 0 0 -3 3 0 0 ..
0 0 0 -3 3 0 0 ..
0 0 0 -3 3 0 0 ..
0 0 0 -3 3 0 0 ..
0 0 0 -3 4 1 1 ..
0 0 0 -3 4 1 1 ..
0 0 0 -3 4 1 1 ..
0 0 0 -3 4 1 1 ..
1 1 1
1 9 1
1 1 1
1 1 1
1 8 1
1 1 1
Image Sharpening Examples
The Mathematical Process of Spatial Filtering
Consider the 1-d case of spatial filtering with an n element mask
(n odd), where m= (n-1)/2 and ignoring the normalization factor.
g
x
= h
i'
h
f
x+i'
(2)
g
x
= h
i''
h
f
x-i''
(3)
g
x
= h
x
h
f
(4)
g
x
= h
i
i=0
i=n-1
f
x-m+i
(1)
f
0
f
1
f
x
f
N-1
h
0
h
m
h
n-1
x
i
i'
i''
a
i'=i-m
i''=-i'
x-i' '
Equation 4 is the discrete version of
the CONVOLUTION INTEGRAL.
g(x)= f ( )h(x )d
Shorthand versions :
g(x) f (x) h(x)
g
x
f
x
h
x
SPATIAL FILTERING IS A
CONVOLUTION PROCESS
The Mathematical Process of Convolution
Practical Considerations
(i) Edge Errors
For an n x n mask there is a (n-1)/2 border to the new image where exact values
cannot be calculated. Solutions are:
(a) Reduce the dimensions of the new image (usually impractical)
(b) Calculate approximate values for the border pixels
(c) Compute the cyclic convolution (beyond our scope).
(ii) Separability
A 2-d mask is separable if the successive application of two 1-d masks gives the
equivalent result to the application of the 2-d mask.
For example, considered as matrices:
Therefore this smoothing mask is separable.
There are computational advantages if the mask is separable.
1 1 1
1 1 1
1 1 1
1 1 1
( )
1
1
1