Image Processing Chapter 2
Image Processing Chapter 2
Recognition (IPPR):
(Lecture 2)
• How many samples and gray levels are required for a “good”
approximation?
• The resolution (the degree of discernible detail) depends strongly on
these two parameters
18
of
Effects of reducing spatial
90
resolution
19
of
90
Effects of reducing gray levels
20
of
Basic relationships between
90
pixels
An image is denoted by: f(x,y)
Lowercase letters (e.g. p, q) will denote individual pixels
A subset of f(x,y) is denoted by S
Neighbors of a pixel:
– A pixel p at (x,y) has 4 horizontal/vertical neighbors at
• (x+1,y),(x-1,y),(x,y+1)and(x,y-1)
• called the 4-neighbors of p: N4(p)
– A pixel p at (x,y) has 4 diagonal neighbors at
• (x+1,y+1),(x+1,y-1),(x-1,y+1)and(x-1,y-1)
• called the diagonal–neighbors of p:ND(p)
– The 4-neighbors and the diagonal-neighbors of p are called
the 8-neighbors of p: N8(p)
21
of
90
Connectivity between pixels
• Connectivity is an important concept in establishing boundaries of
object and components of regions in an image
• When are two pixels connected?
– If they are adjacent in some sense (say they are 4-neighbors)
– and, if their gray levels satisfy a specified criterion of similarity (say
they are equal)
• Example: given a binary image (e.g. gray scale = [0,1]), two pixels
may be 4-neighbors but are not considered connected unless they
have the same value
22
of
90
Connectivity between pixels
• Let V be the set of values used to determine connectivity
– For example, in a binary image, V={1} for the connectivity of pixels
with a value of 1
– In a gray scale image, for the connectivity of pixels with a range of
intensity values of, say, 32 to 64, it follows that V={32,33,...,63,64}
– Consider three types of connectivity
• 4-connectivity: Pixels p and q with values from V are 4-connected if q is
in the set N4(p)
• 8-connectivity: Pixels p and q with values from V are 8-connected if q is
in the set N8(p)
• m-connectivity (mixed): Pixels p and q with values from V are
m-connected if
– q is in the set N4(p),or
– q is in the set ND(p) and the set N4(p) ∩ N4(q) is empty (This is the set of
pixels that are 4-neighbors of p and q and whose values are from V)
23
of
90
Connectivity between pixels
24
of
90
Pixel adjacencies and paths
• Pixel p is adjacent to q if they are connected
– We can define 4-, 8-, or m-adjacency depending on the
specified type of connectivity
• Two image subsets S1 and S2 are adjacent if some pixel in S1
is adjacent to S2
• A path from p at (x,y) to q at (s,t) is a sequence of distinct
pixels with coordinates (x0,y0), (x1,y1),....., (xn,yn)
– Where (x0,y0)=(x,y) and (xn,yn)=(s,t) and
– (xi,yi) is adjacent to (xi-1,yi-1) for 1<= i <= n
– n is the length of the path
• If p and q are in S, then p is connected to q in S if there is a
path from p to q consisting entirely of pixels in S
25
of
90
Example paths
26
of
90
Connected components
• For any pixel p in S, the set of pixels connected to p form a
connected component of S
• Distinct connected components in S are said to be disjoint
27
of
Labeling 4-connected
90
components
• Consider scanning an image pixel by pixel from left to right and
top to bottom
of
90
46
Image Enhancement Examples
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
47
Image Enhancement Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
48
Image Enhancement Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
49
Image Enhancement Examples (cont…)
50
of
90
Spatial & Frequency Domains
There are two broad categories of image
enhancement techniques
– Spatial domain techniques
• Direct manipulation of image pixels
– Frequency domain techniques
• Manipulation of Fourier transform or wavelet
transform of an image
For the moment we will concentrate on
techniques that operate in the spatial
domain
51
of
Basic Spatial Domain Image
90 Enhancement
Most spatial domain enhancement operations
can be reduced to the form
Origin x
g (x, y) = T[ f (x, y)]
where f (x, y) is the
input image, g (x, y) is
the processed image (x, y)
and T is some
operator defined over
some neighbourhood
of (x, y) y Image f (x, y)
52
of
90
Point Processing
The simplest spatial domain operations
occur when the neighbourhood is simply the
pixel itself
In this case T is referred to as a grey level
transformation function or a point processing
operation
Point processing operations take the form
s=T(r)
where s refers to the processed image pixel
value and r refers to the original image pixel
value
53
of
Point Processing Example:
90 Negative Images
Negative images are useful for enhancing
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Original Negative
s = 1.0 - r
Image Image
54
of
Point Processing Example:
90 Negative Images (cont…)
Original Image Enhanced Image x
x
s = intensitymax - r
55
of
Point Processing Example:
90 Thresholding
Thresholding transformations are particularly
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
57
Intensity Transformations
58
of
90
Basic Grey Level Transformations
There are many different kinds of grey level
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
transformations
Three of the most
common are shown
here
– Linear
• Negative/Identity
– Logarithmic
• Log/Inverse log
– Power law
• nth power/nth root
59
of
90
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
Compresses the dynamic range of images
with large variations in pixel values
60
of
90
Logarithmic Transformations (cont…)
s = log(1 + r)
61
of
90
Logarithmic Transformations (cont…)
s = log(1 + r)
We usually set c to 1
Grey levels must be in the range [0.0, 1.0]
62
of
90
Power Law Transformations
Power law transformations have the following
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
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
63
of
90
Power Law Transformations (cont…)
Original Image Enhanced Image x
x
s=rγ
We usually set c to 1
Grey levels must be in the range [0.0, 1.0]
64
of
90
Power Law Example
65
of
90
Power Law Example (cont…)
γ = 0.6
1
0.9
T ran sfo rm ed In ten sities
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
66
of
90
Power Law Example (cont…)
γ = 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
67
of
90
Power Law Example (cont…)
γ = 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
68
of
90
Power Law Example (cont…)
The images to the
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
right show a
s = r 0.6
magnetic resonance
(MR) image of a
fractured human
s = r 0.4
spine
Different curves
highlight different
detail
69
of
90
Power Law Example
70
of
90
Power Law Example (cont…)
γ = 5.0
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
71
of
90
Power Law Transformations (cont…)
An aerial photo
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of a runway is
shown s = r 3.0
This time
power law
transforms are
s = r 4.0
used to darken
the image
Different curves
highlight
different detail
72
of
90
Gamma Correction
Many devices used for image capture, display and printing
respond according to a power law
• The exponent in the power-law equation is referred to as
gamma
• The process of correcting for the power-law response is
referred to as gamma correction
• Example: – CRT devices have an intensity-to-voltage
response that is
a power function (exponents typically range from 1.8-2.5)
– Gamma correction in this case could be achieved by
applying the transformation s=r1/2.5=r^0.4
73
of
90
Gamma Correction
Many of you might be familiar with gamma
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
74
More Contrast Issues
75
of
Piecewise Linear Transformation
90 Functions
Rather than using a well defined mathematical
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
– Similar to thresholding
– Other levels can be
suppressed or maintained
– Useful for highlighting features
in an image
79
of
90
Bit Plane Slicing
Often by isolating particular bits of the pixel
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
[10000000] [01000000]
[00100000] [00001000]
[00000100] [00000001]
81
of
90
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
[10000000] [01000000]
[00100000] [00001000]
[00000100] [00000001]
82
of
90
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
83
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
84
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
85
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
86
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
87
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
88
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
89
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
90
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of
90
91
Bit Plane Slicing (cont…)
92
of
90
Bit Plane Slicing (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Reconstructed image
using only bit planes 8 and
7
Reconstructed image
using only bit planes 8, 7
and 6
Reconstructed image
using only bit planes 7, 6
and 5