computer&vision - centro federal de educação ... · basic&image&topology ... squares...

37
Basic Image Topology Computer Vision Prof. Flávio Cardeal – DECOM / CEFETMG [email protected]

Upload: phamhuong

Post on 02-Sep-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Basic Image Topology

Computer Vision

Prof. Flávio Cardeal – DECOM / CEFET-­‐MG

[email protected]

Abstract

• This lecture is an introduction into digitaltopology to understand concepts as “imageregion” or “border of an image region”.

2

Adjacency Relation• Pixels do not define a particular adjacencyrelation between them per se.

• It is our model that specifies a chosenadjacency relation.

• And the selected adjacency relation has latersignificant impacts on defined image regions.

3

Topology• Adjacency relation is a concept associated tothe concept of digital topology.

• But, what is topology?

• Topology is a math area that has sometimesbeen called “rubber-­sheet geometry”. Why?

4

Topology• Because topology does not distinguish, forinstance, between a circle and a square or asphere and a cube.

5

Source: http

://news.fordh

am.edu

Pressing on asphere to give itsix sides turns itinto a cube.

Topology• We know that the sphere and the cube aredifferent because they have distinct surfaceareas, volumes, lengths, and so on.

• But topologically speaking, they are one and thesame, because the sphere has been deformed ina continuous fashion to become a cube.

6

Topology• Topology is the study of geometric properties andspatial relations unaffected by the continuouschange of shape or size of an object.

• Specifically, changes caused by stretching,twisting and compressing. Important: sticking,cutting, breaking or tearing are not allowed.

7

Digital Topology• Digital topology deals with properties andfeatures of images that correspond to topologicalproperties or topological features of objects.

• Concepts of digital topology are used by imageanalysis algorithms for border tracing, counting ofcomponents, region-­filling, among others.

8

Digital Topology• We are interested in understanding:

• The numbers of components of sets;;• Adjacencies between such components;;• Numbers of holes in sets;;• Properties that do not depend on measurements in aspace equipped with coordinates.

9

Pixel Adjacency for Binary Images

• Pixel adjacency defines connectedness in animage and regions of pairwise connected pixels.

• Assuming 4-­adjacency, each pixel location is adjacent to pixel locations in the set:

10

p = (x, y)

90 3 Image Analysis

Fig. 3.1 Left: The number of black regions does not depend on a chosen adjacency relation. Right:In the Euclidean topology, the number of black regions depends on whether two adjacent blacksquares are actually connected by the black corner point between both or not

J.B. Listing (1802–1882) was the first to use the word “topology” in hiscorrespondence, beginning in 1837. He defined: “Topological properties arethose which are related not to quantity or content, but to spatial order andposition.”

3.1.1 4- and 8-Adjacency for Binary Images

Assumed pixel adjacency (or pixel neighbourhood) defines connectedness in an im-age and thus regions of pairwise connected pixels.

Pixel Adjacency Assuming 4-adjacency, each pixel location p = (x, y) is adja-cent to pixel locations in the set

A4(p) = p + A4 =!(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)

"(3.1)

for the 4-adjacency set A4 = (1,0), (−1,0), (0,1), (0,−1). The graphs inFigs. 1.1 and 1.2 illustrate 4-adjacency. This type of adjacency corresponds to edge-adjacency when considering each pixel as a shaded tiny square (i.e. the grid cellmodel). Assuming 8-adjacency, each grid point p = (x, y) is adjacent to pixel loca-tions in the set

A8(p) = p + A8 =!(x + 1, y + 1), (x + 1, y − 1), (x − 1, y + 1), (x − 1, y − 1),

(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)"

(3.2)

for the 8-adjacency set A8 = (1,1), (1,−1), (−1,1), (−1,−1) ∪ A4. This alsointroduces diagonal edges that are not shown in the graphs in Figs. 1.1 and 1.2.Figure 3.3, left, illustrates 8-adjacency for the shown black pixels. This type ofadjacency corresponds to edge- or corner-adjacency in the grid cell model.

90 3 Image Analysis

Fig. 3.1 Left: The number of black regions does not depend on a chosen adjacency relation. Right:In the Euclidean topology, the number of black regions depends on whether two adjacent blacksquares are actually connected by the black corner point between both or not

J.B. Listing (1802–1882) was the first to use the word “topology” in hiscorrespondence, beginning in 1837. He defined: “Topological properties arethose which are related not to quantity or content, but to spatial order andposition.”

3.1.1 4- and 8-Adjacency for Binary Images

Assumed pixel adjacency (or pixel neighbourhood) defines connectedness in an im-age and thus regions of pairwise connected pixels.

Pixel Adjacency Assuming 4-adjacency, each pixel location p = (x, y) is adja-cent to pixel locations in the set

A4(p) = p + A4 =!(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)

"(3.1)

for the 4-adjacency set A4 = (1,0), (−1,0), (0,1), (0,−1). The graphs inFigs. 1.1 and 1.2 illustrate 4-adjacency. This type of adjacency corresponds to edge-adjacency when considering each pixel as a shaded tiny square (i.e. the grid cellmodel). Assuming 8-adjacency, each grid point p = (x, y) is adjacent to pixel loca-tions in the set

A8(p) = p + A8 =!(x + 1, y + 1), (x + 1, y − 1), (x − 1, y + 1), (x − 1, y − 1),

(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)"

(3.2)

for the 8-adjacency set A8 = (1,1), (1,−1), (−1,1), (−1,−1) ∪ A4. This alsointroduces diagonal edges that are not shown in the graphs in Figs. 1.1 and 1.2.Figure 3.3, left, illustrates 8-adjacency for the shown black pixels. This type ofadjacency corresponds to edge- or corner-adjacency in the grid cell model.

4-­Adjacency

Source: http://cse19-­‐iiith.vlabs.ac.in

This type of adjacency correspondsto edge-­adjacency when consideringeach pixel as a shaded tiny square(i.e. the grid cell model).

11

8-­Adjacency• Assuming 8-­adjacency, each grid pointis adjacent to pixel locations in the set:

12

p = (x, y)

90 3 Image Analysis

Fig. 3.1 Left: The number of black regions does not depend on a chosen adjacency relation. Right:In the Euclidean topology, the number of black regions depends on whether two adjacent blacksquares are actually connected by the black corner point between both or not

J.B. Listing (1802–1882) was the first to use the word “topology” in hiscorrespondence, beginning in 1837. He defined: “Topological properties arethose which are related not to quantity or content, but to spatial order andposition.”

3.1.1 4- and 8-Adjacency for Binary Images

Assumed pixel adjacency (or pixel neighbourhood) defines connectedness in an im-age and thus regions of pairwise connected pixels.

Pixel Adjacency Assuming 4-adjacency, each pixel location p = (x, y) is adja-cent to pixel locations in the set

A4(p) = p + A4 =!(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)

"(3.1)

for the 4-adjacency set A4 = (1,0), (−1,0), (0,1), (0,−1). The graphs inFigs. 1.1 and 1.2 illustrate 4-adjacency. This type of adjacency corresponds to edge-adjacency when considering each pixel as a shaded tiny square (i.e. the grid cellmodel). Assuming 8-adjacency, each grid point p = (x, y) is adjacent to pixel loca-tions in the set

A8(p) = p + A8 =!(x + 1, y + 1), (x + 1, y − 1), (x − 1, y + 1), (x − 1, y − 1),

(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)"

(3.2)

for the 8-adjacency set A8 = (1,1), (1,−1), (−1,1), (−1,−1) ∪ A4. This alsointroduces diagonal edges that are not shown in the graphs in Figs. 1.1 and 1.2.Figure 3.3, left, illustrates 8-adjacency for the shown black pixels. This type ofadjacency corresponds to edge- or corner-adjacency in the grid cell model.

90 3 Image Analysis

Fig. 3.1 Left: The number of black regions does not depend on a chosen adjacency relation. Right:In the Euclidean topology, the number of black regions depends on whether two adjacent blacksquares are actually connected by the black corner point between both or not

J.B. Listing (1802–1882) was the first to use the word “topology” in hiscorrespondence, beginning in 1837. He defined: “Topological properties arethose which are related not to quantity or content, but to spatial order andposition.”

3.1.1 4- and 8-Adjacency for Binary Images

Assumed pixel adjacency (or pixel neighbourhood) defines connectedness in an im-age and thus regions of pairwise connected pixels.

Pixel Adjacency Assuming 4-adjacency, each pixel location p = (x, y) is adja-cent to pixel locations in the set

A4(p) = p + A4 =!(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)

"(3.1)

for the 4-adjacency set A4 = (1,0), (−1,0), (0,1), (0,−1). The graphs inFigs. 1.1 and 1.2 illustrate 4-adjacency. This type of adjacency corresponds to edge-adjacency when considering each pixel as a shaded tiny square (i.e. the grid cellmodel). Assuming 8-adjacency, each grid point p = (x, y) is adjacent to pixel loca-tions in the set

A8(p) = p + A8 =!(x + 1, y + 1), (x + 1, y − 1), (x − 1, y + 1), (x − 1, y − 1),

(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)"

(3.2)

for the 8-adjacency set A8 = (1,1), (1,−1), (−1,1), (−1,−1) ∪ A4. This alsointroduces diagonal edges that are not shown in the graphs in Figs. 1.1 and 1.2.Figure 3.3, left, illustrates 8-adjacency for the shown black pixels. This type ofadjacency corresponds to edge- or corner-adjacency in the grid cell model.

8-­Adjacency

Source: http://cse19-­‐iiith.vlabs.ac.in

This type of adjacencycorresponds to edge-­ orcorner-­adjacency in thegrid cell model.

13

Pixel Neighborhoods• A neighborhood of a pixel contains the pixel itself and some adjacent pixels.

• So, the 4-­neighborhood of equals , and the 8-­neighborhood of equals .

14

p p

pp

A4 (p)∪pA8(p)∪p3.1 Basic Image Topology 91

Fig. 3.2 Left: 4-adjacency set and 8-adjacency set of p. Right: 4-neighbourhood and 8-neighbour-hood of p

Pixel Neighbourhoods A neighbourhood of a pixel p contains the pixel p itselfand some adjacent pixels. For example, the 4-neighbourhood of p equals A4(p) ∪p, and the 8-neighbourhood of p equals A8(p) ∪ p. See Fig. 3.2.

Insert 3.2 (Adjacency, Connectedness, and Planarity in Graph Theory) An(undirected) graph G = [N,E] is defined by a set N of nodes and a set E ofedges; each edge connects two nodes. The graph G is finite if N is finite.

Two nodes are adjacent if there is an edge between them. A path is a se-quence of nodes, where each node in the sequence is adjacent to its predeces-sor.

A set S ⊆ N of nodes is connected iff there is a path in S from any node inS to any node in S. Maximal connected subsets of a graph are called compo-nents.

A planar graph can be drawn on the plane in such a way that its edgesintersect only at their endpoints (i.e. nodes). Let α1 be the number of edges,and α0 be the number of nodes of a graph. For a planar graph with α0 ≥ 3,we have that α1 ≤ 3α0 −6; if there are no cycles of length 3 in the graph, thenit is even α1 ≤ 2α0 − 4.

Euler’s formula states that for a finite planar and connected graph, α2 −α1 + α0 = 2, where α2 denotes the number of faces of the planar graph.

Pixel Connectedness The following transitive closure of the adjacency relationdefines connectedness. Let S ⊆ Ω :1. A pixel is connected to itself.2. Adjacent pixels in S are connected.3. If pixel p ∈ S is connected to pixel q ∈ S, and pixel q ∈ S is adjacent to pixel

r ∈ S, then p is also connected to r (in S).Depending on the chosen adjacency, we thus have either 4-connectedness or 8-connectedness of subsets of Ω .

Regions Maximal connected sets of pixels define regions, also called components.The black pixels in Fig. 3.3, left, define one 8-region and eight 4-regions (isolatedpixels); the figure contains two white 4-regions and only one white 8-region.

Figure 3.4, left, provides a more general example. Assume that the task is tocount “particles” in an image represented (after some image processing) by blackpixels. The chosen adjacency relation defines your result, not the input image!

4-­ and 8-­adjacency sets of p

4-­ and 8-­neighborhoods

of p

Pixel Connectedness• One simple relationship between pixels isconnectedness, which may be illustrated by thefollowing questions:

• Which pixels are “next to” which others?• Can you “get to” one pixel from another?• If so, how “far” is it?

15

Pixel Connectedness• The following transitive closure of the adjacencyrelation defines connectedness. Let :1. A pixel is connected to itself;;2. Adjacent pixels in are connected.3. If pixel is connected to pixel , and pixel

is adjacent to pixel , then is also connected to (in ).

16

S ⊆Ω

Sp∈ S q ∈ S

q ∈ S r ∈ S pr S

Pixel Connectedness• A path is a sequence of pixel locations whereeach pixel location in the sequence is adjacent toits predecessor.

17

Connectedness Binary Images Multi-Level Images Border Tracing

Connectedness

A path is a sequence of pixel locations where each pixel location in thesequence is adjacent to its predecessor

Left: 4-path in grid cell andgrid point model

Right: 8-path in grid cell andgrid point model

Set S is connected i↵ there is path in S from any p 2 S to any q 2 S

4-path and 4-connectedness, or 8-path and 8-connectedness

7 / 28

Connectedness Binary Images Multi-Level Images Border Tracing

Connectedness

A path is a sequence of pixel locations where each pixel location in thesequence is adjacent to its predecessor

Left: 4-path in grid cell andgrid point model

Right: 8-path in grid cell andgrid point model

Set S is connected i↵ there is path in S from any p 2 S to any q 2 S

4-path and 4-connectedness, or 8-path and 8-connectedness

7 / 28

Source: R

. Klette

Example of a4-­path or

4-­connectedness

Example of an8-­path or

8-­connectedness

Pixel Connectedness• A set is connected if and only if there is apath in from any to any .

• Those connected sets of pixels define regions,which are also called components.

18

S ⊆ΩS p∈ S q ∈ S

Pixel Connectedness• Note that depending on the chosen adjacency,we may have either 4-­connectedness or 8-­connectedness of subsets of .

19

Ω

Four groups of pixels joined by 4-­connectedness

Two groups of pixels joined by 8-­connectedness

Source: http://homepages.inf.ed.ac.uk/rbf/

3333

3

Regions• Maximal connected sets of pixels define regions,also called components.

20

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

The black pixels in this figuredefine one 8-­region and eight4-­regions;; the figure containstwo white 4-­regions and onlyone white 8-­region.

Source: R

. Klette

Regions• The figure below provides a general example.The task is to count “particles” in an image(binary image) represented by black pixels.

21

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

Assuming 4-­adjacency for blackpixels, we count five “particles” (red);;assuming 8-­adjacency, the count isthree (green).

Source: R

. Klette

The chosen adjacency relation definesyour result, not the input image!

Regions• Illustration of an application where such a countis relevant.

22

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

Source: R

. Klette

Dual Adjacencies• In the figure below, the black pixels define one 8-­region, forming a simple digital curve. But thiscurve does not separate two white 8-­regions.

23

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

Source: R

. Klette

Dual Adjacencies• In contrast, assuming 4-­adjacency, then we haveisolated black pixels. Therefore, no simple curveand thus there should be no separation.

24

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

Source: R

. Klette

Dual Adjacencies• But, we do have two separated 4-­regions.

• Thus, using the same adjacency relation for bothblack and white pixels leads to a topologicalresult that does not correspond to our intuition.

• What would be a solution for that?

25

Dual Adjacencies• A straightforward solution would be the dual useof types of adjacency for white or black pixels.

• For example, 4-­adjacency for white pixels and 8-­adjacency for black pixels, ensures that simpledigital curves separate inner and outer regions.

26

Border Tracing• When arriving via a scanline at an object, we like totrace its border such that the object region is alwayson the right or always on the left as illustrated below.

27

98 3 Image Analysis

Fig. 3.9 These images are of size 2014 × 1426 (they contain 2,872,964 pixels) and haveGmax = 255. For the image Tomte on the upper left, the percentage of flip-flop cases is 0.38 %compared to the total number of pixels. In the images PobleEspanyol, Rangitoto, and Kirion the upper right, lower left, and lower right, respectively, the percentages of flip-flop cases are0.22 %, 0.5 %, and 0.38 %, respectively

Fig. 3.10 Illustration of twoscanlines that arrive for thefirst time (assuming astandard scan: top–down, leftto right) at objects of interest(lights). At this moment atracing procedure starts forgoing around on the border ofthe object

Not any local circular order of an adjacency set is applicable. Clockwise orcounter-clockwise orders of adjacent pixels are the possible options.

Source: R

. Klette

Definition of Border Pixel• When applying a border tracing algorithm, it is usuallyassumed that the image is either binary or theirregions have been previously labeled.

• That said, the location of a border pixel of aregion satisfies:

• It is in set ;;• There is at least one pixel location , such that:

o is adjacent to but .28

p∈ΩS ⊆Ω

Sq ∈Ω

q p q ∉ S

Border Tracing• Therefore, given a pixel adjacency and a currentborder pixel, we have to test all the adjacent pixels ina defined order such that we keep to our strategy.

• The adjacency used might be 4-­, 8-­ or any otheradjacency of your choice.

• At every pixel location we have a local circular order , which lists all adjacent pixels in exactly once. 29

pξ (p) = q1,...,qnA(p)

Border Tracing• Clockwise or counter-­clockwise orders of adjacentpixels are possible options of local circular orders.

• Assume that we arrive at . Let be thepixel next to pixel in the local circular order of .

30

q1pi

pi+1 ∈ A(pi ) pi+1

3.1 Basic Image Topology 99

Fig. 3.11 Left: Used local circular order. Right: Arrival at an object when going from q0 to p0

1: Let (q0,p0) = (q,p), i = 0, and k = 1;2: Let q1 be the pixel which follows q0 in ξ(p0);3: while (qk,pi) = (q0,p0) do4: while qk in the object do5: Let i := i + 1 and pi := qk ;6: Let q1 be the pixel which follows pi−1 in ξ(pi) and k = 1;7: end while8: Let k = k + 1 and go to pixel qk in ξ(pi);9: end while

10: The calculated border cycle is ⟨p0,p1, . . . , pi⟩;Fig. 3.12 Voss algorithm

Example 3.1 We consider tracing for 4-adjacency. See the example in Fig. 3.11.We arrive at the object via edge (q,p); let (q0,p0) := (q,p) and assume the local

circular order for 4-adjacency as shown. We take the next pixel position in ξ(p0),which is the pixel position right of p0: this is in the object, and it is the next pixelp1 on the border.

We stop if we test again the initial edge; but this would be in direction (p, q),opposite to the arrival direction (q,p). Arriving at the same pixel again is not yet astop.

General Border-Tracing Algorithm by Voss Given is an image with a definedadjacency relation and an initial edge (q,p) such that we arrive at p for the first timeat an object border not yet traced so far. Note: We do not say “first time at an object”because one object may have one outer and several inner borders. The algorithm isprovided in Fig. 3.12.

An object O may have holes, acting as objects again (possibly again with holes).Holes generate inner border cycles for object O in this case; see the following ex-ample. The provided tracing algorithm is also fine for calculating inner borders. Thelocal circular orders remain always the same, only defined by adjacent object ornon-object pixels.

Example of a clockwise order, byassuming a tracing process basedon 4-­adjacency.

pq2q4

q1

q3

Border Tracing• We test whether is in the object;; if “yes”, then wehave and continue at .

• If “not”, then we test the next pixel in the localcircular order of , and so forth.

• The chosen adjacency (4-­ or 8-­adjacency, forinstance), specifies in general different sets of borderpixels for the same image region.

31

pi+2 = q1q1 pi+2

q2ξ (pi+1) pi+1

Border Tracing• Consider a tracing process based on 4-­adjacency.

32

3.1 Basic Image Topology 99

Fig. 3.11 Left: Used local circular order. Right: Arrival at an object when going from q0 to p0

1: Let (q0,p0) = (q,p), i = 0, and k = 1;2: Let q1 be the pixel which follows q0 in ξ(p0);3: while (qk,pi) = (q0,p0) do4: while qk in the object do5: Let i := i + 1 and pi := qk ;6: Let q1 be the pixel which follows pi−1 in ξ(pi) and k = 1;7: end while8: Let k = k + 1 and go to pixel qk in ξ(pi);9: end while

10: The calculated border cycle is ⟨p0,p1, . . . , pi⟩;Fig. 3.12 Voss algorithm

Example 3.1 We consider tracing for 4-adjacency. See the example in Fig. 3.11.We arrive at the object via edge (q,p); let (q0,p0) := (q,p) and assume the local

circular order for 4-adjacency as shown. We take the next pixel position in ξ(p0),which is the pixel position right of p0: this is in the object, and it is the next pixelp1 on the border.

We stop if we test again the initial edge; but this would be in direction (p, q),opposite to the arrival direction (q,p). Arriving at the same pixel again is not yet astop.

General Border-Tracing Algorithm by Voss Given is an image with a definedadjacency relation and an initial edge (q,p) such that we arrive at p for the first timeat an object border not yet traced so far. Note: We do not say “first time at an object”because one object may have one outer and several inner borders. The algorithm isprovided in Fig. 3.12.

An object O may have holes, acting as objects again (possibly again with holes).Holes generate inner border cycles for object O in this case; see the following ex-ample. The provided tracing algorithm is also fine for calculating inner borders. Thelocal circular orders remain always the same, only defined by adjacent object ornon-object pixels.

Local CircularOrder

p5

p6 p7 p8p9

p10p11

p12p13

p14p15

p16

Source: R

. Klette

p17 p18

p19p20p21

p22

p23

p24p25

p26

p27

p28

p29

Border Tracing• Consider a tracing process based on 4-­adjacency.

33

3.1 Basic Image Topology 99

Fig. 3.11 Left: Used local circular order. Right: Arrival at an object when going from q0 to p0

1: Let (q0,p0) = (q,p), i = 0, and k = 1;2: Let q1 be the pixel which follows q0 in ξ(p0);3: while (qk,pi) = (q0,p0) do4: while qk in the object do5: Let i := i + 1 and pi := qk ;6: Let q1 be the pixel which follows pi−1 in ξ(pi) and k = 1;7: end while8: Let k = k + 1 and go to pixel qk in ξ(pi);9: end while

10: The calculated border cycle is ⟨p0,p1, . . . , pi⟩;Fig. 3.12 Voss algorithm

Example 3.1 We consider tracing for 4-adjacency. See the example in Fig. 3.11.We arrive at the object via edge (q,p); let (q0,p0) := (q,p) and assume the local

circular order for 4-adjacency as shown. We take the next pixel position in ξ(p0),which is the pixel position right of p0: this is in the object, and it is the next pixelp1 on the border.

We stop if we test again the initial edge; but this would be in direction (p, q),opposite to the arrival direction (q,p). Arriving at the same pixel again is not yet astop.

General Border-Tracing Algorithm by Voss Given is an image with a definedadjacency relation and an initial edge (q,p) such that we arrive at p for the first timeat an object border not yet traced so far. Note: We do not say “first time at an object”because one object may have one outer and several inner borders. The algorithm isprovided in Fig. 3.12.

An object O may have holes, acting as objects again (possibly again with holes).Holes generate inner border cycles for object O in this case; see the following ex-ample. The provided tracing algorithm is also fine for calculating inner borders. Thelocal circular orders remain always the same, only defined by adjacent object ornon-object pixels.

Local CircularOrder

p4

p5 p6 p7

p8p9

Source: R

. Klette

p10

p3i

iii

ii

i

i ii

p11p12

i

p13p14

i

p15

p16

p17

Border Tracing• Consider another tracing based on 4-­adjacency.

34

92 3 Image Analysis

Fig. 3.3 Left: Assume 4-adjacency: The disconnected black pixels separate a connected “innerregion” from a connected “outer region”. Assume 8-adjacency: The black pixels are connected (asillustrated by the inserted edges), but all the white pixels remain connected (see the dashed edgeas an example). Right: A simple curve in the Euclidean plane always separates interior (the shadedregion) from exterior

Fig. 3.4 Left: Assuming 4-adjacency for black pixels, we count five “particles” in this binaryimage; assuming 8-adjacency, the count is three. Right: Illustration of an application where such acount is relevant

Insert 3.3 (Jordan) C. Jordan (1838–1922), a French mathematician, con-tributed to many areas in mathematics. For example, he showed that the centreof a tree is either a single node or a pair of adjacent nodes. He is especiallyknown for his definitions and characterizations of curves in the plane.

Dual Adjacencies in Binary Images Figure 3.3 illustrates the consequenceswhen deciding for one particular type of adjacency by drawing a comparison withthe geometry in the Euclidean plane R2. R is the set of all real numbers. A simplecurve, also known as a Jordan curve, always separates an inner region, called theinterior, from an outer region, called the exterior. This appears to be obvious, incorrespondence with our intuition, but a mathematical proof of this property, known

p2

p3 p4

p5p6

p7p8

p9

p10

Note: arriving at the same pixel again is not yet a stop!

p11

p12

p1

General Border Tracing Algorithm

• Given is an image with a defined adjacency relationand an initial edge such that we arrive at forthe first time at an object border not yet traced so far.

• The general border-­tracing algorithm proposed byVoss is presented in the following.

35

(q, p) p

General Border Tracing Algorithm

36

3.1 Basic Image Topology 99

Fig. 3.11 Left: Used local circular order. Right: Arrival at an object when going from q0 to p0

1: Let (q0,p0) = (q,p), i = 0, and k = 1;2: Let q1 be the pixel which follows q0 in ξ(p0);3: while (qk,pi) = (q0,p0) do4: while qk in the object do5: Let i := i + 1 and pi := qk ;6: Let q1 be the pixel which follows pi−1 in ξ(pi) and k = 1;7: end while8: Let k = k + 1 and go to pixel qk in ξ(pi);9: end while

10: The calculated border cycle is ⟨p0,p1, . . . , pi⟩;Fig. 3.12 Voss algorithm

Example 3.1 We consider tracing for 4-adjacency. See the example in Fig. 3.11.We arrive at the object via edge (q,p); let (q0,p0) := (q,p) and assume the local

circular order for 4-adjacency as shown. We take the next pixel position in ξ(p0),which is the pixel position right of p0: this is in the object, and it is the next pixelp1 on the border.

We stop if we test again the initial edge; but this would be in direction (p, q),opposite to the arrival direction (q,p). Arriving at the same pixel again is not yet astop.

General Border-Tracing Algorithm by Voss Given is an image with a definedadjacency relation and an initial edge (q,p) such that we arrive at p for the first timeat an object border not yet traced so far. Note: We do not say “first time at an object”because one object may have one outer and several inner borders. The algorithm isprovided in Fig. 3.12.

An object O may have holes, acting as objects again (possibly again with holes).Holes generate inner border cycles for object O in this case; see the following ex-ample. The provided tracing algorithm is also fine for calculating inner borders. Thelocal circular orders remain always the same, only defined by adjacent object ornon-object pixels.

Next Lecture• Geometric 2D Shape Analysis

Area. Length. Curvature.

• Suggested reading

Section 3.2 of textbook.

37