0% found this document useful (0 votes)
35 views21 pages

Chapter - 1 - Image Enhancement (Spatial & Freq. Domain)

Uploaded by

P. VENKATESHWARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views21 pages

Chapter - 1 - Image Enhancement (Spatial & Freq. Domain)

Uploaded by

P. VENKATESHWARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

CHAPTER 6

Image Enhancement

Image cnhancement is the process of inproving the quality of an iinage so


becomes nore suitable for some applications. By image enhancement that
pearance of the image can be improved for visual satisfaction also. processes a
is no enhancement technique that can, in general, be applied to all Actually the
images witho
regard to their contents. This is because we do not know the exact source or
degradation for which theimage lacks some specific feature(s) required for a
application. However, we can always try to modify the image so that particul
tures can be highlighted or improved. Naturally, such processes are adthe desired
hoc in not.
and by applying them we cannot claim, in any sense, to obtain a better
is a closer version of the original undegraded one. There are
many image
approaches
whic
to
this.
Image enhancement can be performed in either spatial domain
main. In spatial domain pixel grey values are transformed directly. Inormajority of do-.
frequency
cases, some convolution mask is used for this purpose. Another
important tool for sn
tial domain enhancement is the image histogram. Either local or
global enhancement
is possible using histogram manipulation techniques. In frequency domain we deil
with the Fourier spectrum of the concerned image. 1T'his energy
spectrum allows us to
select, maintain or remove energy contributions of certain specific frequencies. Since
frequency domain processing does not involve any convolution operation, computation
cost becomes lesser and the processes become simpler.

6.1 Enhancement in Spatial Domain


Basically we can classify the spatial domain enhancement techniques into the follovisg
categories:
1. Pixel grey level transformation
Linear transformations
Image negation
Grey level shifting

104
62 Pivel Gvy Levl
Iransfornation 05

" Non iuear


rannfoations
Logaritbhmc tnnfoation
Exponenial tastots
" Grey evel sicig
" Bit plane slicinK
" lmage averaging
2. Mask processing
" Noise emoving ilters
Smoothing filters
" Sharpening ilters
3. llistogranprocesing
" listogran threslholding
" Ilistogran stretching
" Histogranequalization
Since image processing operations cn be perforned citler in spatial
in frquency domain, enhancement techniques ex0st for both the doman or
doains.
discuss some of the spatial domain techniques in the followiny sulbsections.
We shall

6.2 Pixel Grey Level Transformation


Some transformation functions may be applied to individual pixel grey valucs dircctly
to enhance the appearance of an image for n particular appliention. (Generally such
functions are written as
8= T(r) (6.1)
where, r and sare original and transformed grey levels, respectively. T is a transfor
mation function. Equation (6.1) can also be expressed as
glr, v) = Tð(, v)) (G.2)
where, f(E,y) and g(z, y) represent input and output images, respectively. If the
transformation T is position independent, then Eqs. (G.1) and (6.2) becomes equiv
alent. In Figure 6.l one non-lincar and one linear transfornations are graphically
depicted. Some of the com1nonly used transformation functions are descrilbed in fol
lowing subsections.
106 Image Enhancement
S=Tr)
S=Tr)

T)
Tír)

White
White
Black
Black
transformations.
Figure 6.1: Image grey level

6.2.1 Linear and Non-linear Transformations


simplest type of transformations. Here. a
Linear grey level transfornations are the grey values. Although.
output
linear relationship is maintained between the input and non-linear, it is found that in
linear or
in general. grey level transformations may be to provide the desired enhancement in
many cases the linear transformations are able
non-linear transformations are shown
a controllable fashion. Examples of linear and
in Figure 6.2.
S=T(r)
S=Tr)

While
White

Black Bluck Tr)


T(r)

Black + White Black White

Figure 6.2: Exarnples of non-linear (log) and linear (step) transformations.

Image negatives
The negative of an image with grey levels in the range (0, L 1] is obtained by using
the negative transformation given by the expression:
s = L-1-r (6.3)
e Pixel Grey Level Transforimation 107

Reversingthe intensity levels of.Ianimage. in this mnanner. producesthe cquivalent of


a photographic negative. This Ivpe of Drocessing is particularly suited for enhancing
white or grey details embeddel in dak
black arcas are dominannt in size. The
epions of an image, especially when the
Figure 6.3. Applicat ion of the negationhnage wation transformation is illustratcdin in
Figure 6. 1. anfoatioll on an "eye" image is shown
S= T)

White White

T)=L-1-r
Black Black

Black White Black White


(a)Before transformation (b) After transformation
Figure 6.3: Image negation transtormation. Input and output grey levels.

Figure 6.4: Original and negative images.


Grey level shifting
Sometimes we need to highlight a specifc range of the input grey values. This has
ppication in understanding image negatives and X-ray imnages, etc. Here, some
108 Image EnhanrA

desirei grey values to shift their


Figure 6.5 two
COnstats may diffeTent
be addedshifting of
operations
to a range are shown Figures 66 And 67 aur the
image.
shifting operations on the ryr
efferts of applying different
White
AT)
White

T) Black
Black

A B L-1
B L-1 Black White
A
Black White (b)
(a)
Grey level shifting.
Figure 6.5: Examples of
1.0,
0.9
0.8

0.7
0.6
0.5

0.4
0.3
0.2
0.1F

0.2 0.4 0.6 0.8


transformation.
Figure 6.6: Linearly transformed image and the corresponding

Logarithmic Transformation
by
The general form of such kind of transformation is given
s = clog(1+r)

where, c is a scaling constant. This transformation maps a narrow range of input g


levels into a wider range of output values. The opposite is true for higher values
transformat
the input grey levels. Of course, in that case the inverse logarithmic
Pixel Grey Level Transformation 109

0.9

)8

07

)6

05

0.4

0.3

0.2

0.1

0.2 0.4 0.6 0.8


Cre 6.7: Grey-level shifted image and the corresponding
transformation.
must be applied. Alogarithmic transformation and its effect on the "eye" image have
been shown in Figure 6.8.
250

200

150

100

50

0
50 100 150 200 250

Figure 6.8: Logarithmically transformed image and the corresponding transformation.

6.2.2 Grey Level Slicing


e, pxels with a certain specific range of grey values are only plotted to produce
the output image. Effects of the remnaining grey values are ignored. Therefore, objects
having the Speciic range of grey values may be displayed. The discarded grey values,
110 Image Enhancement
i.e. pixels having outside the range of specified grey values may, however. be plotted
principles. If we know the background grey level.
by maintaining any of the following be plotted as background pixels
one maytheplotout-of-order grey values may
then pixels having
Otherwise, a binaryimage using the two classes of pixels, thosc having

the desired grey values and those lacking them.

6.2.3 Bit-plane Slicing


of grey values they can be represented by a fxi
Depending on the allowed range ains asingle bit or a pixel. For example, in
cont
number of bit-planes. Each plane bit-planes (Figure 6.9). Contributions of these bit.
are 8
a 256-level image, thereimage increases from bit 0 to bit 7. By analyzing the
relativ.
planes to the displayed reduce storag.
bit-planes, we may drop one or more of them to
mportance of different Contribution of the MSB bit plane and that due
needed.
or transmission cost when eye image are shown in
Figure 6.10.
the
to rest of the bit planes for

Figure 6.9: Image bit-plane representation.

Figure 6.10: Bit-plane sliced images: contribution of the MSB-plane (left) and that of the
rest of the bit planes (right).
Proccssing
63Mask Based

6.2.4
Image Averaging

Let us
consider a number of images of thec same objcct or scene. Generally the image
capturing process incorporates some amonnt of randon noise in cach of the captuired
images. That is the captured image fr. ) cotains noise n(r. n). Theefore, the
as
captured image can be represented
S(r.)= f(r.) +no.) (6.1)

where. fr. y) is the original undegradedimage.


Now, if we consider the average of several such degraded inage, the eHo or noise
factor can be reduced by significant amount following the principle of stat istial aver-
aging. That is, the
averaged image becomes
n

rlr.y)=rry)=r(r. y) +
i=1 i=1 =1
ur. y) (65)

zero when the number of iuput.


Siuce the term representing average noise approaches
In Figure 6.11. an
emoges n is large, we can recover a near match of the original image. image is
inut image (top left image), having white and black squares is shown. This
Gaussian noise (with 0 mean and 0.005 variance) differently
corrupted using additive image) of the seven corrupted
Cor seven different instances. Average (right bottomundegraded image.
original
images is found to be almost similar to the

6.3 Mask Based Processing


enhance images. These masks are
Convolution masks are very commonly used to neigh
particular pixel and its
generally very small in size and applied locally to a are smoothing, noise
bours. Some of the important operations performed in this waydomain we sometimes
spatial
removing., sharpening, etc. In case of noise removal in according to the
call these masks as filters. Different types of filters may be needed
over an image
nature and distribution of the noise. The schematic of mask operations
is shown in Figure 6.12. subsections.
Several mask based spatial domain filters are described in the followimg

6.3.1 Smoothing Linear Filter


Ihe response of a smoothing spatial linear filter is simply the average of the pixels
contained in the neighbourhood of the filter mask. By replacing the values of every
pixel in an image by the average of the grey levels in the neighbourhood defined by
the
of
flter mask, this process results in an image with a reduction of sharp transitions
grey levels.
12 Image EnhanceMen

images and average image.


Figure 6.11: Image averaging: original synthetic image, noisy

value is
This kind of filter is also called the mean filter, because each image grey
given image.
being replaced by the average grey value in its neighbourhood. Let, in a of size mxn.
window
Sry represents the set of coordinates in a rectangular subimage
of
centred at the point (T,y). The mean filtering process computes the average value
can be done as
the corrupted image f(, y) within the area defined by Su This
1 (6.0)
g(0,y) = f(s,t)
(s, t)¬Sy

Because random noise typically consists of sharp transitions in grey leves, t


most obvious application of smoothing is noise reduction. Two such noise reducn
In Figu°
masks are shown below where the values of mand nare set as m =n=3. Gaussia
additive
6.13, an image of the moon is shown which is degraded by adding
shown here.
Another
noise and then smoothed by applying the averaging mask as
example of smoothingacoarse image is shown in Figure 6.14.
1|2 1
1
1|1 1
X 11 1 X 42
9 16
1|1 1|21
Mask Based Processing

X
(a) 2D image with mask

h(-1, -1) h(-1,0) h(-1, 1) fx-1, y-1)| SX-1, y)|f-l, y+1)

h(0, 1) h(0, 0) h(0, 1) fK, y-1) fx, y) fx, y+l)

h(1, -1) h(1, 0) h(1, 1) fr+l, -1))fx+1, y)ftl, y+1)

(b) Mask and image pixels

h(-1,-1) h(-1,0) h(-1,1)

h(0,-1) h(0,0) h(0,1)

h(l,-1) h(1,0) h(1,1)


f - l ,y) f-1,y+1)
A-1,y-1)
f ay-1)
, f a y+1)
,
fu,y)

y) fx+l,
flr+l,y-1) fo+1, y+1)

(c) Correspondence between mask and image pixels


Figure 6.12: Mask operations over an image.
114 Iuage Fnlhancemeyt

Gussian noise (c) After smoothing


(a) Original image (b) After adding
moon.
Figure 6.13: Image of

following 4 x 4 image. Apply the above-mentioned lines


Example 1: Consider the smoothed images.
smoothing masks and find out the
13 5 11 6
15 4 6 7
12 14 4 10
10 12 5 11

are to apply a 3 x 3convolution mask, we need to pad un the


Soluti0n: Since, we 0-padded image is shown below.
boundaries. The
image with 0-values at its four
0 0 0
0 13 5 11 6 0
15 6 7 0
0 1214 4 10 0
0 10 12 5 11
0

Now, applying the first mask, we get


4 6 43
79 7 5
7 9 4

5 6 63

The resultant image is fairly smoothed.


image. The npu
Now, let us apply the smoothing mask on a part of the clown
image and the resultant smoothed image are shown in Figure 6.14.
115
Mask Based
Processing
6.3

smoot hed images.


Figure 6.14: Original and

Geometric Mean Filter


6.3.2 mean filter is given by the expression
restored using a geometric
f(z,y)
Animage (6.7)

Here each restored pixel is given by the product of the pixels in


Spy-
where(s, t) is in
1
raised to the power mn
window,
the subimage
Mean Filter
6.3.3 Harmonic noise, but fails for pepper noise. It
does
works well for salt
The harmonic
mean filter
like Gaussian noise. The harmonic mean fltering
types of noise
well also with other expression
operation isgiven by the mn (6.8)
g(,y) = 1

(s,t)
(s,t)¬Sa y

6.3.4 Median Filter

each pixel value is replaced by the median of its neighbour


Incase ofa median filter, coordinates in a rectangular neighbourhood of
size
hood. If Sry represent the set of
point (z, y). The median filtering process determines the median
mxn, centred at the
by Szy: The process can be
value of the subimage of f(, y) within the area defined
described as
(6.9)
glu,y) = median {f(s,t) | (s, t) E Sy}
than the mean filter,
The smoothing effect of the median flter is relatively weaker
but it is very effective to remove impulsive noise.
116 Image Enhancement
Example 2: Consider the
and find out the
image for Example 1. Apply a 3 x 3 median flter mask
sInoothed images.
Solution: Here. at every pixcl location, we need to iclentify the median grey valje
This can be done by arranging all distinct grey values in the neighbourhood
sorting
them in ascending order and then selecting the medlian. Applying this process OT the
given image, we get the following output:
5 5
12 11 7 6
10 10
10 5 10 5

Here, in case of multiple mcdians, we have selected the lower in magnitude.


one may arbitrarily select the other median, or the average of the two to0. Howeve
6.3.5 Max- and Min-Filters
The Max-flter and Min-filter are also statistical flters which can be described as
g(z,y) = max {f(s, t)| (s, t) E Sry} (6.10
and
g(z,y) = min {f(s, t)l(s, t) E Sry} (6.11)
Here, each pixel value is replaced by the maximum or minimum of its neighbourbod

6.3.6 Sharpening Filters


The principal objective of sharpening is to highlight fine detail in an image or to
enhance thedetail that has been blurred. Sharpening can be accomplished by spatial
differentiation. The strength of the response of a derivative operator is proportional
to the degree of discontinuity of the image at the point at which the mask is appied.
Using a second order differentiation we can sharpen the image discontinuities. The
Laplacian operator is defined as
Vf(a, y) = [f(,y 1) + f(a 1, y) 4f(*, y) + f(z, y+1) + f(¢ + 1,)) (619)
The above operator is developed considering a neighbourhood of nearest four elements
The corresponding spatial convolution mask may be represented as
10 0 -1
1 -4 1 Or -1 4 -1
0 1|0 0-1
6.3 Mas
117
consider a neighborhood of 8 pixcls, the diagoal
Ifwe
the
Laplacian, the convolution mask bccones neighbHNiTN ales oitritnste trs
1
-8

Application of a Laplacian operator over the moon


image is shown in Figure 6 15
output ofthe Laplacian operat ion is displayed as an
Here, intensity image
sharp variation of intensity patterns in the original image are visible. where only

(a) Original moon image (b) Laplacian response (c) Sharpened moon image
Figure 6.15: Image of moon.

To sharpen the original image, we need to superimpose the Laplacian output with
the original one. This can be done by adding or subtracting the Laplacian response
with the original image elements. The relations used for this purpose may be written
as
f(z, y) V'f(z, y)
g(z, u) = f(z,y) + Vf(z,y)
If the definition of Laplacian uses a negative centre coefficient, we need to subtract,
otherwise an addition is needed. Combining these operations (Laplacian followed by
ad /subtract) we may derive the following sharpening operators:
0 1 0-1 0
1 -51 Or -1 5 -1
0 10 0 -1 0
Or

1 1 1 -1 -1 -1
1 -9 1 Or -1 -1
1 1|1 -1 -1 -1
|18 Image Enhancemet

6.3.7 Image Blurring and Deblurring


blurring
The inverse process of sharpening is blurring. In nOst of the case
by relative motion between Camera and the objcct during captiuring. Besides relative
motion between camera and object,image blurring Inay occur for other rCASONS als

blur from the image different techniqJes inay be emplyed


The process of removing
One of them is to use sharpening mask. The process of blurring is not an enhancenet
process, but the reverse process is one. In Figure 6.16, image of a caTneraman is shown.
This image is blurred. Figure 6.17(a) and (b) show a blurred version and sharpened

version of the above cameraman image.

Figure 6.16: Original cameranan image.

(a) Blurred image (b) Sharpened image


Figure 6.17: Processed Cameraman image.
130 Image Enhancemera

t
Logarithmic

n t r
h o o t

scale
Output
gray Lincar

" power

Smin
max
min
Input gray scale
Figure 6.22: General image contrast stretching.

6.5 Enhancement in Frequency Domain


It is already mentioned in an earlier section that enhancement processes are faste.
and simpler than their spatial domain counterpart. The advantages in the frequene
domain is due to the fact that the convolution operation, here, is replaced by the
simple point by point multipication of the image with a filter transfer function whid
is binary in nature, in general. Of course, the overhead operations of forward and
inverse Fourier transformations are involved here.
The Fourier transform converts an image into a corresponding energy spectrum.
Each frequency component is associated to a particular band in the energy spectrum.
Therefore, by maintaining or eliminating certain frequency components, we can get a
new energy spectrum. When this new spectrum is brought back tothe spatial domain.
we get a processed image.
The enhancement operators in the frequency domain are called filters or transter
functions. The spatial domain counterpart of this transfer function is the convolutian
mask. From the convolution theorem, we described earlier in Chapter 5, it is easy to
understand that by transforming a spatial mask h(z,y) we can get a correspondm3
transfer function H(u, v).
The enhancement process in the frequency domain can be expressed mathenlau
cally as
(6.39)
G(u,v) = H(u, v) · F(4, v)
where, F(u, v) is the Fourier transform of the original spatial image f(z,1 frequency
the transfer function, and G(u, v) is the transformed (enhanced) imageeiinthe
6.5 Enhancement in Frequency Domain
131

domain. The spatial version of the output image can be


transform given by obtained by an inverse Fourier
g(z.y) = F {G(u. v)) (6.40)
Although we mentioned that a transfer function can be obtained from a spatial mask.
in reality, it is not that easy. The difficulty lies in the fact the Fourier
transformations
produce both real and imaginary components. However, we can derive suitable trans
fer functions by applying common sense and geometrical properties of the frequency
spectrum and the filter function.

6.5.1 Ideal Low Pass Filter

A low pass filter is used, in general, to smooth an image. As it is known that the lower
frequency spectrum of a Fourier transform contains the average image intensities and
high frequency components signify sharp variations, we can develop a low pass filter
to eliminate the high frequency components. A suitable threshold is also required to
be determined.
An ideal low pass filter transfer function can be described by the following relation
1 if Vu? + y2<Do
H(u, v) = 0 otherwise
(6.41)

where, Do = Vu+ v is the threshold frequency and is representing the distance of


the point (uo, vo) from the origin of the frequency plane.
The low pass filter described above is shown graphically in Figure 6.23. It is clear
that the filter passes all the frequency components inside the circle of radius Do, while
attenuates all other higher frequency components. Therefore, this filter is called the
ideal low pass filter.
Hu, v)
H(u, v)

> D(u,v)
0 Do
(a) Frequency response (b) Functional form

Figure 6.23: Ideal Low pass filter.


132 Image Enhancement

6.5.2 Butterworth Low Pass Filter


The ideal low pass filter uses a sharp cut-off that imply hard hltering. 1l we want
make the filter to allow a part of the energy spectrum at higher frequencies, we may
Use the Butterworth filter. The response of Butterworth low pass filter of order nis
defined as 1
H(u, v) = 2n
(642)
where, D= Vu't y2 and Do = yuz +v. For this filter, when D= Do, we get the
response of the filter as H(u, v) = 0.5. This indicates that at the cut-off frequency

response is half of its maximum alue (i.e. 50%) (Figure 6.24). If instead of !
the we can use the following relationg:
want to get a cut-off frequency response of
1
H(u,v) = D
2n (6.43)
1+(V2-1)(Do
Or 1
H({u,v) = 2n (6.4)
1+0.414()
Do
H(u,
v)

Hu, v)

+ D(u, v)
(a) Frequency response (b) Functional form

Figure 6.24: Atypical Butterworth low pass filter.

6.5.3 Ideal High Pass Filter


An ideal high pass filter transfer function can be described by the following relatio
(6.45)
H(4, v) = 10 otherwise
if/u?+ 2> Do
Domain
65 Enhancement in Frequency
13

+ v6 is the threshold frequeney and is representing the dintanre of


where, D = Vu from
thepoint (uo. 9) the origin of the freqency plane
The high pass filter described abve is shewn graphically in Figure 625 It is clear
all the frequency components outside the circle of rarlins Do.
that the filter passes
all ot her lower frequency components. Therefore, this filter is called
while attenuates
filter.
the ideal high pass
Hu. v) Hu, v)

Do D(u, v)
0

(b) Functional forn


(a) Frequency response
Figure 6.25: Ideal high pass filter.

6.5.4 Butterworth High Pass Filter


high pass filter uses a sharp cut-off that imply hard filtering. If we want to
The ideal spectrum at lower frequencies, we may
make the filter to allow a part of the energy
Butterworth filter. The response of Butterworth high pass filter of order n is
use the
defined as 1
H(u, v) 2n
(6.46)
1+
(3)
where, D= Vu'+ y² and Do = Vu, + v. For this filter, when D = Do, we get the
response of the filter as H(u, v) = 0.5. This indicates that at the cut-off frequency
the response is half of its maximumn value (i.e. 50%) (Figure 6.25). If instead of , we
want to get a cut-off frequency response of %) we can use the following relations.
1
H(u, v) = 2n (6.47)

Or
1+
+(Va-)()
1
H(u,v) 2n (6.48)
1+0.414(o
D
134
Hu
v)
Image Enhancement

Du, v)
(a) Frequcncy response (b) Functional form

Figure 6.26: A typical Butterworth high pass filter.

6.5.5 Band Pass Filters


Sometimes another kind of filters are used which maintain features from a speciße
band of frequencies from the transformed image. These are called band pass Alters
An ideal band pass filter transfer function can be described by the following relation:

1 if Vu? + v²>D,
H(u, v) = 1 if V? + v2< D2
(6.49)
0 otherwise

where, D, = /u?+ , fori= 1,2, are the threshold frequencies and are representing
distance of the points (ui, v;) fron the origin of the frequency plane (Figure 6.27).

6.6 Gaussian Filters


Another kind of filters, based on Gaussian distribution function, are very useful n
image processing. These filters, called Gaussian flters, have the unigue characteris
ticthat the function remain real and Gaussian both in spatial and frequency domans
AGaussian filter in the frequency domain is represented as

(650)
G(u) = A exp 2g2
6.6 GaIAsian Ilters

D, D, Du. v)

(b) Functional form


(a) Frcqucncy response
Figure 6.27: ldeal band pass filter.

and o is the standard deviation of the Gaussian function. In


where A is aconstant
spatialdomain, it becomes
(6.51)
g(z) = V2naA exp (-2no'r)

functions constitute a Fourier transform pair that renains real and


The above two observation of
and implement. From
Gaussian. Gaussian are simple to understand
filter we can constitute a real spatial
the spatial domain functional form of a Gaussian
filter. For the purpose of implementation, o can be replaced by the frequency
mask
threshold Do in Eqs. (6.50) and (6.51).
situations all the filters should
From the above descriptions, we see that in ideal
Therefore, these may be termed
operate on the basis of a step thresholding function. output, we
factors in the
as linear filters also. In practice, to maintain desirable quality
need to consider non-linear filters. Butterworth filters are examples of such non-linear
6.28.
flters. General forms of such non-linear filters are shown in Figure
H(u, v) H(u, v)
H(u, v)

D(u,v) + D(u,v) 0 D(u,v)


(a) Low pass (b) High pass (c) Band pass
Figure 6.28: Non-linear filter.

You might also like