Lecture 3
Lecture 3
DS617
Image Processing
Lecture 3
Spatial Image Enhancement Methods
Enhancement methods in spatial domain can be reduced to the form:
g(x,y) = T[ f(x,y) ]
f(x,y) is the input image, g(x,y) is the output enhanced image and T is an
enhancement operator or function defined over a point, some local
neighbourhood mask centered around a point, or the image globally.
g(x,y)
g(x,y)
Spatial Mask (Local) Enhancement Methods
g(x,y) = T[ f(x,y) ]
• T is an enhancement operator or a function on just the neighbours of
the target pixel, f(x,y).
f(x,y) g(x,y)
Spatial Mask (Local) Enhancement Methods (2)
Neighborhood is mostly a rectangle of any size (odd-sized) around a
current central pixel of interest.
Spatial Mask (Local) Enhancement Methods (3)
• For each pixel in the origin input image, the outcome is written on
the same location at the target enhanced image.
2. At each target pixel, compute the histogram of the pixels in just the
neighborhood area around the target pixel.
Simple 3*3
Original Filter
Neighbourhood
e 3*3 Filter
Image Pixels
eprocessed = v.e +
r.a + s.b + t.c +
u.d + w.f +
y Image f (x, y) x.g + y.h + z.i
• The above is repeated for every pixel in the original input image to
generate the output filtered image
Spatial Linear Filtering Methods (2)
Spatial Linear Filtering Methods (3)
• For 3x3 filter shown in the previous slide, the response R of a linear
filter w with an image f is calculated as follows:
95 90 85
* 9 9
1/ 1/ 1/
9
9 9 9
Simple 3*3
1/ 100
104
9
1/ 108
9
1/
9 Original
3*3 Smoothing
Average
/ / /
Image
Pixels Filter
1
999 1106 1
9 989
Neighbourhood / / /
195 190 185
9 9 9
Filter
e = 1/9*106 +
1/ *104 + 1/ *100 + 1/ *108 +
9 9 9
1/ *99 + 1/ *98 +
9 9
1/ *95 + 1/ *90 + 1/ *85
y Image f (x, y) 9 9 9
= 98.3333
The above is repeated for every pixel in the original image to
generate the smoothed image
Spatial Linear Smoothing Filters: Average (Mean) (2)
• A weight of wk = 1/(m*n) is used for any mxn average mask.
• This weighting scheme guarantees that the weights in the mask sum
to one over any given neighborhood size.
• Because all weights are equal in the mean filter then it is also called
a box filter.
• Average mask replaces every pixel in the output image with the mean
value from its mxn neighborhood.
Weighted Average
Filter
Weighted Average Smoothing Filter Example
• By smoothing the original image with 15x15 weighted average filter,
we mix lots of the small objects with the background and leave only
the large objects to be highlighted by thresholding
• The size of the filter establishes the relative size of the mixed objects
σ = 1.4
• Weight values decrease with distance from mask center!
• Mask size is a function of σ:
Spatial Linear Smoothing Filters: Gaussian (2)
• σ controls the amount of smoothing (↑σ ↑smoothing).
• As σ increases, more weights must be obtained to approximate the
Gaussian function accurately.
σ=3
Gaussian Smoothing Filter Example
Averaging
Gaussian
Spatial Linear Sharpening Filters
• Previously we have looked at linear smoothing filters which remove
fine details, reduce noise and blur edges.
– Backward Difference:
– Central Difference:
Spatial Linear Sharpening Filters (3)
• The 1st partial derivatives of the 2D digital image f(x,y) can be:
f
f ( x 1, y ) f ( x, y )
x
f
f ( x, y 1) f ( x, y )
y
• Take a horizontal scan line on the image along the center including the
noise point
• When depicting the gray level profile of this horizontal line, we obtain
1D function.
Spatial Linear Sharpening Filters (5)
Spatial Linear Sharpening Filters (6)
• 1st derivative is just the difference between subsequent values.
Image Strip
8
7
6
5
4
3
2
1
0
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
-1 -1 -1 -1 -1 0 0 6 -6 01st 0
Derivative
0 1 2 -2 -1 0 0 0 7 0 0 0
8
6
4
2
0
-2
-4
-6
-8
Spatial Linear Sharpening Filters (7)
• 2nd derivative simply takes into account the values both before and
after the current value Image Strip
8
7
6
5
4
3
2
1
0
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
-1 0 0 0 0 1 0 6 -12 62nd0Derivative
0 1 1 -4 1 1 0 0 7 -7 0 0
10
-5
-10
-15
Spatial Linear Sharpening Filters (8)
x y
where the partial 2nd order derivative in the x direction is defined as:
2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
x
2
- =
Original Image Laplacian Filtered Sharpened Image
Image
Simplified Spatial Linear Sharpening Filter
• The entire sharpening in the previous slide can be combined into a
single filtering operation
g ( x, y ) f ( x, y ) f ( x, y )
2
f ( x, y ) [ f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)
4 f ( x, y )]
5 f ( x, y ) f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)
Simplified Spatial Linear Sharpening Filter (2)
• This gives us a new filter which does the whole job for us in one step
0 -1 0
-1 5 -1
0 -1 0
-1 -1 -1
-1 9 -1
-1 -1 -1
Spatial Linear Unsharp Filter
• An alternative spatial linear sharpening filter (high-boost filter) to the
Laplacian filter.
• It operates as follows:
1- Subtracting a smoothed (unsharp) version of an image- typically
obtained by filtering the original with a mean or a Gaussian kernel-
from the original image to emphasize edges in the image.
2- The resulting difference image is then added onto the original image
to effect some degree of sharpening using a given constant scaling
factor k that ensures the resulting sharped image is within the
proper range and the edges are not “oversharp” in the resulting
sharped image.
Questions?