Professional Documents
Culture Documents
Image
Pixel z
2 4 1 2 6 2
9 2 3 4 4 4
7 2 9 7 6 7
5 2 3 6 1 5
7 4 2 5 1 2
2 5 2 3 2 8
Image
11/30/2019 24
Mean Filter
Pixel z
2 4 1 2 6 2
…
9 2 3 4 4 4 3 4 4
… …
7 2 9 7 6 7 9 7 6
5 2 3 6 1 5 3 6 1
7 4 2 5 1 2
…
2 5 2 3 2 8
11/30/2019 25
Mean Filter
Step 2. Multiply every pixel by 1/9 and then sum up the values
…
3 4 4
… …
9 7 6
1 1 1
3 6 1 y 3 4 4
9 9 9
1 1 1
…
9 7 6
X 9 9 9
1 1 1
1 1 1 Mask or 3 6 1
1 Window or
9 9 9
1 1 1
9 Template
11/30/2019
1 1 1 26
Mean Filter
5 2 3 6 1 5
7 4 2 5 1 2
Masking Window
11/30/2019 27
Mean Filter
Step 2: Compute
2 4 1 2 6 2 2 4 1
the average value
9 2 3 4 4 4 9 2 3
3 3
1
7 2 9 7 6 7 7 2 9 y p(i, j )
i 1 j 1 9
5 2 3 6 1 5 Sub image p
Mask frame
…
… …
p(2,1) p(2,2) p(3,2) w(1,2) w(2,2) w(3,2)
Mask coefficients
…
Subimage
N M
The reference point y w(i, j ) p(i, j )
of the mask
11/30/2019 i 1 j 1 30
Mean Filter
11/30/2019 31
• Weighted average filter
– In weighted average filter, more weight is given to
the center value. Due to this, the contribution of
center becomes more than the rest of the values.
Due to weighted average filtering, blurring can
actually be controlled.
– Properties of the weighted average filter are.
• It must be odd ordered
• The sum of all the elements should be 1
• The weight of center element should be more than all of
the other elements
• Comparison
– In the first picture, all the vertical edges are more visible than
the original image.
– In the second picture, all the horizontal edges are visible.
11/30/2019 Image filtering 45
• Sobel Operator
– Like Prewitt operator sobel operator is used to detect two
kinds of edges in an image:
• Vertical direction
• Horizontal direction
– The major difference is that in sobel operator the coefficients
of masks are not fixed and they can be adjusted according to
user requirement unless they do not violate any property of
derivative masks.
• Vertical Mask Horizontal Mask
-1 0 1 -1 -2 -1
-2 0 2 0 0 0
-1 0 1 1 2 1
11/30/2019 Image filtering 46
• Vertical Mask:-Works exactly same as the Prewitt operator
vertical mask.
• The difference, it has “2” and “-2” values in center of first and
third column.
• When applied on an image this mask highlights the vertical
edges.
• It works like as first order derivate and calculates the
difference of pixel intensities in a edge region
• The center column is of zero, thus does not include the
original values of an image but rather it calculates the
difference of right and left pixel values around that edge.
• The center values of both the first and third column is 2 and -2
respectively.
• This give more weight age to the pixel values around the edge
region.
• This increase the edge intensity and it become enhanced
comparatively to the original image.
11/30/2019 Image filtering 47
• Horizontal Mask:-Works exactly same as the Prewitt
operator horizontal mask.
• The difference, it has “2” and “-2” values in center of first
and third row.
• When applied on an image this mask highlights the vertical
edges.
• It works like as first order derivate and calculates the
difference of pixel intensities in a edge region
• The center column is of zero, thus does not include the
original values of an image but rather it calculates the
difference of above and below pixel values around that
edge.
• The center values of both the first and third rows is 2 and -2
respectively.
• This give more weight age to the pixel values around the
edge region.
• This increase the edge intensity and it become enhanced
comparatively to the original image.
11/30/2019 Image filtering 48
• Sample Image
– After applying vertical mask on
the image, following image is
obtained.
-All the vertical edges are more visible
than the original image.
– After applying vertical mask on
the image, following image is
obtained.
-All the horizontal edges are more visible
than the original image.
f
f ( x 1) f ( x)
x
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
11/30/2019 58
Second order derivative Spatial Filters: Laplace
Operator
The second-order isotropic derivative operator is the Laplacian for
a function (image) f(x,y)
f f 2 2
f 2 2
2
x y
2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
x 2
2 f
f ( x, y 1) f ( x, y 1) 2 f ( x, y )
y 2
2 f f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)
- 4 f ( x, y )
11/30/2019 59
Sharpening Spatial Filters: Laplace Operator
g ( x, y ) f ( x, y ) c 2 f ( x, y )
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c -1 if 2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c 1 if either of the other two filters is used.
11/30/2019 60
• Positive Laplacian Operator
– Positive Laplacian has a standard 0 1 0
mask in which center element of the
1 -4 1
mask should be negative and corner
elements of mask should be zero. 0 1 0
-Positive Laplacian Operator is used to take out outward edges
in an image.
• Negative Laplacian Operator
– Negative Laplacian operator also has a 0 -1 0
standard mask, in which center element
should be positive. All the elements in the
-1 4 -1
corner should be zero and rest of all the 0 -1 0
elements in the mask should be -1.
- Negative Laplacian operator is used to take out inward edges
in an image
11/30/2019 Image filtering 61
Sharpening Spatial Filters: Laplace Operator
11/30/2019 62
• Laplacian is a derivative operator; its uses highlight gray
level discontinuities in an image and try to deemphasize
regions with slowly varying gray levels.
• This operation produces images which have grayish edge
lines and other discontinuities on a dark background.
• This produces inward and outward edges in an image
• The important thing is how to apply these filters onto
image.
• Both positive and negative Laplacian operators can’t be
applied on the same image.
• When positive Laplacian operator is applied on the
image, the resultant image is subtracted from the original
image to get the sharpened image.
• When negative Laplacian operator is applied, the
resultant image is added onto original image to get the
sharpened image.
11/30/2019 Image filtering 63
• Sample Image After applying negative Laplacian
operator , the following image is
the output
2
P 2
P
Used for estimating image Laplacian P 2 2
2
x y
-1 -1 -1 0 -1 0
The center of the mask
-1 8 -1 -1 4 -1 is positive
-1 -1 -1 0 -1 0
or
1 1 1 0 1 0
The center of the mask
1 -8 1 1 -4 1 is negative
1 1 1 0 1 0
p
2 P
2 P P 2 P
11/30/2019 66
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Laplacian Sharpening (cont.)
Mask for
P P 2
0 -1 0 -1 -1 -1
-1 5 -1 or -1 9 -1
Mask for 0 -1 0 -1 -1 -1
2 P
1 1 1
1 -8 1
1 1 1
or
0 1 0
1 -4 1
0 1 0
11/30/2019 67
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Unsharp Masking and High-Boost Filtering
-1 -1 -1 0 -1 0
-1 k+8 -1 -1 k+4 -1
-1 -1 -1 0 -1 0
Equation:
11/30/2019 68
Unsharp Masking and High-Boost Filtering (cont.)
11/30/2019 69
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Unsharp Masking and Highboost Filtering
► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed) version
of an image from the original image
e.g., printing and publishing industry
► Steps
1. Blur the original image
11/30/2019 70
Unsharp Masking and Highboost Filtering
11/30/2019 71
Image Sharpening based on First-Order Derivatives
11/30/2019 72
Image Sharpening based on First-Order Derivatives
M ( x, y ) | g x | | g y |
z1 z2 z3
M ( x, y) | z8 z5 | | z6 z5 |
z4 z5 z6
z7 z8 z9
11/30/2019 73
Image Sharpening based on First-Order Derivatives
Sobel Operators
M ( x, y) | ( z7 2 z8 z9 ) ( z1 2 z2 z3 ) |
z1 z2 z3 | ( z3 2 z6 z9 ) ( z1 2 z4 z7 ) |
z4 z5 z6
z7 z8 z9
11/30/2019 74
Image Sharpening based on First-Order Derivatives
11/30/2019 75
Example
11/30/2019 76
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
11/30/2019 77
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
11/30/2019 78