Chapter 09 Solutions-Merged
Chapter 09 Solutions-Merged
1 Find the length of the shortest path from (i) (1, 1) to (5, 3) (ii) (1, 6) to
(3, 1) using (a) 4-connectivity and (b) 8-connectivity.
(b) 4
1,1 1,2 1,3 1,4 1,5 1,6
2,1 2,2 2,3 2,4 2,5 2,6
3,1 3,2 3,3 3,4 3,5 3,6
4,1 4,2 4,3 4,4 4,5 4,6
5,1 5,2 5,3 5,4 5,5 5,6
6,1 6,2 6,3 6,4 6,5 6,6
(b) 5
1,1 1,2 1,3 1,4 1,5 1,6
2,1 2,2 2,3 2,4 2,5 2,6
3,1 3,2 3,3 3,4 3,5 3,6
4,1 4,2 4,3 4,4 4,5 4,6
5,1 5,2 5,3 5,4 5,5 5,6
6,1 6,2 6,3 6,4 6,5 6,6
9.2 What is the difference between the result of opening performed once
and twice? What is idempotency?
(ii)
0 0 0
0 1 0
0 0 1
(iii) There are two different types of junctions that need to be considered –
T-junctions
(which require
0 1 0
0 1 1
0 1 0
and Y-junctions
(which require
0 1 0
1 1 0
0 0 1
9.4 How can the hit-or-miss transform be used to perform erosion? How
can the hit-and-miss transform, together with the NOT (or inverse)
operation, be used to perform dilation?
9.5 If an edge detector has produced long lines in its output that are
approximately x pixels thick, what is the longest length spurious
spur (prune) that you could expect to see after thinning to a single-
pixel thickness? Test your estimate on some real images. Hence,
approximately how many iterations of pruning should be applied to
remove spurious spurs from lines that were thinned down from a
thickness of x pixels?
If the output lines are x pixels thick and then they are skeletonized to a
thickness of one pixel, the thickness of the “lost” pixels would be x – 1.
So, any spur perpendicular to the skeleton could be no longer than (x –
1)/2; if the spur were at an angle to the skeleton it could be no longer than
([(x-1)/2}.√2. One iteration of pruning will remove either a perpendicular or
angled pixel from the spur. Thus (x-1)/2 iterations are required.
9.6 Sketch the skeleton of (i) a square (ii) an equilateral triangle (iii) a
circle.
9.8 What shape and size of structuring element would you need to use in
order to detect just the horizontal lines in figure P9.1?
A structuring element that just finds inside the smallest horizontal line (and
doesn’t fit inside the vertical and diagonal lines) is required.
9.9 The features in the image shown in figure P9.2(i) are flawed by small
gaps, which have been removed in the image shown in figure P9.2(ii).
What processing operation would achieve this result? What size and
shape of structuring element is required?
Binary closing would remove the flaws. The structuring element has to fit
inside the foreground shapes. The structuring element should be
circular—considering the rounded edges throughout the image—and its
diameter should be just smaller than the width of the long strand in the
image.
9.10 What is (i) the skeleton and (ii) the medial transform of figure P9.3?
(i) (ii)
Note: The image for (ii), the MAT, has been log-stretched for better
resolution.
9.13 What is the top hat transformation and when is it used? Explain how
the top hat transformation can help to segment dark characters on a
light, but variable, background. Draw a one-dimensional profile
through an image to illustrate your explanation.
The top hat transformation is analogous to unsharp masking and is given
by:
As such, the top hat transform is used (like the unsharp mask) to enhance
gray-level detail in the presence of shading. The top hat transformation
begins with the grayscale opening of the given image. This decreases the
brightness by “elevating” the dark-level of the background and objects.
This opening process is essentially taking the max(min(image)), meaning
that a minimum structuring element is applied to every pixel in the image
(erosion) and then a maximizing structuring element is applied to every
picture of the resulting, eroded image (dilation). The initial erosion
darkens the dark characters in the RIO and the following dilation
separates the darkened characters from the background. The top hat
transform is then completed when the opened image is subtracted from
the original image – making the background uniform and dark, and the
characters bright. The following images help illustrate the top hat
transform:
Figure 1:Original Figure 2:After Opening Figure 3: Original - Opening (Top Hat)
Figure 4:DipProfile, Original Figure 5:DipProfile, top hat
Another example:
We can see that all the background intensities have been subtracted
leaving just the text).
The algorithm works very well if the spreads of the individual distributions
are approximately equal. However, the disadvantage is that it does not
perform well where the distributions have differing variances or are of
abnormal shape.
10.2 Explain the basis for optimal segmentation using the Otsu method.
The Otsu method treats an image’s gray-level histogram as a probability
density function where, given that ni is the number of pixels with a gray
value of i and N is the total number of image pixels, the probability that a
particular pixel has a particular gray-level is given by pi = ni/N.
10.6 Design an energy term for a snake to track lines of constant gray
value.
Let f(x, y) be the image in question. We need to design both an internal
energy term and an external energy term for our snake. If we are tracking
lines of constant gray level, then we want our snake to behave like a thin,
metal strip rather than a shrinking elastic band. As such, the internal
energy function needs to be defined as the sum of the curvatures of the
snake measured at the control points. This can be taken to be the
measure of the slope of the line connecting any two given control points.
Hence:
where, again, the sum ranges from i = 1 to i = N. Hence, the energy term
for our snake is:
10.8 Explain why the watershed lines of a binary image correspond to the
“skiz” lines.
The skiz lines are the result of skeletonizing the background of an image,
reducing the objects in the image to interconnected lines, or regions. If
the skiz lines are superimposed over the original image, the objects in the
image are separated. The skiz lines are created by structuring elements
that continuously erode a given object until the structuring element
encounters another eroded object, essentially forming a boundary line
between two regions. This corresponds to the watershed lines because
when the thresholded image is complemented - the regions becoming
“valleys” - and the valleys “filled with water” the dams (watershed lines)
are formed when the boundaries of the “water-filled” regions meet. These
watershed lines match the skiz lines because they represent the same
region boundaries.
Solutions to Chapter 11
ii. Class: A class is a way of describing objects that have common properties.
Classification involves sorting objects in an image into separate classes. We use
measurable features (i.e. area, petal length, circularity) in order to enumerate
classes.
iii. Classifier: A classifier evaluates the evidence presented from feature extraction
and makes a decision as to the class each object should be assigned.
iv. Feature Space: A feature space is the n-dimensional space for which feature
vectors (vectors containing a set of measured features) can be plotted as points.
In feature space, each feature constitutes a dimension. For example, if we
measured sepal length, petal length, and petal width of irises, we would have
three-dimensional feature space.
v. Decision Rule: The decision rule compares the sample mean to the hypothesized
mean. If the sample mean is “close” to the hypothesized mean, we accept the
null hypothesis, i.e. there is no discernible difference between the hypothesized
set and the sample set.
where
fkm = the value (score) on the canonical discriminant function for case m in the
group k.
Xikm = the value on discriminant variable Xi for case m in group k; and
ui = coefficients which produce the desired characteristics in the function.
3. A training set is a set of data that is used to fit, or train a model for prediction or
classification of values that are known in the training set but unknown in other future
data. It is typically chosen randomly to avoid skewed results future predictions. It is
usually chosen to be about 20% of the total sample set.
4.
x y z
7 4 3
4 1 8
X=
6 3 5
8 6 1
8 5 7
7 2 9
8 2 2
7 4 5
9 5 8
5 3 3
Step 1: Calculate the covariances for xx, xy, xz, yx, yy, yz, zx, zy and zz.
xx = 2.09 yy = 2.25
xy = yx = 1.45 yz = zy = -1.15
xz = zx = -0.39 zz = 7.09
μ σ π λ
4 2 0.50000 1
10 1 0.50000 1
6. When a classifier is designed a training set of images is used. If the classes to which
these images belong is known we refer to process as supervised learning. If the classes
to which the images belong are unknown then the process is referred to as
unsupervised learning. In unsupervised learning the data are plotted to see whether
they cluster naturally.
7.
(a)
-7.427 2.328
(b)
-4.797 -1.408
(c)
1.079 -1.754
(d)
4.821 2.435
(e)
2.545 0.065
8. The features used to extract the letter E were Euler number (lack of holes) and
eccentricity
You could also skeletonize it and look for 3 end points.
9. In heart disease the arteries can be segmented and skeletonized, and the
shapes categorized and described with a grammar that could then be analyzed.