Skeleton by The Means of Thinning: Principle
Skeleton by The Means of Thinning: Principle
1
Medialogi, Gruppe 835
Algorithm
The thinning operation makes use of a structuring element. These elements are of the extended type
meaning they can contain both ones and zeros. The thinning operation is related to the hit-and-miss
transform and can be expressed quite simply in terms of it. The thinning of an image I by a structuring
element J is:
In other words the origin of the structuring element is translated to every possible pixel position
within the image. At each position the element is compared to the underlying image. If the
structuring element and the image exactly match the image pixel underneath the origin of the
structuring element is set to zero (background). If they don’t match it is left unchanged. Note that
the origin of the element must never be zero but it can be either blank or one.
Skeletonizing algorithm
The skeleton of a region may be defined via the Medial Axis Transformation (MAT):
The MAT of a region has an intuitive definition based on the so-called “prairie fire concept”. Consider an
image region, as a prairie of uniform dry grass, and suppose a fire is lit along its border. All fire fronts will
advance into the region at the same speed. The MAT of the region is then the set of points reached by
more than one fire front at the same time, see figure [2].
2
Medialogi, Gruppe 835
efficiency of these calculations, thinning algorithms have been designed that iteratively delete edge points
on the region to the constraints that deletion of these points [2].
Thinning algorithm
In order to find the skeleton, Gonzales and Woods [2] present an algorithm for thinning binary regions.
Region points are assumed to have value 1, and background points value 0. The iterative method consists
of successive passes, where certain conditions have to be met or the point in question is deleted (inverted).
The definition of a contour point is any pixel with value 1, that has at least one 8-neighbor valued 0. The 8-
neighbor notation is shown is figure [3].
For step 1 of the iteration, the following conditions for P1 must be met in order for the point to change.
That is being converted to background value.
a)
b) T(P1) = 1
c) P2 * P4 *P6 = 0
d) P4 * P6 * P8 = 0
Where N(P1) is the number of non-zero neighbors of P1, aka. P2+P3+…+P8+P9 = N(P1). And T(P1) is the
number of 0 -> 1 transitions that happens in ordered sequence, aka. P2,P3,…P8,P9. So if the assigned points
near P1 looks like figure 3, N(P1) = 4 and T(P1)= 3.
3
Medialogi, Gruppe 835
In step 2 conditions a) and b) remains the same, but c) and d) are changed to:
c’) P2 * P4 * P8 = 0
d’) P2 * P6 * P8 = 0
If one or more conditions in a) -> d) are violated, the value of the point in question are unchanged, if all
conditions are satisfied the point is flagged for deletion. However the point is not deleted until all border
points have been processed. Once all border points are processed, results from step 1 is applied, then
follows processing the conditions in step 2, and then deleting points flagged in step 2. This routine covers
one iteration of the algorithm, which is then repeated for each point.
Condition a) is violated when contour point P1 only has one or seven neighbors with the value 1. If it has
one neighbor, the point is the end of a skeleton stroke, and should not be deleted. If it has seven neighbors,
deleting the point P1 would cause erosion into the region.
Condition b) is violated when it is applied to a point on a stroke 1 pixel thick. So this condition prevents
deletion of points, which would cause disconnection of segments of a skeleton structure.
When a point P1 satisfy c) and d), as well as a) and b), the point is either an east or south boundary point or
a north-west corner point in the boundary. In either case P1 is not part of the skeleton and should be
removed. Similarly the conditions c’) and d’) correspond to north or west boundary points, or a south-east
corner point. All of the conditions having minimum 2 zero 8-neighbors.
Example
To start a standard image of a human bone has been converted into a binary image using the ImageJ
program [1]. Figure [5] shows the results.
Running the MATLAB code presented in the previous section, but changing the number of iterations the
algorithm runs through, can be represented as stopping the code before skeleton reaches a single stroke.
4
Medialogi, Gruppe 835
Figure 6: An illustration
Figure [6] shows the effect of changing the iterations to 10 in picture A, and 20 in picture B. The change
should be implemented in the last paragraph of the function.
The INF, which is used in the book by Gonzales and Woods, refers to running the iterations until the
skeleton no longer changes. At some points, no additional changes are made to the structure of the
skeleton, and so the code is stopped.
The end result is a skeleton of the bone as shown in figure [7] picture A and a superimposed image of the
skeleton on top of the original binary image as picture B.
5
Medialogi, Gruppe 835
Implementation
The Skeleton via thinning algorithm has been implemented in MatLab. The following chapter will describe
the code used for this implementation. Before loading an image it must be changed into a binary image in
order to perform morphological operations on it.
The final result can be displayed when applying the morphological operation Inf times. In order of
displaying the two different main subjects of this mini-project the method skeletonization has also been
implemented and displayed beneath this chapter.
ginf = bwmorph(f, 'thin', Inf);
fs = bwmorph(f, 'skel', Inf);
imshow(ginf), figure, imshow(fs)
6
Medialogi, Gruppe 835
Results
Another example:
The original picture: 3D_WoodenGeisha. The original picture: Amazonas_River.
7
Medialogi, Gruppe 835
Reference
[1] http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm
[2] Digital Image processing – Gonzales, Woods. 2nd edition – 2002 – ISBN: 0201180758