Lecture 14 PDF
Lecture 14 PDF
Filtering techniques are use to enhance and modify digital images. Also,
images filters are use to blurring and noise reduction , sharpening and edge
detection. Image filters are mainly use for suppress high (smoothing
techniques) and low frequencies (image enhancement, edge detection).
Classification of image filters is as follows:
Non linear filters are use to detect edges. Those filtering techniques are more
effective than linear filters. In linear filtering, image details and edges are
tend to blur. Gaussian filter, Laplacian filter and Neighborhood Average
(Mean) filter can be identify as examples for linear filters. Median filters are
non linear filters.
Marwa R. | 1
Filtering in the spatial domain (Spatial Filtering)
refers to image operators that change the gray value at any pixel (x,y)
depending on the pixel values in a square neighborhood centered at (x,y)
using a fixed integer matrix of the same size. The integer matrix is called a
filter , mask, kernel or a window.
The mechanism of spatial filtering, shown below, consists simply of
moving the filter mask from pixel to pixel in an image. At each pixel (x,y),
the response of the filter at that pixel is calculated using a predefined
relationship (linear or nonlinear).
Marwa R. | 3
Nonlinear Spatial Filtering
The operation also consists of moving the filter mask from pixel to
pixel in an image. The filtering operation is based conditionally on
the values of the pixels in the neighborhood, and they do not
explicitly use coefficients in the sum-of-products manner.
For example, noise reduction can be achieved effectively with a
nonlinear filter whose basic function is to compute the median gray-
level value in the neighborhood in which the filter is located.
Computation of the median is a nonlinear operation.
Example:
Use the following 3×3mask to perform the convolution process on
the shaded pixels in the 5×5 image below. Write the filtered image.
Marwa R. | 4
Spatial Filters
Marwa R. | 5
Smoothing Spatial Filters
are used for blurring and for noise reduction. Blurring is used
in preprocessing steps to:
▪ remove small details from an image prior to (large)
object extraction
▪ bridge small gaps in lines or curves.
Noise reduction can be accomplished by blurring with a linear filter
and also by nonlinear filtering.
Marwa R. | 6
Note:
Weighted average filter has different coefficients to give more
importance (weight) to some pixels at the expense of others. The
idea behind that is to reduce blurring in the smoothing process.
Marwa R. | 7
Marwa R. | 8
As shown in the figure, the effects of averaging linear filter are:
1. Blurring which is increased whenever the mask size increases.
2. Blending (removing) small objects with the background. The
size of the mask establishes the relative size of the blended objects.
3. Black border because of padding the borders of the original
image.
4. Reduced image quality.
Order-statistics filters
are nonlinear spatial filters whose response is based on ordering
(ranking) the pixels contained in the neighborhood, and then replacing
the value of the center pixel with the value determined by the ranking
result.
Examples include Max, Min, and Median filters.
Marwa R. | 9
Median filter
It replaces the value at the center by the median pixel value in the
neighborhood, (i.e. the middle element after they are sorted).
Median filters are particularly useful in removing impulse noise
(also known as salt-and-pepper noise). Salt = 255, pepper = 0 gray
levels.
In a 3×3 neighborhood the median is the 5th largest value, in a
5×5 neighborhood the 13th largest value, and so on.
For example, suppose that a 3×3 neighborhood has gray levels (10,
20, 0, 20, 255, 20, 20, 25, 15). These values are sorted as
(0,10,15,20,20,20,20,25,255), which results in a median of 20 that
replaces the original pixel value 255 (salt noise).
Example:
Consider the following 5×5 image:
Apply a 3×3 median filter on the shaded pixels, and write the
filtered image.
Solution
Marwa R. | 10
Figure below shows an example of applying the median filter on an
image corrupted with salt-and-pepper noise
Marwa R. | 11
As shown in the figure, the effects of median filter are:
1. Noise reduction
2. Less blurring than averaging linear filter
Marwa R. | 12
Sharpening Spatial Filters
The second order partial derivatives of the digital image f(x,y) are:
Marwa R. | 13
1. zero along flat segments.
2. nonzero at the outset and end of a gray-level step or ramp;
3. zero along
ramps Consider the example below:
We conclude that:
• 1st derivative detects thick edges while 2nd derivative detects thin
edges.
• 2nd derivative has much stronger response at gray-level step than 1st
Marwa R. | 14
derivative.
Thus, we can expect a second-order derivative to enhance fine detail (thin
lines, edges, including noise) much more than a first-order derivative.
The Laplacian Filter
The Laplacian operator of an image f(x,y) is:
Since the Laplacian filter is a linear spatial filter, we can apply it using
the same mechanism of the convolution process. This will produce a
laplacian image that has grayish edge lines and other discontinuities, all
superimposed on a dark, featureless background.
Background features can be "recovered" while still preserving the
sharpening effect of the Laplacian operation simply by adding the
original and Laplacian images.
Marwa R. | 15
Marwa R. | 16