Module 2
Module 2
* Visit https://vtuconnect.in for more info. For any queries or questions wrt our
platform contact us at: support@vtuconnect.in
VTU Connect Android App Download Now On Google Play Store
DIGITAL IMAGE PROCESSING 15EC72
Structure
2.1.0 Introduction
2.1.1 Objectives
2.1.2 Image Enhancement in Spatial domain
2.1.3 Some Basic Gray Level Trans -formations
2.1.4 Histogram Processing
2.1.5 Fundamentals of Spatial Filtering
2.1.6 Smoothing Spatial Filters
2.1.7 Sharpening Spatial Filters
2.2.1 Preliminary Concepts of Frequency Domain
2.2.2 The Discrete Fourier Transform (DFT) of Two Variables and
its properties.
2.2.3 Smoothing Frequency Domain filters
2.2.4 Sharpening Frequency Domain filters
2.2.5 Selective Filtering
2.2.6 Outcomes
2.2.7 Questions /Answers
2.2.8 Further Readings
2.1.0 INTRODUCTION
Image as Signals:
Signal: x(t)
Image processing is the manipulation of an image in order to improve its quality, enhances its
Contrast: Refers to the variability of image intensity across the image. Edges are regions of
relatively high local contrast. Global contrast intensity variation across the entire image is referred
to as the dynamic range of the image.
Usually contrast variation is caused by illumination.
Blur: caused by either a resolution or focus problems, or relative motion between the camera and
the object during the image capturing.
Blur edges correspond to gradual change of intensity locally.
Noise: any unwanted intensity variation in the image. Usually modeled as a random process, but
it can be highly structured and deterministic in some instances
Major Categories of Image Processing Problems
While most image problems are relatively simple to describe, solving them effectively can be quite
difficult.
There is a broad and continuously expanding spectrum of applications to image processing. The
two major branches of image processing are enhancement and restoration.
Enhancement: aimed at improving the subjective quality or the objective utility of the image
and includes: point operations, local operations and global operations. Any of these can be linear
or non-linear.
Restoration: aims at recovering any image after degradation.
2.1.1 OBJECTIVES
3. Point and neighborhood processing are discussed in linear spatial filters and its core
concepts
Spatial Domain Methods (Image Plane) Techniques are based on direct manipulation of pixels in
an image.
Suppose we have a digital image which can be represented by a two-dimensional Random field
f (x, y).
Function T applied to the image f (x, y) to produce a new image g(x, y) T f (x, y) as follows.
g(x, y) = T f (x, y)
(i) A single pixel (x, y). In this case T is a grey level transformation (or mapping) Function.
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. Image enhancement can be done through
gray level transformations which are discussed below.
The effect of this transformation will be to produce an image of higher contrast than the
original by darkening the levels below a value m and brightening the levels above m in the original
pixel spectrum. The technique is referred to as contrast stretching. The values of r below m are
compressed by the transformation function into a narrow range of S towards the dark end of the
spectrum; the opposite effect takes place for values of r above m.
.
Fig. 2.1: Intensity transformation Function.
In the limiting case shown in Fig 2.1(b), produces a 2-level (binary) image. This is also referred
to as image thresholding. Many powerful enhancement processing techniques can be formulated
in the spatial domain of an image.
Note: It is to be noted that there is no general theory of image enhancement. When an image is
processed for visual interpolation, the observer is the ultimate judge of how well a particular
method works. Visual evaluation of image quality is a subjective process thus making the
definition of a "good image" an elusive standard by which to compare algorithm performance.
2.1.3.1 Gray level transformation
There are three basic gray level transformation.
➢ Linear
➢ Logarithmic
➢ Power – law
The overall graph of these transitions has been shown below
Linear transformation
First, we will look at the linear transformation. Linear transformation includes simple identity and
negative transformation. Identity transformation has been discussed in our tutorial 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 Fig 2.3
Negative transformation
The second linear transformation is negative transformation, which is invert of identity
transformation. In negative transformation, each value of the input image is subtracted from the
L-1 and mapped onto the output image.The result is somewhat like as shown in the Fig.2.4
Fig. 2.4: Original digital mammogram and negative image obtained using the negative transformation
In this case the following transition has been done.
s = (L – 1) – r
since the input image of Einstein is an 8 bpp image, so the number of levels in this image are 256.
Putting 256 in the equation, we get this
s = 255 – r
So each value is subtracted by 255 and the result image has been shown above. So what happens
is that, the lighter pixels become dark and the darker picture becomes light. And it results in image
negative. It has been shown in the Fig 2.5.
Logarithmic transformation further contains two type of transformation. Log transformation and
inverse log transformation.
Log transformation
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 value of c in the log transform adjust the kind of enhancement
you are looking for.
s=cr^γ
This symbol γ is called gamma, due to which this transformation is also known as gamma
transformation.
Variation in the value of γ varies the enhancement of the images is shown in the Fig. 2.7 Different
display devices / monitors have their own gamma correction, that’s why they display their image
at different intensity.
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 image displayed on CRT is dark.
s = cr
1 maps a narrow range of dark input values into a wider range of output values, while
maps a narrow range of bright input values into a wider range of output values when 1
: gamma, gamma correction
Fig. 2.7: Plots of the power law equation for various values of Gama
Fig. 2.8: b and d represents the image displayed without and with gama correction
Fig. 2.9: Aerial Image, (b) to (d)results of applying transforms with gama=3,4 and 5.
2.1.3.2 Piecewise-linear transformation functions
Principle Advantage: Some important transformations can be formulated only as a piecewise
function.
Principle Disadvantage: Their specification requires more user input that previous transformations
Types of Piecewise transformations are:
Contrast Stretching
One of the simplest piecewise linear functions is a contrast-stretching transformation, which is
used to enhance the low contrast images.
Low contrast images may result from:
Poor illumination
Wrong setting of lens aperture during image acquisition.
Fig. 2.10: Contrast stretching a. transformation function, low contrast image, result of contrast stretching and
threshold image.
Fig. 2.10 shows a typical transformation used for contrast stretching. The locations of points (r1,
s1) and (r2, s2) control the shape of the transformation function.
If r1 = s1 and r2 = s2, the transformation is a linear function that produces no changes in gray
levels.
If r1 = r2, s1 = 0 and s2 = L-1, the transformation becomes a thresholding function that creates a
binary image. As shown previously in slide 7.
Intermediate values of (r1, s1) and (r2, s2) 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 the function is always increasing
Gray-level Slicing
Thresholding is the special case of clipping where a=b and output becomes binary. The
thresholding is used to make such an image binary. There is intensity level slicing without
background and with background. These transformations permit segmentation of certain gray
level regions from the rest of the image the transformation function and corresponding images as
shown in the Fig 2.11 and Fig 2.12 respectively.
Fig. 2.11: Transformation high lights the intensity range [a,b] and high lights the range.
Fig. 2.12: Transformation high lights the intensity range [a,b] and high lights the range.
Bit-plane slicing
Pixels are digital numbers, each one composed of bits. Instead of highlighting gray-level range,
we could highlight the contribution made by each bit is as shown in the Fig 2.13.
Fig. 2.14: An 8-bit greyscale image and its corresponding representation from bit 1 to bit 8
Fig. 2.15: Images reconstructed using Bit planes 8 and 7, Bit planes 8,7 and 6 and Bit planes 8,7,6 and 5
This method is useful and used in image compression
2.1.4 HISTOGRAM PROCESSING
• Histogram
In an image histogram, the x axis shows the gray level intensities and the y axis shows the
frequency of these intensities.
h(rk)=nk
– where is the kth gray level and is the number of pixels in the image having
gray level
– Normalized histogram
• p(rk)=nk / MN
Spreading out the frequencies in an image (or equalising the image) is a simple way to
improve dark or washed out images
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 be skewed towards the
lower end of the grey scale and all the image detail is 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. Histogram equalization
involves finding a grey scale transformation function that creates an output image with a uniform
histogram (or nearly so) is as shown in the Fig. 2.17.
Fig. 2.17: Four basic Images and their corresponding histograms equalized images.
defined relationship. All the filters values are pre-defined and are a standard the above process is
indicated in the Fig. 2.18.
Fig. 2.18: The mechanism of linear spatial filtering using a 3X3 filter mask.
• Box filter
Fig. 2.19: original image of, (b)-(f) results of smoothing with square averaging filter masks of sizes 3,5,9,15 and 35
respectively.
Smoothing filters are used to remove fine details from the original images. Sharpening spatial
filters seek to highlight fine detail – Remove blurring from images – Highlight edges Sharpening
filters are based on spatial differentiation.
The operator usually takes an image and a filter function in the Fourier domain. This image is then
multiplied with the filter function in a pixel-by-pixel fashion:
G( u,v ) = F(u,v)*H(u,v)
where F(u,v) is the input image in the Fourier domain, H(u,v) the filter function and G(u,v) is the
filtered image. To obtain the resulting image in the spatial domain, G(u,v) has to be re-transformed
using the inverse Fourier Transform. There are basically three different kinds of filters: lowpass,
high pass and bandpass filters.
2.2.2 The Discrete Fourier Transform (DFT) of Two Variables and its
properties.
The formula for 2-dimensional discrete Fourier transform is given below.
The discrete Fourier transform is actually the sampled Fourier transform, so it contains some
samples that denotes an image. In the above formula f(x,y) denotes the image, and F(u,v) denotes
the discrete Fourier transform. The formula for 2-dimensional inverse discrete Fourier transform
is given below.
The inverse discrete Fourier transform converts the Fourier transform back to the image
To filter an image in the frequency domain:
1. Compute F(u,v) the DFT of the image
2. Multiply F(u,v) by a filter function H(u,v)
3. Compute the inverse DFT of the result I as shown in the Fig. 2.20.
Smoothing is achieved in the frequency domain by dropping out the high frequency components
The basic model for filtering is:
G(u,v) = H(u,v)F(u,v)
where F(u,v) is the Fourier transform of the image being filtered and H(u,v) is the filter transform
function
Low pass filters – only pass the low frequencies, drop the high ones
Fig. 2.21: (a)Perspective plot of ILPF TF(b)Filter displayed as an image(c) Filter radial cross section
The transfer function for the ideal low pass filter can be given as:
1 if D(u, v) D0
H (u, v) =
0 if D(u, v) D0
where D(u,v) is given as:
D(u, v) = [(u − M / 2) 2 + (v − N / 2) 2 ]1/ 2
➢ The sharp cutoff frequencies of an ILPF cannot be realized with electronic components,
although certainly can be simulated in a computer.
➢ The ILPF is not very practical. It is useful to study their behavior as a part of our
development of filtering concepts.
➢ The center lobe of the sinc is the principal cause of blurring, while the outer, smaller lobs
are mainly responsible for ringing.
➢ The spread of the sinc function is inversely proportional to the radius of H(u,v),for larger
values of D0 blurring effects will be absent.
Fig. 2.22: Original image and (b)-(f) results of filtering using ILPFs with cutoff frequencies set at the radii
values 5, 15, 30, 80 and 230
1
H (u , v ) =
1 + [ D (u , v ) / D0 ]2 n
Fig. 2.23: (a)Perspective plot of BLPF TF(b)Filter displayed as an image(c) Filter radial cross section
Fig. 2.23: Original image and (b)-(f) results of filtering using BLPFs with cutoff frequencies set at the radii values 5,
15, 30, 80 and 230
Fig. 2.24: (a)-(d) Spatial representation of BLPFs of order 1,2,5 and 20 and corresponding intensity profiles through
the center of filters.
The ringing effects increases as the function of filter order as shown in the Fig. 2.23 and Fig.2.24.
Gaussian Lowpass Filters
The transfer function of a Gaussian lowpass filter is as shown in the Fig. 2.25 and is defined as:
H (u, v) = e − D ( u ,v ) / 2 D0 2
2
Fig. 2.25: (a)Perspective plot of BLPF TF(b)Filter displayed as an image(c) Filter radial cross section
Fig. 2.26: Original image and (b)-(f) results of filtering using BLPFs with cutoff frequencies set at the radii values 5,
15, 30, 80 and 230
GLPF will have no ringing effects which is required in medical imaging in which any type of
artifact is unacceptable.
Practical application of LPF
The low-resolution text with broken character segments can be joined by using GLPF is as shown
in the below Fig. 2.27.
Fig. 2.27: Sample of text with broken segments and repaired with LP filtering process
The Fig. 2.28 shows the applications of LP filtering for producing a smoother, softer looking
results from sharp original. That is significant reduction in fine skin lines around the eyes,so that
the smoothed image look quite soft and pleasing.
Fig. 2.28: Original image and (b, c) result of filtering using a GLPF with D 0 = 100 and 80.
where D0 is the cut off distance. The Fig.2.29 shows an image and cross section of IHPF.
Fig. 2.29: (a)Perspective plot of IHPF TF(b)Filter displayed as an image(c) Filter radial cross section
Fig. 2.30: Original image and (b)-(c) Results of ideal high pass filtering with D0 = 15,30,80
Results of ideal high pass filtering with D0 = 15
➢ The ringing is severe that it is produced distorted, thickened object boundaries
➢ The edges of the top 3 circles do not show well because they are not strong as other edges
of the image. i.e. closer to background intensity.
The smaller objects and lines are appeared almost solid white
1
H (u , v ) =
1 + [ D0 / D (u , v )]2 n
where n is the order and D is the cut off distance. The Fig.2.31 shows an image and cross
0
section of BHPF
Fig. 2.31: (a)Perspective plot of BHPF TF(b)Filter displayed as an image(c) Filter radial cross section
H (u, v) = 1 − e − D ( u ,v ) / 2 D0 2
2
where n is the order and D is the cut off distance. The Fig.2.32 shows an image and cross
0
section of GHPF
Fig. 2.32: (a)Perspective plot of GHPF TF(b)Filter displayed as an image(c) Filter radial cross section
In a finger print recognition by using an HPF the ridges are enhanced and smudges has been
reduced considerably using a threshold of the filtered image as shown in the Fig,2.33.
Obtain a sharp image by subtracting a lowpass filtered (i.e., smoothed) image from the original
image. Image sharpening emphasizes edges but low frequency components are lost.
Unsharp filtering - frequency-domain filter
H hp (u, v) = 1 - H lp (u, v )
Sharpening Filters: High Boost
High boost filter: amplify input image, then subtract a lowpass image.
High Boost = an original – LP
=(A-1) original + original - LP
H hb (u, v) = (A -1) - H hp (u, v)
High-boost filtering often desirable to emphasize high frequency components representing the
image details (by means such as sharpening) without eliminating low frequency components
representing the basic form of the signal.
High frequency emphasis
H hfe (u, v) = a + bH hp (u, v)
typically, 0.25≤ a ≤ 0.5, 1.5 ≤ b ≤ 2.0
In HP filtering process the DC term is set to Zero, thus reducing the average intensity in the filtered
image to 0. this drawback can be overcome by the use of High frequency emphasis filter, the
constant a gives control over the proportion of high frequencies that influence the final result. The
effect of the above explained concepts are indicated in the Fig. 2.34.
Fig. 2.34: (a)A chest of X-ray image (b)result of GHPF(c) Result of HE (d) Result of HE and histogram
equalization.
Homomorphic filtering
Many times, we want to remove shading effects from an image (i.e., due to uneven illumination)
➢ Enhance high frequencies
➢ Attenuate low frequencies but preserve fine detail
Consider the following model of image formation:
f (x, y) = i (x, y) r (x, y)
i(x,y): illumination
r(x,y): reflection
In general, the illumination component i(x,y) varies slowly and affects low frequencies mostly.
In general, the reflection component r(x,y) varies faster and affects high frequencies mostly.
IDEA: separate low frequencies due to i(x,y)
from high frequencies due to r(x,y) the resultant waveform is as shown in the Fig. 2.35.
2.2.6 Outcomes
Students will be able to understand various transformation techniques used for image
enhancement. Its significance in spatial domain.
Students will be able to understand various filtering techniques in frequency domain.
Smoothing and sharpening the image is known using low pass and high pass filters.
2.2.7 Questions