DIP2
DIP2
UNIT -2
IMAGE ENHANCEMENT
Learning Objectives:
Image enhancement techniques are designed to improve the quality of an
image as perceived by a human being. Image enhancement can be
performed both in the spatial as well as in the frequency domain. After
reading this chapter, the reader should have a basic knowledge about the
following concepts:
1. Image enhancement in spatial and frequency domain
2. Point operations and mask operations in spatial domain
3. Different types of gray –level transformation
4. Histogram and histogram equalization
5. Frequency domain filtering
Introduction:
Image enhancement approaches fall into two broad categories: spatial
domain methods and frequency domain methods. The term spatial domain
refers to the image plane itself, and approaches in this category are based
on direct manipulation of pixels in an image.
Frequency domain processing techniques are based on modifying the
Fourier transform of an image. Enhancing an image provides better
contrast and a more detailed image as compare to non-enhanced image.
Image enhancement has very good applications. It is used to enhance
medical images, images captured in remote sensing, images from satellite
etc. As indicated previously, the term spatial domain refers to the
aggregate of pixels composing an image. Spatial domain methods are
procedures that operate directly on these pixels. Spatial domain processes
will be denoted by the expression.
g(x,y) = T[f(x,y)]
where f(x, y) is the input image, g(x, y) is the processed image, and T is an
operator on f, defined over some neighborhood
of (x, y).
Page | 25
Digital Image Processing SCSVMV Dept of ECE
The simplest form of T is when the neighborhood is of size 1*1 (that is, a
single pixel). In this case, g depends only on the value of f at (x, y), and T
becomes a gray-level (also called an intensity or mapping) transformation
function of the form
s=T(r)
where r is the pixels of the input image and s is the pixels of the output
image. T is a transformation function that maps each value of „r‟ to each
value of „s‟.
For example, if T(r) has the form shown in Fig. 2.2(a), the effect of this
transformation would be to produce an image of higher contrast than the
original by darkening the levels below m and brightening the levels above
m in the original image. In this technique, known as contrast stretching,
the values of r below m are compressed by the transformation function into
a narrow range of s, toward black. The opposite effect takes place for
values of r above m.
In the limiting case shown in Fig. 2.2(b), T(r) produces a two-level (binary)
image. A mapping of this form is called a thresholding function.
One of the principal approaches in this formulation is based on the use of
so-called masks (also referred to as filters, kernels, templates, or windows).
Basically, a mask is a small (say, 3*3) 2-D array, such as the one shown in
Fig. 2.1, in which the values of the mask coefficients determine the nature
of the process, such as image sharpening. Enhancement techniques based
on this type of approach often are referred to as mask processing or
filtering.
Page | 26
Digital Image Processing SCSVMV Dept of ECE
LINEAR TRANSFORMATION:
First, we will look at the linear transformation. Linear transformation
includes simple identity and negative transformation. Identity
transformation has been discussed in ourtutorial of image transformation,
but a brief description of this transformation has been given here.
Identity transition is shown by a straight line. In this transition, each
value of the input image is directly mapped to each other value of output
image. That results in the same input image and output image. And hence
is called identity transformation. It has been shown below:
NEGATIVE TRANSFORMATION:
The second linear transformation is negative transformation, which is
Page | 27
Digital Image Processing SCSVMV Dept of ECE
IMAGE NEGATIVE:
The image negative with gray level value in the range of [0, L-1] is
obtained by negative transformation given by S = T(r) or
S = L -1 – r
Where r= gray level value at pixel (x,y)
L is the largest gray level consists in the image
It results in getting photograph negative. It is useful when for enhancing
white details embedded in dark regions of the image.
The overall graph of these transitions has been shown below.
Page | 28
Digital Image Processing SCSVMV Dept of ECE
LOGARITHMIC TRANSFORMATIONS:
Logarithmic transformation further contains two type of transformation.
Log transformation and inverse log transformation.
LOG TRANSFORMATIONS:
The log transformations can be defined by this formula
S = c log(r + 1).
Where S and r are the pixel values of the output and the input image and c
is a constant. The value 1 is added to each of the pixel value of the input
image because if there is a pixel intensity of 0 in the image, then log (0) is
equal to infinity. So, 1 is added, to make the minimum value at least 1.
During log transformation, the dark pixels in an image are expanded as
compare to the higher pixel values. The higher pixel values are kind of
compressed in log transformation. This result in following image
enhancement.
The shape of the curve shows that this transformation maps the narrow
range of low gray level valuesintheinputimageintoa
widerrangeofoutputimage.
Theoppositeis trueforhighlevelvaluesofinputimage.
Page | 29
Digital Image Processing SCSVMV Dept of ECE
In Fig that curves generated with values of γ>1 have exactly the opposite
effect as those generated with values of γ<1. Finally, we Note that Eq. (6)
reduces to the identity transformation when c=γ=1.
This type of transformation is used for enhancing images for different type
of display devices. The gamma of different display devices is different. For
example, Gamma of CRT lies in between of 1.8 to 2.5, that means the
Page | 30
Digital Image Processing SCSVMV Dept of ECE
CORRECTING GAMMA:
S=Cr γ
S=Cr (1/2.5)
The same image but with different gamma values has been shown here.
Intermediate values of ar1, s1b and ar2, s2b produce various degrees of
spread in the gray levels of the output image, thus affecting its contrast. In
general, r1≤ r2 and s1 ≤ s2 is assumed so that the function is single valued
and Monotonically increasing.
Page | 31
Digital Image Processing SCSVMV Dept of ECE
Finally, Fig. x(d) shows the result of using the thresholding function
defined previously,with r1=r2=m, the mean gray level in the image. The
original image on which these results are based is a scanning electron
microscope image of pollen, magnified approximately 700 times.
Page | 32
Digital Image Processing SCSVMV Dept of ECE
the desired range of gray levels but preserves the background and gray-
level tonalities in the image. Figure y (c) shows a gray-scale image, and
Fig. y(d) shows the result of using the transformation in Fig. y(a).
Variations of the two transformations shown in Fig. are easy to formulate.
BIT-PLANE SLICING:
Instead of highlighting gray-level ranges, highlighting the contribution
made to total image appearance by specific bits might be desired. Suppose
that each pixel in an image is represented by 8 bits. Imagine that the
image is composed of eight 1-bit planes, ranging from bit-plane 0 for the
least significant bit to bit plane 7 for the most significant bit. In terms of 8-
bit bytes, plane 0 contains all the lowest order bits in the bytes comprising
the pixels in the image and plane 7 contains all the high-order bits.
Figure 3.12 illustrates these ideas, and Fig. 3.14 shows the various bit
planes for the image shown in Fig. 3.13. Note that the higher-order bits
Page | 33
Digital Image Processing SCSVMV Dept of ECE
(especially the top four) contain the majority of the visually significant
data.The other bit planes contribute to more subtle details in the image.
Separating a digital image into its bit planes is useful for analyzing the
relative importance played by each bit of the image, a process that aids in
determining the adequacy of the number of bits used to quantize each
pixel.
HISTOGRAM PROCESSING:
The histogram of a digital image with gray levels in the range [0, L-1] is a
discrete function of the form
H(rk)=nk
where rk is the k gray level and nk is the number of pixels in the image
th
The components of the histogram in the high contrast image cover a broad
range of the gray scale. The net effect of this will be an image that shows a
great deal of gray levels details and has high dynamic range.
Page | 34
Digital Image Processing SCSVMV Dept of ECE
HISTOGRAM EQUALIZATION:
Histogram equalization is a common technique for enhancing the
appearance of images. Suppose we have an image which is predominantly
dark. Then its histogram would beskewed towards the lower end of the
grey scale and all the image detail are compressed into the dark end of the
histogram. If we could stretch out the grey levels at the dark end to
produce a more uniformly distributed histogram then the image would
become much clearer.
Let there be a continuous function with r being gray levels of the image to
be enhanced. The range of r is [0, 1] with r=0 repressing black and r=1
representing white. The transformation function is of the form
S=T(r) where 0<r<1
It produces a level s for every pixel value r in the original image.
Thus, the PDF of the transformed variable s is the determined by the gray
levels PDF of the input image and by the chosen transformations function.
A transformation function of a particular importance in image processing
Whereas P and Q are the padded sizes from the basic equations
Wraparound error in their circular convolution can be avoided by padding
these functions with zeros
Fig: Ideal Low Pass Filter 3-D view and 2-D view and line graph
Page | 37
Digital Image Processing SCSVMV Dept of ECE
Fig: (a) Test pattern of size 688x688 pixels (b) its Fourier spectrum
Fig: (a) original image, (b)-(f) Results of filtering using ILPFs with cutoff
frequencies set at radii values 10, 30, 60, 160 and 460, as shown in
fig.2.2.2(b). The power removed by these filters was 13, 6.9, 4.3, 2.2 and
0.8% of the total, respectively.
Page | 38
Digital Image Processing SCSVMV Dept of ECE
-
Transfer function does not have sharp discontinuity establishing cutoff
between passed and filtered frequencies.
Cut off frequency D0 defines point at which H(u,v) = 0.5
Page | 39
Digital Image Processing SCSVMV Dept of ECE
Unlike the ILPF, the BLPF transfer function does not have a sharp
discontinuity that gives a clear cutoff between passed and filtered
frequencies.
Fig. (a) Original image. (b)-(f) Results of filtering using BLPFs of order 2,
with cutoff frequencies at the radii
Fig. shows the results of applying the BLPF of eq. to fig.(a), with n=2 and
D0 equal to the five radii in fig.(b) for the ILPF, we note here a smooth
transition in blurring as a function of increasing cutoff frequency.
Moreover, no ringing is visible in any of the images processed with this
particular BLPF, a fact attributed to the filter’s smooth transition between
low and high frequencies.
Where D0 is the cutoff frequency. When D(u,v) = D0, the GLPF is down to
0.607 of its maximum value. This means that a spatial Gaussian filter,
obtained by computing the IDFT of above equation., will have no ringing.
Page | 41
Digital Image Processing SCSVMV Dept of ECE
Figure shows a perspective plot, image display and radial cross sections of
a GLPF function.
Fig. (a) Perspective plot of a GLPF transfer function. (b) Filter displayed as
an image. (c). Filter radial cross sections for various values of D0
Fig.(a) Original image. (b)-(f) Results of filtering using GLPFs with cutoff
frequencies at the radii shown in fig.2.2.2. compare with fig.2.2.3 and
fig.2.2.6
Page | 42
Digital Image Processing SCSVMV Dept of ECE
Fig: Top row: Perspective plot, image representation, and cross section of a
typical ideal high-pass filter. Middle and bottom rows: The same sequence
for typical butter-worth and Gaussian high-pass filters.
IDEAL HIGH-PASS FILTER:
A 2-D ideal high-pass filter (IHPF) is defined as
H (u,v) = 0, if D(u,v) ≤ D0
H (u,v) = 1, if D(u,v) ˃ D0
Where D0 is the cutoff frequency and D(u,v) is given by eq. As intended,
Page | 44
Digital Image Processing SCSVMV Dept of ECE
the IHPF is the opposite of the ILPF in the sense that it sets to zero all
frequencies inside a circle ofradius D0 while passing, without attenuation,
all frequencies outside the circle. As in case of the ILPF, the IHPF is not
physically realizable.
Fig Spatial representation of typical (a) ideal (b) Butter-worth and (c)
Gaussian frequency domain high-pass filters, and corresponding intensity
profiles through their centers.
We can expect IHPFs to have the same ringing properties as ILPFs. This is
demonstrated clearly in Fig. which consists of various IHPF results using
the original image in Fig.(a) with D0 set to 30, 60, and 160 pixels,
respectively. The ringing in Fig. (a) is so severe that it produced distorted,
thickened object boundaries (E.g., look at the large letter “a”). Edges of the
top three circles do not show well because they are not as strong as the
other edges in the image (the intensity of these three objects is much closer
to the background intensity, giving discontinuities of smaller magnitude).
FILTERED RESULTS OF IHPF:
Page | 45
Digital Image Processing SCSVMV Dept of ECE
Fig. Results of high-pass filtering the image in Fig.(a) using an IHPF with
D0 = 30, 60, and 160
Fig.2.2.2(b). These results are much smoother than those obtained with an
IHPF
Fig. Results of high-pass filtering the image in fig.(a) using a GHPF with
D0 = 30, 60 and 160, corresponding to the circles in Fig.(b)
Page | 47