Module 3
Module 3
MODULE 3
IMAGE ENHANCEMENT
Image Enhancement
Image enhancement techniques are designed to improve the quality
of an image as perceived by human being
1
8/3/2022
Types of operations
Rectangular neighborhood
2
8/3/2022
3
8/3/2022
• Image Negatives
• Log Transformation
• Power law transformation
• Contrast Stretching
• Gray-level Thresholding
• Bit Plane slicing
4
8/3/2022
Image Negative
S=L-1-r
10
5
8/3/2022
11
Log Transformation
12
6
8/3/2022
13
14
7
8/3/2022
15
16
8
8/3/2022
17
18
9
8/3/2022
19
20
10
8/3/2022
21
22
11
8/3/2022
23
Original image
Contrast stretching
• Enhancing low contrast images
24
12
8/3/2022
Thresholding
• In hard thresholding, the pixels having intensity lower than the
Threshold are set to zero and the other pixels having intensity value
greater than threshold are set to maximum intensity value
• Thresholding used to obtain binary image from grayscale image
25
26
13
8/3/2022
27
28
14
8/3/2022
29
30
15
8/3/2022
• Instead of highlighting gray-level ranges, highlighting the contribution made to total image
appearance by specific bits might be desired
• For an 8 bit image, 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.
• 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
31
32
16
8/3/2022
33
34
17
8/3/2022
Histogram equalization
• Histogram
• A image histogram is the graphical representation between number of pixels and
intensity values
35
36
18
8/3/2022
Histogram Equalization
• Equalisation is a process that attempts to spread out the gray levels in
an image so that they are evenly distributed across their range
• It reassigns the brightness values of pixels based on the image
histogram
37
38
19
8/3/2022
Spatial Filtering
39
Origin x
y Image f (x, y)
40
40
20
8/3/2022
The above is repeated for every pixel in the original image to generate the filtered image
41
41
Original Image
42
42
21
8/3/2022
43
43
44
44
22
8/3/2022
45
45
46
46
23
8/3/2022
47
• Spatial filtering term is the filtering operations that are performed directly
on the pixels of an image
48
24
8/3/2022
49
f ( x, y ) w ( 1 , 1 ) f ( x 1 , y 1 ) w ( 1 , 0 ) f ( x 1 , y ) w ( 1 ,1 ) f ( x 1 , y 1 )
w ( 0 , 1 ) f ( x , y 1 ) w ( 0 , 0 ) f ( x , y ) ww(1,-1)
( 0 ,1 ) f w(1,0)
( x , y w(1,1)
1)
w ( 1 , 1 ) f ( x 1 , y 1 ) w ( 1 , 0 ) f ( x 1 , y ) w ( 1 ,1 ) f ( x 1 , y 1 ) 50
25
8/3/2022
51
52
26
8/3/2022
53
99
95
106
90
98
85
* 1/
1/
9
1/
1/
9
1/
1/
9
9 9 9
1/
1049
1/
1009
1/
1089
Original Image Filter
Simple 3*3 1/
99 1 /9
106 1/
98
3*3 Smoothing Pixels
9 9
Neighbourhood 195
/9 190
/9 185
/9
Filter
e = 1/9*106 +
1/ *104 + 1/ *100 + 1/ *108 +
9 9 9
1/ *99 + 1/ *98 +
9 9
y Image f (x, y) 1/ *95 + 1/ *90 + 1/ *85
9 9 9
= 98.3333
The above is repeated for every pixel in the original image to generate the smoothed image
54
54
27
8/3/2022
1 1 1 1 2 1
1 1
1 1 1 2 4 2
9 16
1 1 1 1 2 1
1 1 1 1 1
1 1 1 1 1
1 1
1 1 1 1 1
25 ?
1 1 1 1 1
1 1 1 1 1
56
28
8/3/2022
2 6 4 7
57
2 6 4 7
58
29
8/3/2022
2 6 4 7
59
0 2 6 4 7 0
0 0 0 0 0 0
60
30
8/3/2022
0 2 6 4 7 0
0 0 0 0 0 0
61
1 2 3 2 1 2 2 1
4 2 5 1 1 3 3 2
1 2 6 3 2 4 4 3
2 6 4 7 1 2 3 2
62
31
8/3/2022
2 2 6 4 7 7
2 2 6 4 7 7
63
0 0 0 0 0 0
0 2 6 4 7 0
0 0 0 0 0 0
64
32
8/3/2022
Result of Replication
1 2 3 2 2 3 2 2
4 2 5 1 2 3 3 3
1 2 6 3 3 4 4 4
2 6 4 7 3 4 5 5
65
Original Image
66
33
8/3/2022
a b
w (s, t) f ( x s, y t)
g (x, y) s atb
a b
s atb
w (s,t)
67
Original image
Smooth by 3x3 box
Size: 500x500 filter
34
8/3/2022
69
70
35
8/3/2022
Order-Statistic Filtering
71
71
Order-Statistics Filters
• Order-statistics filters are nonlinear spatial filters whose response is
based on ordering (ranking)
• the pixels contained in the image area encompassed by the filter, and
then replacing the value of the center pixel with the value determined
by the ranking result.
• Best-known “median filter”
72
36
8/3/2022
Median Filtering
Median = ? 20
73
73
Median Filtering
74
74
37
8/3/2022
75
5th
76
38
8/3/2022
77
78
39
8/3/2022
79
1st Derivative
The 1st derivative of a function is given by:
f
f ( x 1) f ( x )
x
Its just the difference between subsequent values and
measures the rate of change of the function
80
40
8/3/2022
2nd Derivative
2 f
f ( x 1) f ( x 1) 2 f ( x )
intox account the values both before and after the current value
Simply takes
2
81
The 2nd derivative is more useful for image enhancement than the 1st derivative -
Stronger response to fine detail
82
41
8/3/2022
Laplacian Filter
The Laplacian is defined as follows:
2 f 2 f
2
f 2 2
x y
2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x , y )
2x
2 f
f ( x , y 1) f ( x , y 1) 2 f ( x , y )
2y
83
Laplacian Filter
So, the Laplacian can be given as follows:
2
f [ f ( x 1, y ) f ( x 1, y )
f ( x , y 1 ) f ( x , y 1 )]
4 f (x, y)
Can we implement it using a filter/ mask? 0 1 0
1 -4 1
0 1 0
84
42
8/3/2022
Laplacian Filter
85
Laplacian Filter
Applying the Laplacian to an image we get a new image
that highlights edges and other discontinuities
43
8/3/2022
Laplacian
Filtered Image
Scaled for Display
f ( x, y ) 2 f , w5 0
g ( x, y )
f ( x, y ) 2 f , w5 0
87
- =
Original Laplacian Sharpened
Image Filtered Image Image
In the final sharpened image edges and fine detail are much
more obvious
88
44
8/3/2022
• Used to retain some of the low frequency components to aid in the interpretation of an image
• Where 𝐴 is the amplification factor and low pass component is the blurred version of the original
image
89
Unsharp masking
• One of the techniques typically used for edge enhancement
• In this approach, smoothened version of the image is subtracted from
original image;hence, tipping the balance towards the sharper
content of the image
90
45
8/3/2022
91
Unsharp masking
46
8/3/2022
f
G x x
f f
G y
y
93
f mag ( f )
G 2
x G 2
y
1
2
1
f 2 f
2
2
x y
For practical reasons this can be simplified as:
f Gx G y
94
47
8/3/2022
Gradient Operators
There is some debate as to how best to calculate these gradients
Simplest Operator
f f
( z8 z5 ), ( z6 z5 )
yx xy
f ( z8 z5 ) 2 ( z 6 z5 ) 2
f ( z8 z5 ) ( z6 z5 )
95
Gradient Operators
Prewitt Operator
f ( z 7 z 8 z 9 ) ( z1 z 2 z 3 )
( z 3 z 6 z 9 ) ( z1 z 4 z 7 )
-1 -1 -1 -1 0 1
f f
0 0 0 -1 0 1
y 1 1 1
x -1 0 1
Extract horizontal edges Extract vertical edges
96
48
8/3/2022
Gradient Operators
Sobel Operator
-1 -2 -1 -1 0 1
f f
0 0 0 -2 0 2
y 1 2 1
x -1 0 1
Extract horizontal edges Extract vertical edges
f ( z 7 2 z 8 z 9 ) ( z1 2 z 2 z 3 )
( z 3 2 z 6 z 9 ) ( z1 2 z 4 z 7 )
Emphasize more the current point (y direction)
Pixel Arrangement
97
An image of a contact
lens which is
enhanced in order to
make defects more
obvious
98
49
8/3/2022
99
• In spatial domain, filtering is done by convolving the input image 𝑓(𝑥, 𝑦) with the
kernel h(𝑥, 𝑦)
100
50
8/3/2022
101
102
51
8/3/2022
103
104
52
8/3/2022
105
Ringing Effect
106
53
8/3/2022
107
108
54
8/3/2022
109
110
55
8/3/2022
111
2D - LPF
Filtering with filters having cut-off frequencies equal to distance of radii equal to 10, 30, 60, 160 and 460,
enclosing 87, 93.1, 95.7, 97.8 and 99 % image power.
112
ILPF BLPF GLPF
56
8/3/2022
2 D HPF
Ideal
Butterworth
Gaussian
113
Homomorphic Filtering
114
57
8/3/2022
115
• An image f(x, y) can be expressed as the product of illumination and reflectance components:
• Equation above cannot be used directly to operate separately on the frequency components of
illumination and reflectance because the Fourier transform of the product of two functions is not
separable; in other words,
• where Fi (u, v) and Fr (u, v) are the Fourier transforms of ln i(x, y) and ln r(x, y), respectively
116
58
8/3/2022
117
118
59
8/3/2022
119
2 D convolution
120
60
8/3/2022
121
122
61
IMAGE ENHANCEMENT IN FREQUENCY DOMAIN
Fig: ideal low pass filter 3-D view and 2-D view and line graph
Effect of different cutoff frequencies:
As the cutoff frequency decreases,
image becomes more blurred
Noise becomes increases
Analogous to larger spatial filter sizes
The Ideal LPF has sharp cutoffs or discontinuities which cause ringing.
The ILPF has a sinc function behaviour in the Spatial Domain.
The center of lobe is the cause for blurring but the outer smaller lobes cause ringing.
We want to achieve blurring with little ringing.
-
Transfer function does not have sharp discontinuity establishing cutoff between passed and
filtered [Link] off frequency D0 defines point at which H(u,v) = 0.5
Fig. (a) perspective plot of a Butterworth lowpass-filter transfer function. (b) Filter displayed
as an image. (c)Filter radial cross sections of order 1 through 4.
Unlike the ILPF, the BLPF transfer function does not have a sharp discontinuity that gives a
clear cutoff between passed and filtered frequencies. In BLPFA 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.
GAUSSIAN LOWPASS FILTERS (GLPF):
When high-pass filter attenuates frequencies, low-pass filter passes them. A high pass filter is
obtained from a given low pass filter using the equation.
H hp (u,v) = 1- Hlp (u,v)
Where Hlp (u,v) is the transfer function of the low-pass filter. That is when the low- pass filter attenuates
frequencies, the high-pass filter passed them, and vice-versa.
Fig.. shows typical 3-D plots, image representations and cross sections for these filters. The
Butter-worth filter represents a transition between the sharpness of the ideal filter and the broad
smoothness of the Gaussian filter.
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
= 1, if D(u,v) ˃ D0
The IHPF is the opposite of the ILPF in the sense that it sets to zero all frequencies inside a circle of
radius D0 while passing, without attenuation, all frequencies outside the circle. As in case of the
ILPF, the IHPF is not physically realizable.
Butter-worth high-pass filters:
A 2-D Butter-worth high-pass filter (BHPF) of order n and cutoff frequency D0 is defined as
1. Suggest a suitable filter that will reduce the impact of salt-and-pepper noise at the same time it
preserves the edges in the image.
The filter that will reduce the impact of salt-and-pepper noise with minimum blurring is a median filter.
2. Suggest a suitable filter that could minimise the impact of ‘Gaussian noise’?
Gaussian filter is an optimum filter that could reduce the impact of Gaussian noise.
10. If all the pixels in an image are shuffled, will there be any change in the histogram. Justify your
answer.
11. Can two different images have the same histogram? Justify your answer
Yes, there is a possibility that two different images can have the same histogram. For example, the
histograms of the original image and the flipped image are taken. Since the values of the pixels are not
affected by a ‘flipping’ operation, the histogram of the original image is the same as the histogram of the
flipped image. Even though the original and flipped images are different, their histograms remain the same.
From this illustration, it is obvious that two different images can have the same histogram.
12. What will we obtain if the arithmetic mean filter is applied to an image again and again? What will
happen if we use the median filter instead?
Iterative arithmetic mean filtering will ultimately blur the whole image with constant gray level. On the
other hand, iterative median filtering will only change once after the first round of filtering, and will remain
stable from that moment on which is invariant to the filter.
13. Two images have the same histogram. Which of the following properties must they have in
common? (i) Same total power (ii) Same entropy (iii) Same interpixel covariance function
The total power and entropy must be the same when two images have the same histogram, because the total
power and entropy depend only on the pixel values and not on the order they are arranged in the image.
The interpixel covariance function is not necessarily the same when two images have the same histogram.