2. 2
What are images?
•2D image f(x,y).
•x and y are spatial co-ordinates.
•Amplitude of f at any (x,y) is called intensity or
gray level of the image.
4. 4
•Result is a matrix of real numbers of size M*N.
•Each element in this array is called a pixel.
5. 5
OBJECTIVE
The principal objective of enhancement is to process
an images so that the result is more suitable than the
original image for a SPECIFIC application.
Category of image enhancement
• Spatial domain
• Frequency domain
6. 6
WHAT IS???
Spatial filtering (neighborhood processing) is defined by:
A neighborhood
An operation that is performed on the pixels inside
the neighborhood
7. 7
•Typically, the neighborhood is rectangular and its
size is much smaller than that of f(x , y)
e.g., 3x3 or 5x5
Neighborhood
8. 8
Neighborhood
•Coefficients of neighborhood is also called as filter,
mask, filter mask, kernel, template or window.
•Image size is M*N and filter mask size m*n.
•m=2a+1 and n=2b+1.
•a and b are non-negative integers.
9. 9
Assume the
origin of the
mask is the
center of the
mask.
for a 3 x 3 mask,
1 1
1 1
( , ) ( , ) ( , )
s t
g x y w s t f x s y t
10. 10
LINEAR V/S NON-LINEAR
A filtering method is linear when the output is
a weighted sum of the input pixels.
Methods that do not satisfy the above property
are called non-linear.
12. 12
Correlation:
•Process of passing the mask w by the image array f.
Convolution
•Often used in applications where we need to
measure the similarity between images or parts of
images
(e.g., pattern matching).
•Similar to correlation except that the mask is first
flipped both horizontally and vertically.
Note: if w(x,y) is symmetric, that is w(x,y)=w(-x,-y),
then convolution is equivalent to correlation!
13. 13
TOOL BOX IMPLEMENTATION
g = imfilter(f, w, filtering_mode, boundary_options,
size_options)
Common syntax
g = imfilter(f, w, ‘replicate’)
14. 14
How do we choose the elements of a
mask?
Typically, by sampling certain functions.
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
15. 15
Spatial filters : Smoothing ( low pass)
Use: for blurring and noise reduction.
How it works? The value of every pixel is replaced by the
average of the gray levels in the neighborhood.
Type of smoothing filters:
1. Standard average
2. Weighted average.
3. Median filter
Gaussian
16. 16
1 1 1
1 1 1
1 1 1
9
1
1 2 1
2 4 2
1 2 1
16
1
Standard average Weighted average
13090120110
200989491
100999190
90859682
Standard averaging filter:
(110 +120+90+91+94+98+90+91+99)/9 =883/9 = 98.1
Weighted averaging filter:
(110 +2 x 120+90+2 x 91+4 x 94+2 x 98+90+2 x 91+99)/16 =97.81
17. 17
Mask size determines the degree of smoothing and
loss of detail.
original 3x3 5x5 7x7
15x15 25x25
19. 19
Very effective for removing “salt and pepper” noise
(i.e., random occurrences of black and white pixels).
Averaging Median filtering
20. 20
Spatial filters : Sharpening ( high pass)
Use: for highlighting fine detail or enhancing
detail that has been blurred.
1st derivative
of Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Type of sharpening filters: