Professional Documents
Culture Documents
1/95
IMAGE PRE-PROCESSING
TECHNIQUES
Text Books:
Digital Image Processing – Gonzalez & Woods, 3rd Edition
2/95
CONTENTS
IMAGE ENHANCEMENT
Spatial Domain Methods
• Histogram Processing
• Fundamentals of Spatial Filtering
• Smoothing Spatial Filters
• Sharpening Spatial Filters
Frequency Domain Methods
• Basics of Filtering in Frequency Domain
• Image Smoothing
• Image Sharpening
• Selective Filtering
3/95
CONTENTS (Contd…)
IMAGE SEGMENTATION
• Segmentation Concepts
• Point Detection
• Line Detection
• Edge Detection
• Thresholding
• Region Based Segmentation
4/95
CONTENTS (Contd…)
IMAGE COMPRESSION
• Fundamentals
• Coding Redundancy
• Spatial & Temporal Redundancy
• Compression Methods –
Huffman Coding
Arithmetic Coding
LZW Coding
Run Length Coding
Bit Plane Coding
Transform Coding
Predictive Coding
Lossy & Lossless Coding
Wavelet Coding
• JPEG Standards
5/95
The principle objective of Image Enhancement is to process
an image so that the result is more suitable than the original
image for specific application
Image Enhancement approaches fall into 2 broad categories
1. Spatial Domain
2. Frequency Domain
Spatial Domain refers to the image plane itself & approaches
are based on direct manipulation of pixels in an image
Frequency Domain refers to modifying Fourier Transform of
an image
6/95
HISTOGRAM PROCESSING
The Histogram of a digital image with intensity levels in the
range (0, L-1) is a discrete function h(rk) = nk, where rk is the
kth intensity value & nk is the no. of pixels in the image with
intensity rk
The Normalized Histogram can be obtained by dividing each
of its components by the total no. of pixels in the image i.e.,
MN, where M is the no. of rows and N is no. of columns in
the image
Normalized Histogram is given by – p(rk) = nk/MN
Contd …
7/95
Histograms are simple to calculate in software and also lend
themselves to economic hardware implementations. Thus
making a popular tool for real time image processing
The Histogram Processing for intensity transformations can
be explained by the fig – 1
The left side of the figure is the image with four different
intensity characteristics – Dark,
Light,
Low Contrast
High Contrast
Contd …
8/95
4 Basic Image Types & Corresponding HistogramsContd …
9/95
The right side of the figure shows the Histogram of the
corresponding images on the left
The horizontal axis if each histogram plot corresponds to
the intensity values i.e., rk
The vertical axis of each histogram plot corresponds to the
values of h(rk) = nk or p(rk) = nk/MN, if the values are
normalized
Thus the histogram can be graphically viewed as plots of
h(rk) = nk versus rk or p(rk) = nk/MN versus rk
Contd …
10/95
In dark image, components of the histogram are concentrated
on the lower side of the intensity scale
The components of the histogram of light image are biased
towards the high side of the intensity scale
An image with low contrast has a narrow histogram located
typically towards the middle of the intensity scale
The components of the histogram in the high contrast image
cover a wide range of intensity scale
Contd …
11/95
Histogram Equalization
Consider an Image with continuous intensity values
Let, r be the intensity values of the image to be processed
The range of r is (0, L-1) with r = 0 representing black and r
= L-1 representing white
For satisfying these conditions, the transformation is of the
form – S = T(r), 0 ≤ r ≤ L-1
The transformation or intensity mappings produce an output
intensity level S for each pixel in the input image with the
intensity r
Contd …
12/95
The transformation must satisfy two conditions –
1. T(r) is monotonically increasing function in the interval
0 ≤ r ≤ L-1
2. 0 ≤ T(r) ≤ L-1 for 0 ≤ r ≤ L-1
Monotonically Increasing Function: If T(r2) ≥ T(r1) for r2 > r1
Condition – 1 guarantees the O/P intensity values will never
be less than the corresponding I/P values, thus preventing
artifacts created by reversals of intensity
Condition – 2 guarantees the range of O/P intensities is same
as the input
Contd …
13/95
The inverse transformation is given by – r = T-1(S)
The inverse transformation must satisfy the two conditions –
1. T(r) is strictly monotonically increasing function in the
interval 0 ≤ r ≤ L-1
2. 0 ≤ T(r) ≤ L-1 for 0 ≤ r ≤ L-1
Strictly Monotonically Increasing Function: If T(r2) > T(r1) for r2 > r1
Condition – 1 guarantees the mappings from S back to r are
one-to-one, thus preventing the ambiguities
Contd …
14/95
The fig – a shows a function which satisfies both conditions
of a monotonically increasing function
It is possible for multiple values to map to a single value and
still satisfy the first two conditions
Contd …
17/95
(a) 4 Basic Image Types
(b) Corresponding Histogram
Equalized Images
(c) Histograms of the Images
in (b)
Contd …
18/95
The left column in fig (a) shows four images with various
intensity characteristics i.e., dark, light, low contrast and
high
contrast
The center column in fig (b) shows the result of performing
the histogram equalization on each of the four images
The result of histogram equalization on dark, light and low
contrast images gives a significant improvement
The histogram equalization on the high contrast image did
not
Contd …
have much effect because the intensities of this image already
19/95
The right column in fig (c) shows the histograms of the
equalized images
The histograms of the dark, light and low contrast images are
visually very similar
This is because the images have same content, the increase in
contrast resulting from histogram equalization was enough to
render any intensity differences in the equalized images
visually indistinguishable
Contd …
20/95
Though there is a significant contrast difference between the
original images, this example illustrates power of histogram
equalization as an adaptive contrast enhancement tool
The fig – (b) shows transformation function used to generate
the equalized image in fig – (a)
The transformation functions are generated by using Eq. 12
The transformation function of the high contrast image has a
nearly linear shape, which indicates that the inputs were
mapped to nearly equal outputs
Contd …
21/95
Histogram Matching
Contd …
22/95
The Histogram Matching is also named as the Histogram
Specification
Consider an image with continuous intensity values
Let, r & z be the intensity values of the input & output
images
respectively
Let, Pr(r) and Pz(z) be the continuous PDFs
Contd …
24/95
The transformation T(r) can be obtained from Eq. 1 if Pr(r) is
estimated from the input image
The transformation function, G(z) can be obtained from Eq. 2
if Pz(z) is known
Contd …
25/95
An image whose intensity levels have a specified PDF can be
obtained from a given image by using Eq. 1, 2 & 3 with the
following procedure –
1. Obtain Pr(r) from the I/P image and use Eq. 1 to obtain
the values of S
2. Use the specified PDF in Eq. 2 to obtain the
transformation function G(z)
3. Obtain the inverse transformation from Eq. 3, as z is
obtained from S, this process is a mapping from S to z
Contd …
26/95
4. Obtain the O/P image by first equalizing the input image
by using Eq. 1, the pixel values in this image are the S
values. For each pixel with value S in the equalized
image, perform the inverse mapping by Eq. 3 to obtain
the corresponding pixel in the O/P image. When all
pixels have been processed the PDF of the O/P image
will be equal to the specified PDF
Contd …
27/95
The discrete form of transformation in Eq. 1 is given by –
Sk = T(rk) = (L-1)
Sk = T(rk) =
, for k = 0 to L-1 ------ Eq. 4
Where, MN – Total Number of Pixels in the Image
nj – Number of Pixels with Intensity Value rj
L – Total No. of possible Intensity Levels in image
The discrete formulation of Eq. 2 if the specific value of Sk is
given in computing the transformation function is –
G(zq) = (L-1) pz(zi) ------ Eq. 5
Contd …
29/95
Procedure for Histogram Matching or Histogram
Specification
is as follows –
1. Compute the histogram Pr(r) of the given image and use it
to find the histogram equalization transformation in Eq. 4.
Round the resulting values, Sk to integer range [0, L-1]
2. Compute all the values of the transformation function G
using Eq. 5 for q = 0 to L-1, where pz(zi) are the values of
the specified histogram. Round the values of G to integers
in the range [0, L-1]. Store the values of G in a tableContd …
30/95
3. For every value of Sk, k = 0 to L-1 use the stored value of
Contd …
32/95
Comparison b/t Histogram Equalization and
Histogram Matching
Contd …
33/95
The fig – (a) shows an image of Mars Moon Phobos taken by
NASA’s Mars Global Surveyor
The fig – (b) the histogram of fig – (a)
The image is dominated by large, dark areas which results in
a histogram characterized by a large concentration of pixels
in the dark end of a gray scale
At first glance, it would look like histogram equalization is a
good approach to enhance the image, so that the details in the
dark areas become more visible
But it is not going to enhance
Contd …
34/95
(a) Transformation Function for
Histogram Equalization
Contd …
35/95
The fig – (a) shows the histogram equalization transformation
obtained from the histogram in fig – (b) of previous figure
The most relevant characteristic of this transformation
function is how fast it rises from intensity level 0 to a level
near 190
This is caused by the large concentration of pixels in the
input
histogram having levels near 0
Contd …
36/95
When this transformation is applied to levels of input image
to obtain a histogram equalized result, the net effect is to
map
a very narrow interval of dark pixels into the upper end of
the
gray scale of the output image
Because numerous pixels in input image have levels precisely
in this interval, the resulting image can be light, washed out
appearance
This is shown in fig – (b)
Contd …
37/95
The histogram of this image is shown in fig – (c)
In the histogram of the output image, all the intensity levels
are biased towards the upper half of the gray scale
Because the problem with transformation function in fig – (a)
was caused by large concentration of pixels in original image
with levels near 0, a reasonable approach is to modify the
histogram of that image so that it does not have this property
Contd …
38/95
(a) Specified Histogram
(b) Transformations
(c) Enhanced Image Using
Mappings from Curve (2)
(d) Histogram of (c)
Contd …
39/95
The fig – (a) shows a manually specified function that
preserves the general shape of original histogram, but has a
smoother transition levels in dark region of the gray scale
Sampling this function into 256 equally spaced discrete
values produced the desired specified histogram
Transformation function G(z) obtained from this histogram
by using Eq. is labeled transformation – 1 in fig – (b)
Similarly, the inverse transformation from Eq. is labeled
transformation – 2 in fig – (b)
Contd …
40/95
The enhanced image in fig – (c) was obtained by applying
transformation – 2 to the pixels of the histogram equalized
image in fig – (b)
The improvement of the histogram specified image over the
result obtained by histogram equalization is evident by
comparing these two images
It is of interest to note that a rather modest change in the
original histogram was all required to obtain a significant
improvement in appearance
Contd …
41/95
The fig – (d) shows the histogram of fig – (c)
The most distinguishing feature of this histogram is how its
low end has shifted right towards the lighter region of the
gray scale
Contd …
42/95
Local Histogram Processing
Contd …
43/95
The number of pixels in these areas may have negligible
influence on the computation of a global transformation
whose shape does not necessarily guarantee the desired
local enhancement
The solution is to devise transformation functions based in
the image
The Histogram Equalization and Histogram Matching can
easily be adapted to Local Enhancement
The procedure is to define a neighborhood and move its
center from pixel to pixel
Contd …
44/95
At each location histogram of the points in neighborhood is
computed and either a histogram equalization or histogram
matching transformation function is obtained
This function is used to map the intensity of pixel centered
in the neighborhood
The center of the neighborhood region is then moved to an
adjacent pixel location and the procedure is repeated
Contd …
45/95
Because only one row or column of the neighborhood
updating the histogram obtained in previous location with
the new data introduced at each motion step is possible
This approach has obvious advantages over repeatedly
computing the histogram of all pixels in the neighborhood
region each time the region is moved one pixel location
Another approach which is used to reduce computations is
to utilize non-overlapping regions, but this method
produces an undesirable blocky effect
Contd …
46/95
m pl
Exa
e
Contd …
47/95
The fig – (a) shows an 8 – bit 512 X 512 image that appears
to contain five black squares on a gray background
The image is slightly noisy but the noise is imperceptible
The fig – (b) shows result of global histogram equalization
The histogram equalization of smooth and noisy regions
shows a significant enhancement of the noise
Contd …
48/95
The fig – (b) does not reveal any significant details from
the
image other than a very faint hint that top left and bottom
right squares contain an object
The fig – (c) is a significant detail contained within dark
squares can be seen
The intensity values of these objects were too close to the
intensity of the large squares and their sizes were too small
to influence global histogram equalization significantly
enough to slow this detail
Contd …
49/95
Using Histogram Statistics for Image Enhancement
corresponding to value ri
Contd …
50/95
The nth moment of r about its mean is defined as –
51/95
FUNDAMENTALS OF SPATIAL FILTERING
Spatial Domain
Spatial Filtering
Spatial Domain Process
Linear Spatial Filtering
Non-Linear Spatial Filtering
Correlation
Convolution
Vector Representation of Linear Filtering
Generating Spatial Filter Masks
Contd …
52/95
SMOOTHING SPATIAL FILTERS
Smoothing Linear Filters
Example – I
Example – II
Order Statistic (Non-Linear) Filters
Example – III
Contd …
53/95
p l e -
Exa m
I
Fig. 2.14 – (a) Image of Size 528X485 Pixels from the Hubble Space Telescope
(b) Image Filtered with a 15X15 Averaging Mask
(c) Result of Thresholding (b)
Contd …
55/95
pl e -
E x a m
I II
Fig. 2.15 – (a) X-Ray Image of Circuit Board Corrupted by Salt & Pepper
Noise
(b) Noise Reduction with a 3X3 Averaging Mask
(c) Noise Reduction with a 3X3 Median Filter
56/95
SHARPENING SPATIAL FILTERS
Foundation
Example – I
Using The Second Derivative for Image Sharpening –
The Laplacian
Example – II
Unsharp Masking and High Boost Filtering
Example – III
Example – IV
Using First Order Derivatives for Non-Linear Image Sharpening –
The Gradient
Example – V
Contd …
57/95
pl e -
E xam
I
Fig. 2.16 – Illustration of the First and Second Derivatives of a 1-D Digital Function
Representing a Section of a Horizontal Intensity Profile from an Image Contd …
58/95
pl e -
E x am
II
Fig. 2.17 – (a) Blurred Image of the North Pole of the Moon
(b) Laplacian without Scaling (c) Laplacian with Scaling
(d) Image Sharpened using the Mask I (e) Result of using the Mask II Contd …
59/95
p l e -
E xa m
III
Fig. 2.19 – (a) Original Image (b) Result of Blurring with a Gaussian Filter
(c) Unsharp Mask (d) Result of using Unsharp Masking
Contd …
(e) Result of using High Boost Filtering
61/95
pl e -
Ex am
V
62/95
BASICS OF FILTERING IN FREQUENCY
DOMAIN
Characteristics of Frequency Domain
Example – I
Frequency Domain Filtering Fundamentals
Example – II
Example – III
Example – IV
Example – V
Example – VI
Contd …
63/95
CONTD …
Contd …
64/95
pl e -
Exa m
I
Contd …
65/95
pl e -
E x am
II
Fig. 2.22 – Result of Filtering the Image in Fig. 2.21(a) by setting 0 the term
F(M/2, N/2) in the Fourier Transform
Contd …
66/95
p l e -
E xa m
III
Contd …
67/95
pl e -
E xam
IV
Contd …
68/95
pl e -
Ex am
V
Contd …
69/95
pl e -
Exa m
VI
Fig. 2.27 – (a) Image Resulting from Multiplying by 0.5 the Phase Angle
and then Computing the IDFT
(b) The Result of Multiplying the Phase by 0.25.
The Spectrum was not changed in either of the two cases
Contd …
71/95
p l e -
Exam
VIII
Contd …
73/95
pl e -
Ex am
X
Fig. 2.30 – (a) A Spatial Mask and Perspective Plot of its Corresponding Frequency
Domain Filter (b) Filter Shown as an Image
(c) Result of Filtering Fig. 2.29(a) in the Frequency Domain with the Filter in (b)
(d) Result of Filtering the Same Image with the Spatial Filter in (a)
74/95
IMAGE SMOOTHING
USING FREQUENCY DOMAIN FILTERS
Types of Filters
Ideal LPF
Example – I
Example – II
Example – III
Example – IV
Butterworth LPF
Example – V
Example – VI
Example – VII
Gaussian LPF
Example – VIII
Example – IX
Contd …
75/95
pl e -
Ex am
I
Fig. 2.31 – (a) Perspective Plot of an Ideal Low Pass Filter Transfer Function
(b) Filter Displayed as an Image
(c) Filter Radial Cross Section
Contd …
76/95
pl e -
E x am
II
Contd …
77/95
pl e -
E x a m
I II
Contd …
79/95
pl e -
Ex am
V
Contd …
80/95
pl e -
Exa m
VI
Contd …
82/95
pl e -
Exam
VIII
Contd …
83/95
pl e -
E xam
IX
84/95
IMAGE SHARPENING
USING FREQUENCY DOMAIN FILTERS
Types of Filters
Ideal HPF
Example – I
Example – II
Example – III
Butterworth HPF
Example – IV
Example – V
Gaussian HPF
Example – VI
Contd …
85/95
pl e -
Exa m
I
Fig. 2.43 – Top Row: Perspective Plot, Image Representation and Cross
Section of a Typical Ideal High Pass Filter
Middle & Bottom Rows: The Same Sequence for BHPFs and GHPFs
Contd …
86/95
pl e -
E x am
II
Contd …
87/95
pl e -
E x a m
I II
Fig. 2.45 – Results of High Pass Filtering the Images in Fig. 2.32(a) using an
IHPF with D0 = 30, 60 and 160
Contd …
88/95
pl e -
E xam
IV
Fig. 2.46 – Results of High Pass Filtering the Image in Fig. 2.32(a) using a
BHPF of Order 2 with D0 = 30, 60 and 160, Corresponding to the Circles in
Fig. 2.32(b)
These Results are Much Smoother than Those Obtained with an IHPF
Contd …
89/95
pl e -
Ex am
V
Fig. 2.47 – Results of High Pass Filtering the Image in Fig. 2.32(a) using a
GHPF with D0 = 30, 60 and 160 & Corresponding to the Circles in Fig.
2.32(b)
Compare with Fig. 2.45 and Fig. 2.46
Contd …
90/95
pl e -
Exa m
VI
91/95
SELECTIVE FILTERING
Band Reject & Band Pass Filters
Notch Filters
Contd …
92/95
pl e -
Ex am
I
Contd …
93/95
pl e -
E x am
II
Fig. 2.50 – (a) Sampled News Paper Image Showing a Moiré Pattern (b) Spectrum
Contd …
(c) Butterworth Notch Reject Filter Multiplied by the Fourier Transform (d) Filtered Image
94/95
pl e -
E x a m
I II
Fig. 2.51 – (a) 674 X 674 Image of Saturn Rings Showing Nearly Periodic Interference
(b) Spectrum: The Burst of Energy in Vertical Axis near Origin Correspond to Interference Pattern
(c) A Vertical Notch Reject Filter (d) Result of Filtering
95/95
IMAGE SEGMENTATION FUNDAMENTALS
Segmentation
5 – Conditions
Edge Based Segmentation
Region Based Segmentation
Example
mp l
Exa
e
95/95
DETECTION OF DISCONTINUITIES
Introduction
Point Detection
Example – I
Line Detection
Example – II
Example – III
Edge Detection
Example – IV
Example – V
Example – VI
CONTD …
Basic Edge Detection
Example – VII
Gradient Operators
Example – VIII
Example – IX
Example – X
Example – XI
p le -
Exam
I
95/95
p le -
Exam
II
95/95
l e -
Ex amp
V
Fig. 2.58 – A 1508 X 1970 Image Showing (Zoomed) Actual Ramp (Bottom, Left),
Step (Top, Right) and Roof Edge Profiles
The Profiles are from Dark to Light in the Areas Indicated by the Short Line Segments
Shown in the Small Circles
The Ramp and Step Profiles Span 9 Pixels and 2 Pixels Respectively
The Base of the Roof Edge is 3 Pixels
95/95
l e -
a mp
Ex
VI
95/95
l e -
am p
Ex
VII
95/95
l e -
m p
x a
E I
I I
V
Fig. 2.64 – (a) Original Image of Size 834 X 1114 Pixels with Intensity Values
Scaled to the Range [0, 1]
(b) Mod of │gx│, The Component of the Gradient in the x – Direction,
obtained Using the Sobel Mask (c)│gy│
(d) The gradient Image, Mod of │gx│ + │gy│
95/95
l e -
a mp
Ex
IX
95/95
l e -
am p
Ex
X
95/95
l e -
a mp
Ex
XI
95/95
l e -
mp
Exa
XII
Fig. 2.68 – (a) Threshold Version of the Image in Fig. 2.62(d) with the
Threshold Selected as 33% of the Highest Value in the Image; This Threshold
is high enough to Eliminate Most of the Brick Edges in the Gradient Image
(b) Threshold Version of the Image in Fig. 2.64(d), Obtained Using a
Threshold Equal to 33% of the Highest Value in that Image
95/95