Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
with help of Attila Lerch, Judit Verestoy, Zoltan Megyesi, Zsolt Janko Skeletal representation
and Levente Hajder Medial axis
Distance transform and medial axis
http://visual.ipan.sztaki.hu Thinning and skeleton
Summary of skeletal representation
Basic notions of digital geometry Definition: Let S be a set of pixels and pixels P, Q S. P is connected to Q if
there exists a sequence of pixels P = P0, P1, . . . , Pn = Q , Pi S, such that Pi is
Connectivity in digital images: a neighbour of Pi1, i [1, n].
Q ?
8 neighbours or 4 neighbours: 8-connectivity, 4-connectivity
Contradiction arises if same type of connectivity is used for object (S) and
background (S): pairs of pixels from the two sets may be connected across P
each other. set 1 set 2 set 3
It is a relation of equivalence
? S
It partitions the image into connected components
S
4
3
Operations of shrinking and expanding
Definitions:
Definitions
Hole in S is a component of S surrounded by S.
S (1) denotes shrinking of S: delete border of S.
Pixel P S is called a border pixel if it has a neighbour in S in the sense of S (k) is k-step shrinking of S: repeat shrinking k times.
connectivity used in S.
Otherwise, S is called an interior pixel. S (1) denotes expanding of S: interchange the connectivities of S and S, then
shrink S.
S (k) is k-step expanding of S: repeat expanding k times.
S
hole interior shrink expand expand
pixel
Illustrations to definitions of hole and border. Examples of shrinking and expanding. For 4-connected S, S (1) is empty:
shrinking does not preserve connectivity and may remove objects.
6
5
Binary image processing: Processing bilevel images using geometric criteria. row r and column c of the starting pixel
Different image data structures are used for binary image processing. The data
length S: number of pixels in the run
structures differ in data compression and in operations they support.
label L: identifies the connected component to which the run belongs
Original image matrix
c
Quadtree (area-based) r L2
S
Run-length code (area-based)
L1
Chain code (contour-based)
run R : {row r, column c , length S , label L }
Run-length code (RLC):
Run-length coding. L1 and L2 are labels.
A binary image is represented by a set of horizontal runs.
An image can be restored from its RLC, labelled or unlabelled.
A run is a maximal continuous sequence of object pixels.
8
7
RLC-based connected component analysis A typical RLC-based connected component algorithm allocates a label
equivalency table, inputs unlabelled RLC, and operates in two passes.
Connected component analysis: Finding connected components of a binary image. The first pass includes three basic procedures:
Different algorithms for connected component analysis exist, based on different opening a new label
data structures. In particular: propagating an existing label
merging the equivalent labels and updating the equivalency table
The simplest algorithm is recursive: Find next unlabelled pixel in image matrix,
The second pass recomputes the labels based on the equivalency table.
spread recursively to neighbours, mark visited pixels by current label.
10
9
Definition: An interior point of a shape belongs to the medial axis (MA) of the
1. Select connectivity (8 or 4). Allocate and initialise equivalency table (matrix) shape if this point lies at the same distance from two or more nearest contour
Eij = 0 if i 6= j, Eii = 1. Set label counter NL = 0. points.
2. Scan RLC and find the next unlabelled run R(r, c, S). Search the previous row Medial axis is the locus of such points.
r = r 1 and find runs Rk , k = 1, 2, . . . , Nc, which are connected to R. (Rk
are already labelled.) Operation that finds the medial axis of a shape is called medial axis transform
If Nc = 0 (no connected runs), open a new label by assigning label NL to (MAT).
run R, then increment NL.
If Nc = 1 and there is single connected run R1 with label L1, then propagate
label by assigning label L1 to run R.
If Nc > 1, select the smallest of the connected run labels Lk , Ls, then merge
labels by assigning label Ls to run R and setting Eks = 1 for all k.
Repeat until the end of RLC is reached.
3. Use the final equivalency table Eij to re-label the runs and obtain the true Examples of medial axes of simple shapes. MA of a disc is its centre.
number of connected components. Note that bisector of each angle is a branch of MA.
12
11
Properties of medial axis Properties of medial axis (continued)
In continuous case, MA is always a connected set of points. MA is very sensitive to small (e.g., noisy) variations of shape.
MA is a compact and efficient representation of shapes consisting of elongated Medial axis of shape can be obtained using distance transform (DT) of shape.
parts, for instance, letters, chromosomes.
DT assigns to each point the distance from that point to contour of shape.
Medial axis is a regenerative description if the distance is assigned to each In discrete case, distance to the closest background pixels is used. Different
discrete approximationsto DT exist.
point of MA.
Then the shape can be restored from its MA as the locus of inscribed circles MA of discrete shape may be disconnected.
computes its distance transform uDT (r, c) and its medial axis uM A(r, c). 2. Compute DT recursively for k = 1, 2, . . . as
Comments: uk (r, c) = u0(r, c) + min {uk1(i, j); (i, j) : (r, c; i, j) 1)} (1)
i,j
uDT (r, c) is a greyscale image coding the distance from object pixel (r, c) to
Iterate (1). Stop when no more changes occur: uk (r, c) = uk1(r, c) for all r, c.
the nearest background point.
Set uDT (r, c) = uk (r, c).
uM A(r, c) is a binary image.
3. Compute MAT uM A(r, c) as the set of points
We approximate the Euclidean distance is by the city-block distance.
{(r, c) : uDT (r, c) uDT (i, j); (r, c; i, j) 1}
In practice, finer approximations are used, but principle of operation is the same.
16
15
DT is finished when k equals half the maximum thickness of the object.
Examples of distance transform
The MAT procedure can be reversed to restore the object from its skeleton if
the distance information is preserved.
1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 1 2 2
1 2 3 3 3 2 1 3 3 3
1 2 2 2 2 2 1 2 2 image DT
1 1 1 1 1 1 1 1 1
uDT = u3 = u2 maxima of uDT medial axis uM A In DT images, dark points are large distances from background.
18
17
22
21
Properties of skeleton
Skeleton may significantly differ from MA. (Compare the skeleton and the
medial axis of a rectangle.) Comparison of thinning and MAT.
24
23
Summary of skeletal representation
Compresses data.
Regenerative: Original shape can be restored from skeleton and distance data.
Drawbacks:
25