Digital Image Processing: Lecture # 3 Spatial Enhancement-I
Digital Image Processing: Lecture # 3 Spatial Enhancement-I
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
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
6
Basic Concepts
Most spatial domain enhancement
operations can be generalized as:
g ( x, y ) T f ( x, y )
7
Point Processing
s T (r )
r = gray level of f at (x,y)
s = gray level of g at (x,y)
9
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
10
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
11
POINT PROCESSING
12
Point Processing Example:
Thresholding
13
Point Processing Example:
Thresholding
Segmentation of an object of interest from a
background
14
Point Processing Example:
Intensity Scaling
s T (r ) a.r
15
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
16
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
17
Point Processing Example:
Negative Images
18
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
19
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
20
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”
21
Logarithmic Transformations
22
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
23
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)
25
Power Law Transformations
Contrast Enhancement
26
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
27
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
28
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
29
Power Law Transformations
Contrast Enhancement
31
Power Law Transformations
Contrast Enhancement
32
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)
33
Piecewise Linear Transformation
Functions
Contrast stretching
34
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
36
Contrast Stretching
37
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
38
Grey Level Slicing
39
Histogram of a Grayscale Image
40
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
41
UNIQUENESS
42
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
43
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
44
Histogram of a Grayscale Image
45
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
46
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
47
Histogram of a Grayscale Image
hI g the number
of pixels in I
with graylevel g .
48
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
49
Histogram of a Color Image
50
Histogram of a Color Image
51
Histogram of a Color Image
52
Histogram: Example
Dark Image
Bright Image
53
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
54
HISTOGRAM INSIGHT INTO CONTRAST
55
Histogram: Example
56
Histogram: Example
58
Contrast Stretching
255
L
L 1
s T (r ) (r rmin )
127
max min
r r
0
0 rmin 127 rmax255
59
Contrast Stretching
60
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
62