Filters
Filters
Fig. 10.25 (a) Examples of zero spatial frequency, (b) low spatial frequency
and (c) high spatial frequency
Digital Image Processing 335
2 8 6
6 8 6 6 6
2 8 6 6 16 -1
2 2 6 -1 -1
6 2 Kernel
Data
cis 10.26 3x3
data
convolution kernel applied on asample
of numbers (these numbers are also
a matrix
toaveragethe value of each pixel with the values of known
as
kernel, coefficients
) thatkernel
surrounding pixels. The is usedis
in both the row and column dimensions
movedalong with one pixel at atime and the
until the
calculation is repeated entire image has been filtered and a
generated. By varying the calculation performed and the
'new' image is
weightings the individual
pixelsinthefilter window, filters can be designed to enhance or
of
offeatures.
suppress different types
To understand how one pixel is convolved, imagine that the convolution kernel is
don the data file values of the image (in one band), sothat the pixel to be
overlaid.
is in the centre of the window. Figure 10.26 shows a 3 x 3 convolution kernel convolved
being
appliedtothe pixel in the third column, third row of the sample data (the pixel that
corresponds to the centre of the kernel). To computethe output value for this pixel, each
value in the convolution kernel is multiplied by the image pixel value that corresponds to
it. These products are summed, and the total is divided by the sum of the values in the
kernel, as shown as follows:
(-1x8) + (-1x6) +(-lx6) +(-1x2) +(16x 8) +(-1x6) +
(-lx2) +(-lx2) +(-lx8)
integer (-1) +(-1) +(-1) + 16 +(-1)+(-1) +(-1)
= int [(128 40)/(16 8)]
=int (88/8) = int (1) = 11
Low-pass (Smoothing) Filter Alow-pass filter is designed to emphasize larger, bo
mogeneous areas of similar tone and reduce the smaller detail in an image. Thus, low
pass filters generally serve to smooth the appearance of an image. Average, mode, and
median filters are examples of low-pass filters.
Averaging filter A 2D moving average filter is defined in terms of its dimensions,
which must be odd, positive, and integral. The output DN is found by dìviding the sum of
the products of corresponding convolution kernel and image elements often divided by
lhe number of kernel elements. Averaging filter is also known as smoothing filter.
An example of the averaging filter is the mean filter, where averaging is done with a
kernel ofequal weights. This filter is also called a box-car filter. A3x3example of such
kernel is as follows:
and GlS
336 Remote Sensing
filtering with a
Another example of averaging
filter is kemel of dif erent
follows:
1
1 2 1
0 0 0
1 1
filter The median filter is a better way to reduce
speckle,
Median
by arranging DN
all values in
simplistic. Thisfilter operates of interest is replaced by the sequential ghile
value in order being siy
window that we define. The pixel
distribution(median). A median
filter is useful for removing pulse the
cent
orrwi
eih inoithethik
(a single observation far
filter is more useful in removing outliers RADAR
on imagery, than a awayspifrom
ke noise., Thi
the rest
data), random noise, and speckles
the
It has a desirable effect of retaining edges to some extent.
example.
This Simple aver
filter can also abege filtey
line) removal. For
to drop-out line (missing scan
ap lied
5 13 11|
12 4 9
8 6 14
The median filter finds the median pixel value. In the aforementioned
the median value for the above given set of grey-level values example, 8is
Thus the centre value of the window (4) is replaced by 8. (3,4,5,6,[8],9,11,12,14),
Mode filter The mode filter is primarily used to clean up thematic maps for presenta-
tion purposes, in that it replaces small island' themes by their larger, surrounding themes
This filter computes the mode of the grey-level values (the most frequently ocumig
grey-level value) within the filter window surrOUnding each pixel. For example
|5 3 3
3 3
3 4 5
Filtered pixel of filter window (3,3,3,3,3,4,5,5,5) is 3 (which occurs five times).
It is possible that a decision have to be made between two values with the same
it S
frequency of occurTrence. In this case, if the centre value is one of the tie values,
chosen. Otherwise, the first tie value encountered is chosen. For example,
Digital Image
5 3
Processing 337
1
3 2 3
5 4 5
-1 -1 -1|
bis kernel is used on a set of pIKels in
which arelatively low value is surounded
by higher values, the low value gets lower, as in the
BEFORE
AFTER
following:
204 200 197 204 200 197
201 106 209 201 9 209
198 200 210 198 200 210
Inversely, when the kernel is used on a set of pixels in which a relatively high value is
surrounded by lower values, the high value becomes higher, as in the following:
BEFORE AFTER
64 60 57 64 60 57
61 125 69 61 187 69
58 60 70 58 60 70
In either case, spatial frequency is increased by this kernel.
Edge Detection Filter Edge and line detection are important operations in digital image
processing.Directional, or edge detection filters are designed to highlight linear features,
such as roads or field boundaries. These filters can also be designed to enhance features
which are oriented in specific directions. These filters are useful in various fields such as
geology, for the detection of linear geologic structures. Zero-sum kernels are kernels in
which the sum of all coefficients in the kernel equals zero. A common type of edge
detection kernel is azero-sum kernel. In case of zero-sum kernel, the sum of the coefficients
338 Remote Scnsing and G7N
Sobel
Original image
Laplacian
Median
Smoothing High pass
Fig. 10.27 Original image compared with the outputs of
application several filter
is not used in the convolution equation (no division is performed).
is not defined. This generally causes the output values to be zeroin areas
since division
values are equal. low in areas of low spatial frequency, extreme in
where all
areas of
frequency. Therefore., a zero-sum kernel is an edge detector, which usually high
spatiaoutl ipa
or zeros out areas of low spatial frequency and creates a sharp contrast
frequency is high. The resulting image often contains only edges and zeros. Smowheroethesspatial
are examples of zero-sum kernels (Fig. 10.27):
|-1 -2 -1| 1 -1 -1 -1 -1|1
F0olowing
-1
Sobel= 0 0 02 0 -2 Prewitt = 0 0 01 0
2 1|| 1 0 -1
Horizontal Vertical Horizontal
Vertical
1 0 1 1 1
-4 1lor1 -8 1
Laplacian =|1
0 1 1|
Adaptive Filter Adaptive filters have kernel coefficients calculated for each window
position based on the mean and variance of the original DN in the underlying image. A
powerful technique for sharpening images in the presence of low noise levels is via an
adaptive filtering algorithm. Here we look at a method of re-defining a high-pass filer as
the sum of acollection of edge sharpening kernels. Following is one example of high
pass filter:
|-1 -2
-2 12 -2
-1 -2
DigitalImage Processing 339
Thisfiltercanbe re-written as sum of the eight edge-sharpening kernels as follows:
2
-2 1 0
0 0
0
0 0
2 -2 2
1
0 -1
The logic of the algorithmis that the firstprincipal component (PC-1) of an imaee:
assumed tocontain the overall scene luminance. The other principal components reneeis
repre
tintra-scene variance. Thus, we cansharpen only PC- l and then reverse the princis
components calculation to reconstruct the original image. Luminance is sharpened
whereas variance is retained.