CHAPTER 7 SHAPE DESCRIPTION -...

67
7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape description CHAPTER 7 SHAPE DESCRIPTION DIGITAL IMAGE PROCESSING DIGITAL IMAGE PROCESSING DIGITAL IMAGE PROCESSING

Transcript of CHAPTER 7 SHAPE DESCRIPTION -...

Page 1: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.1THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

CHAPTER 7

SHAPE DESCRIPTION

DIGITAL IMAGE PROCESSINGDIGITAL IMAGE PROCESSINGDIGITAL IMAGE PROCESSING

Page 2: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.2THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Contents

♦♦ INTRODUCTIONINTRODUCTION

♦♦ CHAIN CODESCHAIN CODES

♦♦ POLYGONAL APPROXIMATIONSPOLYGONAL APPROXIMATIONS

♦♦ FOURIER DESCRIPTORSFOURIER DESCRIPTORS

♦♦ QUADTREESQUADTREES

♦♦ PYRAMIDSPYRAMIDS

♦♦ SHAPE FEATURESSHAPE FEATURES

Page 3: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.3THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Contents

♦♦ MOMENT DESCRIPTORSMOMENT DESCRIPTORS

♦♦ THINNING ALGORITHMSTHINNING ALGORITHMS

♦♦ MATHEMATICAL MORPHOLOGYMATHEMATICAL MORPHOLOGY

♦♦ GREYSCALE MORPHOLOGYGREYSCALE MORPHOLOGY

♦♦ SKELETONSSKELETONS

♦♦ SHAPE DECOMPOSITIONSHAPE DECOMPOSITION

Page 4: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.4THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Introduction

Two-dimensional shapes can be described in two differentways:

Á) Use of the object boundary and its Use of the object boundary and its featuresfeatures (e.g. (e.g. boundary length)boundary length). This method is directly connected to edge and line detection. The resulting description schemes are called external represantationsexternal represantations..

Â) Description of the region occupied by the object Description of the region occupied by the object on on thethe image plane.image plane. This method is linked to the region segmentation techniques. The resulting representation schemes are called internal representations.internal representations.

Page 5: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.5THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Introduction

Shape representation schemes must have certain desirableproperties:

UniquenessUniqueness. This is of crucial importance in object recognition, because each object must have a unique representation

CompletenessCompleteness. This refers to unambiguous representations

Invariance under geometrical transformationsInvariance under geometrical transformations.Invariance under translation, rotation, scaling and reflection is very important for object recognition applications.

Page 6: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.6THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Introduction

SensitivitySensitivity. This is the ability of a representation schemeto reflect easily the differences between similar objects

Abstraction from detailAbstraction from detail. This refers to the ability of therepresentation to represent the basic features of a shapeand to abstract from detail. This property is directly related to the noise robustness of the representation.

Page 7: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.7THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

• The chain code depends on the start point of boundaryfollowing.

• An advantage of chain code is that it is translation invariant.

• Scale invariance can be obtained by changing the size of the sampling grid, producing seldom, however, exactly the same chain code.

• Rotation invariance is obtained by using the difference difference chain chain codecode..

Chain codes

Page 8: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.8THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Chain codes

Chain code of the digital boundary

Figure 1: Directions of boundary segments of a chain code for (a) a 4-connected chain; (b) an 8-connected chain.

(a) (b)

Page 9: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.9THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

The difference code chaindifference code chain is given by:

{1iif)x,x(diff

1iif)x,x(diffi

1ii

Ni

d≠

=

−=

• Chain codes provide a good compression of boundary description.

• Chain codes can also be used to calculate certain boundary features.

Chain codes

Page 10: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.10THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

The boundary perimeter T is given by:

∑=

=N

iinT

1

{02mod1

12mod2

=

== i

i

xif

xifinwhere:(in case of an8-connectedchain code)

The object width w and height h are given by:

∑∑==

==N

ii

N

ii hhww

11

,

{{3,2,00

11

3,2,10

01

=

=

=

=== i

i

i

i

xif

xifi

xif

xifi hw

(in case of an4-connectedchain code)

Chain codes

Page 11: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.11THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Chain codes can be used in the calculation of object area

The boundaries of binary objects can be easilly followed byemploying an algorithm similar to Papert’s turtle:Papert’s turtle:

Figure 2: Turtle procedure in binary object boundary following

Chain codes

• Fir pixel value turn and advance one pixel

1

0

left

right

Page 12: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.12THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Polygonal approximations

•Digital boundaries carry information which may be superfluous for certain applications. Boundary approximations can be sufficient in such cases. Linear Linear piecewisepiecewise (polygonal) approximations(polygonal) approximations are the most frequently used.

••The optimal linear piecewise approximationThe optimal linear piecewise approximation can be obtained by choosing the polygon vertices in such a way that the overall approximation error is minimized.•Error measures:

•Mean square 2ii

1

22 |dx| −= ∑

=

Ν

ι

Ε

|dx|max ii12

max −=−≤≤ Νι

Ε•Maximal

Page 13: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.13THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

••Splitting techniquesSplitting techniques divide a curve segment recursively into smaller segments, until each curve segment can be approximated by a linear segment within an acceptable error range.

Polygonal approximations

Page 14: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.14THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 3: Splitting methodfor polygonalapproximations

Figure 4:Splitting methodfor the linear picewiseapproximationof a closed curve

Polygonal approximations

Page 15: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.15THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

•A basic advantage of the splitting approach is that it candetect the inflection points on a curve and can use themin curve representation.

••Merge techniques in the polygonal approximationMerge techniques in the polygonal approximationoperate in the opposite way.

•The primary disadvantage of the merge algorithm is thatpolygon vertices do not coincide with curve inflectionpoints.

•This problem can be solved by combining split and mergetechniques.

Polygonal approximations

Page 16: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.16THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Fourier descriptors

Signal representation using Fourier descriptorsFourier descriptors

∑−

=

−=

1

0

2exp)()(

N

n N

nkinzkZ

π

∑−

=

=

1

0

2exp)(

1)(

N

k N

nkiKZ

Nnz

π

Figure 5: Parametric curve representation

Page 17: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.17THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Fourier representation propertiesFourier representation properties

A)A) The coefficient Æ(0) represents the centre of gravitycentre of gravityof the curve.

B)B) Fourier coefficients Z(k) represent slowly and rapidlyvarying shape trends for small and large indices krespectively.

C)C) A translation in curve coordinates by z0 :zt(n)=z(n)+z0 , z0=x0+iy0

affects only the term Z(0) of the representation:Zt(0)=Z(0)+z0

Fourier descriptors

Page 18: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.18THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

D)D) A rotation of the curve coordinates by angle è :zr(n)=z(n)eiè

results in a phase shift of the transform coefficients by anequal amount:

Zr(k)=Z(k)eiè

E)E) A scaling operation by a factor á, results in a scaling ofFourier coefficients by an equal amount:

zs(n)=áz(n)Zs(k)=áZ(k)

Fourier representation propertiesFourier representation properties

Fourier descriptors

Page 19: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.19THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

F) F) A change in the starting point of curve traversal:zt(n)=z(n-n0)

produces modulationmodulation of the Fourier descriptors:Zt(k)=Z(k)e-i2ðn0k/N

Fourier descriptors have interesting invariance propertiesthat can be used in object recognition applications.

∑−

=

−=1

0

221 |))(||)((|

N

k

kZkZE( Error measure formatching two curvesz1(n) , z2(n) )

Fourier representation propertiesFourier representation properties

Fourier descriptors

Page 20: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.20THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Quadtrees

•Quadtrees are based on the following recursive approach:if a binary image region of size 2n × 2n consists of both 0sand 1s, it is declared inhomogeneous and is split into foursquare subregions R0, R1, R2, R3, having size 2n-1×2n-1 each.•This procedure continues until all subregions arehomogeneous. •The resulting representation is a quadtreequadtree.

∑=

≈=n

0k

nk 43

44N

Maximalnumberof nodes

Page 21: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.21THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 6: (a) Binary image (b) Quadtree representation

Quadtrees

Page 22: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.22THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Pyramids

•• MultiresolutionMultiresolution representations employ several copies ofthe same image at different resolutions.• Multiresolution techniques applied to greyscale or binaryimages lead to the so-called image pyramids.image pyramids.• An image pyramid is a series fk(i,j), k=0,…,n of imagearrays, each having size 2k × 2k .

fk(i,j)=g(fk+1(2i,2j), fk+1(2i,2j+1), fk+1(2i+1,2j), fk+1(2i+1,2j+1))

g(·) is a mapping function

∑∑= =

+ ++=1

0l

1

0m1kk )mj2,li2(f

4

1)j,i(f

Page 23: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.23THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 7:(a) Image pyramid

(b) Mapping from onepyramid level to thenext level.

Pyramids

Page 24: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.24THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

•Pyramids techniques enjoy a certain popularity for image analysis and compression applications, because they offer abstraction from image details.

•Binary image pyramids can be used in multiresolution edge detection and region segmentation.

•The total space required for the storage of a pyramid (and of a quadtree) is 4/3 × (2n × 2n) where 2n × 2n is the size of the original image. Of course, the pyramid can be simply stored on n+1 arrays of size 2k × 2k, k=0,..,n.

Pyramids

Page 25: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.25THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Pyramids

Figure 8:(a) Originalbinaryimage

(b) Imagepyramid

(c) Output ofthe pyramidedge detector

(d) Edgepyramid

Page 26: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.26THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Shape features

Geometrical shapes possess certain features (e.g. perimeter)that carry sufficient information for some object recognitionapplications. Such features can be used as object descriptorsresulting in a significant data compression, because they canrepresent the geometrical shape by a relatively small featurevector.

Shape features can be grouped in two large classes:boundary featuresboundary featuresregionregion featuresfeatures

Page 27: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.27THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Object perimeterperimeter::

∫ += dttytxT )()( 22

∑∑−

=+

=

−==1

11

1

1

||N

iii

N

ii xxdT x1,…,xN : boundary

coordinate list

Curvature Curvature magnitudemagnitude::2

2

2

2

22|)(|

+

=∆

dt

yd

dt

xdtk

Shape features

Page 28: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.28THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Curvature Curvature magnitudemagnitude::

ds

sodsk

)()( /= 22 dydxds +=where

Shape features

])1n(y)n(y2)1n(y[)]1n(x)n(x2)1n(x[1

|)n(k| 222

++−−+++−−⋅=∆

Another curvature definitionAnother curvature definition::

Approximaton of the local curvatureApproximaton of the local curvature::

= oddfor x,

2

2

even,for x2

1

)x(L

i

i

i

)x(L)x(L

xx)n(k

1nn

1nn

−−

≅ where

Page 29: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.29THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Bending Bending energyenergy::

∫=T

dttkT

E0

2|)(|1

∑−

=

=1

0

2|)(|1 n

i

ikT

E where 1<n<N

=

42 2|)(|

T

kkZE

π Calculated from boundaryFourier descriptors

Shape features

2

T

2E

=

πCircle bending energy

∑=

−=−=n

1i

2

2

object

circleN

|)i(k|T

41

E

E1E

πNormalization ofbending energy

Page 30: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.30THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

ObjectObject areaarea

∫∫=R

dxdyA

∫∂

−=

Rdt

dt

dytx

dt

dxtyA )()(

using a differentialgeometry formula

Compactness or circularityCompactness or circularity

A4

T 2

πγ = 2N T

A41

πγ −= normalized version

Shape features

Page 31: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.31THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Object width and heightwidth and height

)(min)(max

)(min)(max

tytyh

txtxw

tt

tt

−=

−=

Object diameterdiameter

),(max,

lkRXX

XXdDlk ∈

=

where XkXl is the direction of the line segment

Shape features

Page 32: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.32THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Topological descriptors can give useful global informationabout an object. Two important topological features are theholes Hholes H and the connected components Cconnected components C of an object.

EulerEuler numbernumberE = C E = C -- HH

Letters A, B, C, have Euler numbers 0, -1, 1, respectively.

Shape features

Page 33: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.33THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Moment descriptors

The moments moments of an image f(x,y)f(x,y) are given by:

∫ ∫∞

∞−

∞−== ,...2,1,0q,p,dxdy)y,x(fyxm qp

pq

Centre of gravityCentre of gravity of an object

00

01

00

10

m

my,

m

mx ==

Central momentsCentral moments

∫ ∫∞

∞−

∞−=−−= ,...2,1,0,,),()()( qpdxdyyxfyyxx qp

pqµ

Page 34: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.34THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Moment relations for discrete imagesMoment relations for discrete images

∑∑

∑∑−−=

=

i j

qppq

i j

qppq

jifyjxi

jifjim

),()()(

),(..

µ

Moment relations for binary imagesMoment relations for binary images

∑∑

∑∑−−=

=

i j

qppq

i j

qppq

yjxi

jim

)()(

..

µ

Moment descriptors

Page 35: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.35THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Coordinates of the centre of gravityCoordinates of the centre of gravity

∑∑∈∈

==RjiRji

jN

yiN

x),(),(

11

Object orientation èorientation è: can be derived by minimizing thefunction:

∑∑∈

−−−=Rji

yjxiS),(

2]sin)(cos)[()( θθθ

where Í is the area of an image in pixels

=0220

112arctan

21

µµµ

θ

Moment descriptors

Page 36: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.36THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Object eccentricityeccentricity

−+−+

=θµθµθµθµθµθµ

ε2coscossin2sinsincos

112

202

02

112

202

02

+−=

A11

22002 4)( µµµ

ε

Object spread or sizespread or size

)( 2002 µµ +=S

Moment descriptors

Page 37: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.37THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Moment descriptors

Figure 9: Definition of object orientation

Page 38: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.38THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Thinning algorithms

ThinningThinning can be defined heuristically as a set of succesiveerosions of the outermost layers of a shape, until aconnected unit-width set of lines (skeleton) is obtained.

Thinning algorithms satisfy the following two constraints:

1. They maintain connectivity at each iteration. They do1. They maintain connectivity at each iteration. They donot remove border pixels that may cause discontinuitiesnot remove border pixels that may cause discontinuities

2. They do not shorten the end of thinned shape limbs.2. They do not shorten the end of thinned shape limbs.

Page 39: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.39THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 10:(a) Border pixel whose removal may cause discontinuities;(b) border pixel whose removal will shorten an object limb;(c) local pixel notation used in connectivity check.

Thinning algorithms

(a) (b) (c)

Page 40: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.40THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 11: Central window pixels belonging to: (a) an East boundary; (b) a South boundary; (c) a North-West corner point.

Thinning algorithms

(a) (b) (c)

Page 41: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.41THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 12: Central window pixels belonging to: (a) a North boundary; (b) a West boundary; (c) a South-East corner.

Thinning algorithms

(a) (b) (c)

Page 42: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.42THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Thinning algorithms

First thinning algorithm•Check in a local neighborhood 3×3

•If the number of the pixels of the object (except the central) Í(p0) is: 2 < Í (p0) < 8)

•we check if the removal of the central pixel would break object connectivity.

Check

•The pixel sequence is formed p1p2p3...p8p1.

•If the number of 0→1 transitions is 1, then the central pixel that has value 1 is removed.

Page 43: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.43THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Thinning algorithms

where Ô(p0) denotes the number of the 0→1 transitions.

) =.p.p)&&(p=.p.p)&&(p)=)&&(T(p)N(p:(P

) =.p.p)&&(p=.p.p)&&(p)=)&&(T(p)N(p:(P

0 0 162

0 0162

7517310 0 2

753531 0 0 1

≤≤≤≤

Second thinning algorithm•Step 1: a logical rule P1 is applied in a 3×3neighbourhood and flags the border pixels that can be deleted.

•Step 2: a logical rule P2 is applied in a 3×3neighbourhood and flags the border pixels that will be deleted.

Page 44: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.44THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Figure 13:Sobel edgedetectoroutput

Binaryimage

Output of the one-passthinningalgorithm

Output ofthe two-passthinningalgorithm

Thinning algorithms

Page 45: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.45THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Mathematical morphology

Mathematical morphology uses a set theoretic approach toimage analysis.

The morphological transformations must possess thefollowing properties:

1. Translation invariance1. Translation invarianceØ(Ø(XXzz)=[)=[Ø(Ø(X)]X)]zz

2. Scale invariance2. Scale invarianceØØëë((X)=ëX)=ëØ(ëØ(ë--11X)X)

Page 46: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.46THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

3. Local knowledge. 3. Local knowledge. Transformation Ø(×) must requireonly information within a local neighbourhood for itsoperation

4. Semicontinuity. 4. Semicontinuity. The morphological transformation Ø(×)must possess certain continuity properties.

Basic morphological transformations

}{ IU 0: ≠∈==⊕∈

− XBEzXBX zBb

bs

}{ XBEzXBX zBb

bs ⊂∈==

∈− :I

dilationdilation

erosionerosion

Mathematical morphology

Page 47: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.47THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Erosion and dilation are special cases of MinkowskiMinkowski setsetadditionaddition and Minkowski Minkowski set subtractionset subtraction

Mathematical morphology

UBb

bXBX∈

=⊕ IBb

bs XBX

=

(a) (b) (c)

Figure 14: (a) thresholded image (b) eroded and (c) dilated image by the structuring elements SQUARE.

Page 48: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.48THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Erosion, dilation, Minkowski set addition and subtractionhave the following interesting properties:

CommutativityCommutativity::

ABBA ⊕=⊕

Mathematical morphology

AssociativityAssociativity::

CBACBA ⊕⊕=⊕⊕ )()(

Page 49: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.49THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Translation Translation invarianceinvariance::

zz

zz

zz

BABA

BABA

BABA

)(

)(

)(

==

⊕=⊕

Increasing Increasing propertyproperty::

DBDABA

DBDABA

⊆⇒⊆⊕⊆⊕⇒⊆

Mathematical morphology

Page 50: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.50THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

DistributivityDistributivity::

CBACBA

CBCACBA

CABACBA

CABACBA

CBCACBA

)()(

)()()(

)()()(

)()()(

)()()(

=⊕

=

=

⊕⊕=⊕

⊕⊕=⊕

I IIUUUUU

Mathematical morphology

Page 51: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.51THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Opening ×Opening ×ÂÂ:: }{U XBBBBXX zzs

B ⊂=⊕= :)(

Closing XClosing XBB:: }{I cz

cz

sB XBBBBXX ⊂=⊕= :)(

Mathematical morphology

(a) (b)

Figure 15: (a) opened image (b) closed image.

Page 52: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.52THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Opening and closing propertiesOpening and closing properties

DualityDuality::

BccB

BccB

XX

XX

)()(

)()(

=

=

Mathematical morphology

Extensivity and Extensivity and antiextensivityantiextensivity::

XX

XXB

B

Page 53: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.53THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Increasing Increasing propertyproperty::

BB

BB

XXXX

XXXX

)()(

)()(

2121

2121

⊂⇒⊂

⊂⇒⊂

IdempotenceIdempotence::

BBB

BBB

XX

XX

=

=

)(

)(

Mathematical morphology

Page 54: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.54THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Definition of binary dilationDefinition of binary dilation

}{ I 0: ≠∈=⊕ XBEzBX zs

Definition of binary erosionDefinition of binary erosion

}{ XBEzBX zs ⊂∈= :

An alternative way for the calculation of binary erosionAn alternative way for the calculation of binary erosionand dilationand dilation

I

U

Bbb

s

Bbb

s

XBX

XBX

∈−

∈−

=

=⊕

Mathematical morphology

Page 55: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.55THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Greyscale morpholgy

The tools for greyscale morphological operations are simplefunctions g(x) having domain G. They are calledstructuring functionsstructuring functions

Figure 16: A example of a structuring function.

Page 56: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.56THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Greyscale morpholgy

Greyscale dilation and erosion of a function f(x) by g(x)Greyscale dilation and erosion of a function f(x) by g(x)

}{

}{ )()(min)]([

)()(max)]([

,

,

xzgzfxgf

xzgzfxgf

DxzDz

s

DxzDz

s

−−=

−+=⊕

∈−∈

∈−∈

Greyscale opening and closingGreyscale opening and closing

)()]()([)]()[()(

)()]()([)]()[()(

xgxgxfxggfxf

xgxgxfxggfxfsg

sg

−⊕=⊕=

⊕−=⊕=

Page 57: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.57THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Implementation of greyscale dilation and erosion inImplementation of greyscale dilation and erosion inpipelinepipeline

)...))(...((

)...))(...((

21

21

k

k

gggfgf

gggfgf

=⊕⊕⊕⊕=⊕

Dilation and erosion of a function by a setDilation and erosion of a function by a set

}{}{ )(...,),(),...,(min)]([)]([

)(...,),(),...,(max)]([)]([

vififvifxgfxGf

vififvifxgfxGfss

ss

+−==

+−=⊕=⊕

Opening and closing of a function by a setOpening and closing of a function by a set

)]()[()(

)]()[()(

xGGfxf

xGGfxfsG

sG

⊕=

⊕=

Greyscale morpholgy

Page 58: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.58THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

CloseClose--opening filter (CO)opening filter (CO)

)]()[( xfy GG=

openopen--closing filter (OC)closing filter (OC)

)]()[( xfy GG=

The algebraic difference y=f (x)-fnB(x) is a nonlinearhigh-pass filter, called toptop--hat transformation.hat transformation.

Greyscale morpholgy

Page 59: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.59THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Greyscale morpholgy

Figure 17: Opening as a rolling ball transformation

Page 60: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.60THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Greyscale morpholgy

(a) (b)

Figure 18: (a) Thresholded image, (b) Result of top-hat filtering

Page 61: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.61THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Skeletons

Object skeletonskeleton is an important topological descriptor ofa two-dimensional binary object

(a) (b)

Figure 19: (a) Grassfire propagation model of medial axis;(b) maximal disk definition of skeleton.

Page 62: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.62THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Skeletons

Figure 20: Illustration of morphological skeletonization

Page 63: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.63THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Skeletons

Figure 21: (a) Fast skeletonization algorithm;(b) fast object reconstruction from skeleton subsets.

(a)

(b)

Page 64: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.64THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Shape decomposition

• A complex object X can be decomposed into a union of ‘simple’ subsets X1,…, Xn, thus providing an intuitive object description scheme called shape decomposition.shape decomposition.

• Shape decomposition must use simple geometrical primitives in order to conform with our intuitive notion of simple shapes.

• The complexity of the decomposition must be small compared with the original description of X.

• A small noise sensitivity is desirable.

Page 65: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.65THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Morphological shape decompositionMorphological shape decompositionRecursive relation:

0)(:

0

)(

0

1

1

/=ΒΧ′−Χ

/=′

=′

′−=

Κ

=

s

j

i

ji

Bnii

conditionStopping

X

XX

XXXi

U

Figure 22: (a) Original binary image;(b) first 16 components of its morphological shape decomposition.

Shape decomposition

Page 66: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.66THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Blum ribbonsBlum ribbonsSimple objects Xi of the form:

BnLX iii ⊕=Disadvantages of morphological shape decompositionDisadvantages of morphological shape decomposition

It is susceptible to boundary noise.

The representation produced is not close to human shapeperception if the object consists of unions, intersectionsand differences of various geometrival primitives. Thiscan be alleviated by combining morphological techniqueswith constructive solid geometry, (CSG).constructive solid geometry, (CSG).

Shape decomposition

Page 67: CHAPTER 7 SHAPE DESCRIPTION - AIIAposeidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip_material/chapter… · 7.1 THESSALONIKI 1998 I. Pitas Digital Image Processing Fundamentals Shape

7.67THESSALONIKI 1998

I. Pitas Digital Image Processing FundamentalsShape description

Shape decomposition

Main advantage of CSG over skeleton representation orMain advantage of CSG over skeleton representation ormorphological shape decompositionmorphological shape decomposition

• CSG uses a multitude of geometrical primitives(e.g. squares) instead of one.

• This fact not only enhances the descriptive power of CSGbut also conforms to our intuitive notion of simplegeometrical shapes.