Digital Image Processing
Week-02
1
Contents
• Image Resolution
• Relationship between pixels
• Connectivity
• Connected Component Analysis
• Image Enhancement
Spatial & Gray Level Resolution
Spatial Resolution
4
Spatial Resolution
5
Intensity Level Resolution
Intensity level resolution refers to the number of intensity levels used to represent the
image
◼ The more intensity levels used, the finer the level of detail in
an image
◼ Intensity level resolution is usually given in terms of the
number of bits used to store each intensity level
6
Intensity Level Resolution
Number of Intensity
Number of Bits Examples
Levels
1 2 0, 1
2 4 00, 01, 10, 11
4 16 0000, 0101, 1111
8 256 00110011, 01010101
16 65,536 1010101010101010
7
Intensity Level Resolution
8
Intensity Level Resolution
256 grey levels (8 bits per pixel) 128 grey levels (7 bpp) 64 grey levels (6 bpp) 32 grey levels (5 bpp)
16 grey levels (4 bpp) 8 grey levels (3 bpp) 4 grey levels (2 bpp) 2 grey levels (1 bpp)
9
Resolution: How much is enough?
How many samples and gray levels are required
for a good approximation?
◼ Quality of an image depends on number of pixels and gray-
level number
◼ The more these parameters are increased, the closer the
digitized array approximates the original image
◼ But: Storage & processing requirements increase rapidly as a
function of N, M, and k
10
Resolution: How much is enough?
Depends on what is in the image and what you
would like to do with it
11
Relationships between pixels
Neighbors of pixel are the pixels that are
adjacent pixels of an identified pixel
y-1 y y+1
x-1
x
x+1
12
4- Neighbors of a Pixel –N4(p)
coordinates of each of y-1 y y+1
x-1
the blue pixels
What are the
x
x+1
(x-1,y), (x+1,y), (x, y-1), (x, y+1)
13
Diagonal Neighbors of a Pixel –ND(p)
y-1 y y+1
x-1
x
x+1
(x-1,y-1), (x+1,y-1), (x-1, y+1), (x+1, y+1)
14
8- Neighbors of a Pixel –N8(p)
y-1 y y+1
x-1
x
x-1
N8 ( p ) = N 4 ( p ) N D ( p )
(x-1,y), (x+1,y), (x, y-1), (x, y+1)
(x-1,y-1), (x+1,y-1), (x-1, y+1), (x+1, y+1)
15
Determine different regions in the
image
16
Connectivity
Establishing boundaries of objects and components in an image
Group the same region by assumption that the pixels being the same
color or equal intensity
Two pixels p & q are connected if
◼ They are adjacent in some sense
◼ If their gray levels satisfy a specified criterion of
similarity
17
Connectivity
V: Set of gray levels used to define the criterion of similarity
4-connectivity
If gray level ( p, q) V , and q N 4 ( p)
Set of gray levels V = {1}
18
Connectivity
V: Set of gray levels used to define the criterion of similarity
8-connectivity
If gray level ( p, q) V , and q N8 ( p)
Set of gray levels V = {1}
19
Connectivity
V: Set of gray levels used to define the criterion of similarity
m-connectivity (Mixed Connectivity)
If gray level
( p, q) V , and q satisfies one of the following:
a. q N 4 ( p ) or
b. q N D ( p) And N 4 ( p) N 4 (q) has no pixels
whose values are from V
20
Example: m – Connectivity
Set of gray levels V = {1}
Note: Mixed connectivity can eliminate the multiple path connections that often
occurs in 8-connectivity
21
Paths
Path: Let coordinates of pixel p: (x, y), and of pixel q: (s, t)
A path from p to q is a sequence of distinct pixels with
coordinates: (x0, y0), (x1, y1), ......, (xn,yn)
where (x0, y0) = (x, y) & (xn,yn) = (s, t), and (xi,yi) is adjacent
to (xi-1,yi-1) 1≤i ≤n
22
Test Yourself
Distance Metrics
Let pixels p, q and z have coordinates (x,y),
(s,t) and (u,v) respectively.
D is a distance function or metric if
◼ D(p,q) ≥ 0 and
◼ D(p,q) = 0 iff p = q and
◼ D(p,q) = D(q,p) and
◼ D(p,z) ≤ D(p,q) + D(q,z)
24
City block distance (D4 distance)
D4 ( p, q) = x − s + y − t
Diamond with center at
(x,y)
D4 = 1 are the 4 neighbors
of pixel p(x,y)
25
Chessboard distance (D8 distance)
D8 ( p, q) = max( x − s , y − t )
Square centered at p(x,y)
D8 = 1 are the 8 neighbors
of pixel p(x,y)
26
Euclidean Distance
De ( p, q) = ( x − s)2 + ( y − t )2
q(s,t)
p(x,y)
A circle with radius r centered at (x,y)
27
Distance Maps
Connected Component Analysis
CC labeling – 4 Connectivity
Process the image from left to
right, top to bottom:
1.) If the next pixel to process is 1
i.) If only one of its neighbors
(top or left) is 1, copy its label.
ii.) If both are 1 and have the
same label, copy it.
iii.) If they have different labels
Pass 1
− Copy the label from the left.
− Update the equivalence table.
iv.) Otherwise, assign a new label.
Re-label with the smallest of equivalent
labels Pass 2
30
CC labeling – 4 Connectivity
31
CC labeling – 4 Connectivity
32
CC labeling – 8 Connectivity
Same algorithm but examine also the upper diagonal neighbors of p
33
CC labeling – 8 Connectivity
Background pixel
Background pixel
Unlabeled Pixel
Unlabeled Pixel
Label 1
34
CC labeling – 8 Connectivity
Background pixel Background pixel
Unlabeled Pixel Unlabeled Pixel
Label 1 Label 1
Label 2 Label 2
Label 3
35
CC labeling – 8 Connectivity
Background pixel Background pixel
Unlabeled Pixel Unlabeled Pixel
Label 1 Label 1
Label 2 Label 2
Label 3 Label 3
36
CC labeling – 8 Connectivity
Background pixel Background pixel
Unlabeled pixel Unlabeled pixel
Label 1 Label 1
Label 2 Label 2
Label 3 Label 3
37
CC labeling – 8 Connectivity
Background pixel Background pixel
Unlabeled pixel Unlabeled pixel
Label 1 Label 1
Label 2 Label 2
Label 3 Label 3
Label 4 Label 4
38
Image Enhancement
39
Image Enhancement
40
Image Enhancement
Process an image so that the result is more suitable than the original image for a
specific application
Image Enhancement Methods
◼ Spatial Domain: Direct manipulation of pixels in an
image
◼ Frequency Domain: Process the image by modifying the
Fourier transform of an image
This Chapter – Spatial Domain
41
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
42
Basic Concepts
Most spatial domain enhancement
operations can be generalized as:
g ( x, y) = T f ( x, y)
f (x, y) = the input image
g (x, y) = the processed/output image
T = some operator defined over some neighbourhood of (x,
y)
43
Point Processing
In a digital image, point = pixel
Point processing transforms a
pixel’s value as function of its
value alone;
It does not depend on the values
of the pixel’s neighbors.
44
Point Processing
Neighborhood of size 1x1:
g depends only on f at (x,y)
T: Gray-level/intensity transformation/ mapping function
s = T (r )
◼ r = gray level of f at (x,y)
◼ s = gray level of g at (x,y)
45
Point Processing using Look-up Tables
A look-up table (LUT)
implements a functional
mapping.
255
E.g.: index value
... ...
output value
101 64
102 68
127
103 69
104 70
105 70
106 71
0
0 127 255 ... ...
input value input output
46
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
47
POINT PROCESSING
Contrast Stretching Thresholding
48
Point Processing Example:
Thresholding
1.0 r > threshold
s=
0.0 r <= threshold
49
Point Processing Example:
Thresholding
Segmentation of an object of interest from a
background
1.0 r > threshold
s=
0.0 r <= threshold
50
Point Processing Example:
Intensity Scaling
s = T (r ) = a.r
51
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
⚫ nth power/nth root
52
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
53
Point Processing Example:
Negative Images
54
Today’s Learning Outcomes
• Image resolution is purely dependent on the
type of application and available resources
• Relationship between pixels is important
• Connected component analysis is one of the
fundamental concept in image analysis
• Basic transformations functions can be used for
image enhancement
What's Next
• Mathematical Transformation
• Histograms
Readings from Book (4th Edn.)
• Chapter – 2
• Chapter 3.1
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
Pattern Classification” by Duda et al., John Wiley & Sons.
Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2018
Machine Vision: Automated Visual Inspection and Robot Vision”, David Vernon, Prentice Hall,
1991
www.eu.aibo.com/
Advances in Human Computer Interaction, Shane Pinder, InTech, Austria, October 2008
58