346 A Computational Introduction to Digital Image Processing, Second Edition
4. Consider the two images
• • · · · • • • • ·
• • · · · • • • • ·
· • • · · • • • • ·
• • · · · • • • • ·
• • · · · • • • • ·
· · • • • · · · · •
· · • • • · · · · •
• · · • • · · · · •
· · • • • · · · · •
· · • • • · · · · •
A
,
• • · · · • • · · ·
• • · · · • · · • ·
· • • · · · · • • ·
• • · · · · • • • ·
• • · · · • • • · ·
· · • • • · · · · •
· · • • • · · · · •
• · · • • · · · · •
· · • • • · · · · ·
· · • • • · · · · ·
B
Find the 4-components and 8-components of each image.
5. The above matrices were obtained with the MATLAB/Octave commands
MATLAB/Octave
>> A=magic(10)>50
>> B=magic(10)>60
If you use Python you will have to enter the matrices manually. Check your an-
swers of th e previous question with the
bwlabel function of MATLAB/Octave or
sk.measure.label in Python.
6. We can define the 6-neighbors of a pixel p with coordinates (x, y) to be the pixels with
coordinates (x + 1, y), (x −1, y), (x, y + 1), (x, y −1), (x + 1, y + 1), and (x −1, y −1).
Draw a diagram showing the six 6-neighbors of a pixel.
7. Prove the triangle inequality for the Euclidean distance metric, and for the 4-path
and 8-path metrics d
4
and d
8
.
8. Define the relation 6-connectedness as:
p is 6-connected to q if there is a path p = p
1
, p
2
, . . . , p
n
= q such that for
each i = 1, 2, . . . , n − 1, p
i
is 6-adj acent to p
i+1
.
Show that this is an equivalence relation.
9. Find the lengths of the shortest 6-paths between pixels with the following co ordinates:
(a) (0, 0) and (2, 2), (b) (1, 2) and (5, 4), (c) (2, 1) and (6, 8),
(d) (3, 1) and (7, 4)
Can you develop an expression for a 6-path metric?
10. Show how to refine the algorithms for component labeling to label the 6-comp onents
of a binary image.