Lecture 03
Lecture 03
Lecture # 3
Spatial Enhancement-I
1
Image Enhancement
2
Image Enhancement
3
Image Enhancement
4
Image Enhancement
Process an image so that the result is more suitable than the original image for a
specific application
5
Types of image enhancement
operations
6
Types of image enhancement
operations
Point/Pixel operations
Output value at specific coordinates
(x,y) is dependent only on the input
value at (x,y)
Local operations
The output value at (x,y) is dependent
on the input values in the
neighborhood of (x,y)
Global operations
The output value at (x,y) is dependent
on all the values in the input image
7
Basic Concepts
Most spatial domain enhancement
operations can be generalized as:
g ( x, y) T f ( x, y )
8
Point Processing
s T (r )
r = gray level of f at (x,y)
s = gray level of g at (x,y)
10
Point Processing using Look-up Tables
A look-up table (LUT)
implements a functional
mapping.
255
101 64
102 68
127
103 69
104 70
105 70
106 71
0
11
Point Processing using Look-up Tables
input output
...0 ... 0
cell index
contents
64
a pixel with ... ...32 is mapped to
this value this value
128 128
... ...
192 224
... ...
255 255
12
POINT PROCESSING
15
Point Processing Example:
Thresholding
16
Point Processing Example:
Thresholding
Segmentation of an object of interest from a
background
17
Point Processing Example:
Intensity Scaling
s T (r ) a.r
18
Point Processing Transformations
There are many different kinds of grey level
transformations
Three of the most
common are shown
here
Linear
Negative/Identity
Logarithmic
Log/Inverse log
Power law
19
Point Processing Example:
Negative Images
Reverses the gray level order
For L gray levels, the transformation has the
form:
s ( L 1) r
Negative images are useful for enhancing white or grey detail embedded in
dark regions of an image
20
Point Processing Example:
Negative Images
21
Logarithmic Transformations
The general form of the log transformation is
s c log(1 r )
The log transformation maps a narrow range of low input grey level values into
a wider range of output values
The inverse log transformation performs the opposite transformation
22
Logarithmic Transformations
Properties
For lower amplitudes of
input image the range of
gray levels is expanded
For higher amplitudes of
input image the range of
gray levels is compressed
23
Logarithmic Transformations
Application
This transformation is suitable for the case when the
dynamic range of a processed image far exceeds the
capability of the display device (e.g. display of the
Fourier spectrum of an image)
Also called “dynamic-range compression / expansion”
24
Logarithmic Transformations
25
Power Law Transformations
Power law transformations have the following form
s c r
Map a narrow range
of dark input values
into a wider range of
output values or vice
versa
Varying γ gives a whole
family of curves
26
Power Law Transformations
For < 1: Expands values of dark pixels, compress
values of brighter pixels
For > 1: Compresses values of dark pixels,
expand values of brighter pixels
If =1 & c=1: Identity transformation (s = r)
28
Power Law Transformations
Contrast Enhancement
29
Power Law Transformations
Contrast Enhancement
γ = 0.6
1
Transformed Intensities
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Old Intensities
30
Power Law Transformations
Contrast Enhancement
γ = 0.4
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
31
Power Law Transformations
Contrast Enhancement
γ = 0.3
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
32
Power Law Transformations
Contrast Enhancement
34
Power Law Transformations
Contrast Enhancement
35
Image Enhancement
Aerial Result of
Power law
Image
transformation
c = 1, = 3.0
(suitable)
Result of
Power law
Result of transformation
Power law c = 1, = 5.0
transformation (high contrast,
c = 1, = 4.0 some regions are
(suitable) too dark)
36
Piecewise Linear Transformation
Functions
Contrast stretching
37
Contrast Stretching
Objective
Increase the dynamic range of
the gray levels for low contrast
images
Rather than using a well
defined mathematical
function we can use arbitrary
user-defined transforms
r1 = rmin & s1 = 0
r2 = rmax & s2 = L-1
39
Contrast Stretching
40
Grey Level Slicing
Highlights range
[A,B] of gray Highlights range
levels and reduces [A,B] but
all others to a preserves all
contrast level other gray
levels
41
Grey Level Slicing
42
Histogram of a Grayscale Image
43
Histogram of a Grayscale Image
44
HISTOGRAM
• A discrete function h(rk)=nk
– rk is the kth gray level
– nk is the number of pixels having gray level rk in the
image
• Ex:
nk
6
5
0 1 2 3 4
1 3 3 0 3
0 1 3 0 2
1
3 0 3 1 rk
0 1 2 3
45
UNIQUENESS
46
Histogram of a Grayscale Image
Histogram of a digital image with gray levels in the range [0,L-1] is a
discrete function
h(rk ) nk
Where
rk = kth gray level
nk = number of pixels in the image having gray level rk
h(rk) = histogram of an image having rk gray levels
47
Normalized Histogram
Dividing each of histogram at gray level rk
by the total number of pixels in the image,
n
p(rk ) nk / n for k 0,1, , L 1
48
Histogram of a Grayscale Image
49
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
50
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
51
Histogram of a Grayscale Image
hI g the number
of pixels in I
with graylevel g.
52
Histogram of a Color Image
If I is a 3-band image
then I(r,c,b) is an integer between 0 and 255.
I has 3 histograms:
hR(g) = # of pixels in I(:,:,1) with intensity value g
hG(g) = # of pixels in I(:,:,2) with intensity value g
hB(g) = # of pixels in I(:,:,3) with intensity value g
53
Histogram of a Color Image
54
Histogram of a Color Image
55
Histogram of a Color Image
56
Histogram: Example
Dark Image
Bright Image
57
Histogram: Example
Dark image
Components of
histogram are
concentrated on
the low side of
the gray scale
Bright image
Components of
histogram are
concentrated on
the high side of
the gray scale
58
HISTOGRAM INSIGHT INTO CONTRAST
59
Histogram: Example
60
Histogram: Example
62
Contrast Stretching
255
L
L 1
s T (r ) (r rmin )
127
max min
r r
0
0 rmin 127 rmax255
63
Contrast Stretching
64
Histogram Equalization
65
HISTOGRAM EQUALIZATION
66
AERIAL PHOTOGRAPH OF THE PENTAGON
68
The Probability Distribution Function
of an Image
69
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray
level. The probability that q ≤ g is given by
g
1 g
h
I
PI g pI hI 0
255
,
h
0 A 0
I
0
where hI(γ ) is
the histogram of This is the probability that
image I. any given pixel from I has
value less than or equal to g.
70
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray Also called CDF
level. The probability that q ≤ g is given by for “Cumulative
Distribution
Function”.
g
g
1 g
h
I
PI g pI hI 0
255
,
h
0 A 0
I
0
where hI(γ ) is
the histogram of This is the probability that
image I. any given pixel from I has
value less than or equal to g.
71
The Cumulative Distribution Function
of an Image
• P(g) is the fraction of pixels in an image that have intensity
values less than or equal to g.
• P(g) is the probability that a pixel randomly selected from
the given band has an intensity value less than or equal to
g.
• P(g) is the cumulative (or running) sum of p(g) from 0
through g inclusive.
• P(0) = p(0) and P(255) = 1;
72
Histogram Equalization
Let PI
be the cumulative (probability) distribution function of I.
73
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
CDF
74
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
LUT
75
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
LUT
76
Histogram Equalization
77
Histogram Equalization
Luminosity
before
J r , c 255 PI I r , c .
after
78
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0
1 1 1 1 4
4 5 6 6 6
8 8 8 8 9
79
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0 2 2 2 2 2
1 1 1 1 4 4 4 4 4 5
4 5 6 6 6 5 5 7 7 7
8 8 8 8 9 9 9 9 9 9
Gray levels 0 1 2 3 4 5 6 7 8 9
Counts (h(rk)) 5 4 0 0 2 1 3 0 4 1
r0 r1 r2 r3 r4 r5 r6
sk =round(9•F(rk)) 2 4 5 5 7 9 9
s0 s1 s2 s3 s4 s5 s6
80
Histogram Equalization: Example
An 8x8 image
81
Histogram Equalization: Example
Fill in the following table/histogram
82
Histogram Equalization: Example
83
Histogram Equalization: Example
84
Histogram Equalization: Example
85
Histogram Equalization: Example
86
Histogram Equalization: Example
87
Histogram Equalization: Example
88
Histogram Equalization: Example
J r , c 255 PI I r , c .
If cdf is normalized
s round (255.cdf (r ))
If cdf is NOT normalized
cdf (r )
s round (255. )
M N
s round (255. 46 / 64 )
s 183
183
Original Image
89
Histogram Equalization: Example
90
Histogram Equalization: Example
Equalized Histogram
92
Histogram Equalization: Example
Equalized Histogram
Low contrast
High Contrast
Equalized Histogram
93
HISTOGRAM MATCHING
(SPECIFICATION)
• HISTOGRAM EQUALIZATION DOES NOT ALLOW
INTERACTIVE IMAGE ENHANCEMENT AND
GENERATES ONLY ONE RESULT: AN
APPROXIMATION TO A UNIFORM HISTOGRAM.
• SOMETIMES THOUGH, WE NEED TO BE ABLE TO
SPECIFY PARTICULAR HISTOGRAM SHAPES
CAPABLE OF HIGHLIGHTING CERTAIN GRAY-LEVEL
RANGES.
94
HISTOGRAM SPECIFICATION
• THE PROCEDURE FOR HISTOGRAM-SPECIFICATION BASED
ENHANCEMENT IS:
k nj
s T (rk )
j 0 n
k
vk G z k p z z i s k
i 0
96
HISTOGRAM SPECIFICATION
97
MAPPINGS
98
HISTOGRAM SPECIFICATION
99
HISTOGRAM SPECIFICATION
k nk pr(rk) sk pz(zk) vk nk
0 790 0.19 0.19 0 0 0
1 1023 0.25 0.44 0 0 0
2 850 0.21 0.65 0 0 0
3 656 0.16 0.81 0.15 0.15 790
4 329 0.08 0.89 0.2 0.35 1023
5 245 0.06 0.95 0.3 0.65 850
6 122 0.03 0.98 0.2 0.85 985
7 81 0.02 1.0 0.15 1.0 448
101
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
102
103
GLOBAL/LOCAL HISTOGRAM EQUALIZATION
• IT MAY BE NECESSARY TO ENHANCE DETAILS OVER SMALL AREAS IN THE
IMAGE
• 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
• DEVISE TRANSFORMATION FUNCTIONS BASED ON THE GRAY LEVEL
DISTRIBUTION IN THE NEIGHBORHOOD OF EVERY PIXEL IN THE IMAGE
• THE PROCEDURE IS:
– DEFINE A SQUARE (OR RECTANGULAR) NEIGHBORHOOD AND MOVE THE
CENTER OF THIS AREA FROM PIXEL TO PIXEL.
– AT EACH LOCATION, THE HISTOGRAM OF THE POINTS IN THE
NEIGHBORHOOD IS COMPUTED AND EITHER A HISTOGRAM
EQUALIZATION OR HISTOGRAM SPECIFICATION TRANSFORMATION
FUNCTION IS OBTAINED.
– THIS FUNCTION IS FINALLY USED TO MAP THE GRAY LEVEL OF THE PIXEL
CENTERED IN THE NEIGHBORHOOD.
– THE CENTER IS THEN MOVED TO AN ADJACENT PIXEL LOCATION AND THE
PROCEDURE IS REPEATED.
104
GLOBAL/LOCAL HISTOGRAM EQUALIZATION
105
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• LET r REPRESENT A GRAY LEVEL IN THE IMAGE [0, L-1], AND LET p(ri )
DENOTE THE NORMALIZED HISTOGRAM COMPONENT
CORRESPONDING TO THE ith VALUE OF r.
• THE nth MOMENT OF r ABOUT ITS MEAN IS DEFINED AS
L 1 n
n r ri m pri
i 0
• WHERE m IS THE MEAN VALUE OF r (AVERAGE GRAY LEVEL)
m i 0 ri pri
L 1
106
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• THE SECOND MOMENT IS GIVEN BY
L 1 2
2 r ri m pri
i 0
107
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Local)
• LET (x,y) BE THE COORDINATES OF A PIXEL IN AN
IMAGE, AND LET SX,Y DENOTE A NEIGBORHOOD OF
SPECIFIED SIZE, CENTERED AT (x,y)
• THE MEAN VALUE mSXY OF THE PIXELS IN SX,Y IS
ms xy r s ,t prs ,t
s ,t
S xy
• THE GRAY LEVEL VARIANCE OF THE PIXELS IN
REGION SX,Y IS GIVEN BY
S xy
2
r s ,t
msxy prs ,t
2
s ,t S xy
108
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT
• THE GLOBAL MEAN AND VARIANCE ARE MEASURED
OVER AN ENTIRE IMAGE AND ARE USEFUL FOR
GROSS ADJUSTMENTS OF OVERALL INTENSITY AND
CONTRAST.
• A USE OF THESE MEASURES IN LOCAL
ENHANCEMENT IS, WHERE THE LOCAL MEAN AND
VARIANCE ARE USED AS THE BASIS FOR MAKING
CHANGES THAT DEPEND ON IMAGE
CHARACTERISTICS IN A PREDEFINED REGION ABOUT
EACH PIXEL IN THE IMAGE.
109
TUNGSTEN FILAMENT IMAGE
110
USE OF HISTOGRAM STATISTICS FOR IMAGE ENHANCEMENT
111
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
112
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
113
Readings from Book (3rd Edn.)
• 3.1 Image Enhancement &
Transformations
• 3.2 Basic Intensity
Transformation Functions
• 3.3 Histogram
Acknowledgements
Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
Pattern Recognition and Analysis Course – A.K. Jain, MSU
Material in these slides has been taken from, the following resources
115