Top Banner
Lecture 7 Object representation and description Filip Malmberg GW 11.1-11.4 Suggested problems: 11.19,11.25
57

Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

Jan 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

Lecture 7Object representation and descriptionFilip Malmberg

GW 11.1-11.4Suggested problems: 11.19,11.25

Page 2: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

2

Image analysis fundamental stepsimage acquisition

preprocessing, enhancement

segmentation

Representation, description, feature extraction

classification, interpretatio, recognition

result

Page 3: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

3

Farmed vs wild salmon

Page 4: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

4

Distinguishing between salmon and trout

Page 5: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

5

Identifying melanoma

Page 6: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

6

Analysing drug effects on cell cultures

Page 7: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

7

Commonly after segmentation one needs to represent objects in order to describe them

• External (boundary):• Representation: Polygon of the boundary• Description: The circumference

• Internal (regional)• Representation: Pixels inside the object• Description: The average color

Representation and description

Page 8: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

8

• The Representation of the Object

• An encoding of the object

• Truthful but possibly approximate

• A Descriptor of the Object:

• Only an aspect of the object

• Suitable for classification

• Consider invariance to e.g. noise, translation,

Representations and descriptors

Page 9: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

9

Shape Representation

• Sometimes necessary/desirable to represent an object in a less complicated or more intuitive way

• Simple descriptions like enclosing circle, enclosing rectangle, inscribed circle etc.

• The boundary or boundary segments

• Divide an object into regions or parts

• Represent by ”skeleton”

Page 10: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

10

• Often we want descriptors that are invariant of scale, rotation and translation:

• However, not always. In Optical Character Recognition (OCR) rotation and scale is important (e.g. ‘P’ and ‘d’)

Scale, rotation and translation

Page 11: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

11

Chain code: a contour based shape descriptors

Chain code – describe the sequence of steps generated when walking around the boundary

Chain code can be defined for 4 and 8 neighbours

Page 12: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

12

Chaincode example

4-connected:000303030323211222232110111

8-connected:0007776542344542212

Page 13: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

13

• Code becomes very long and noise sensitive

• Scale dependent

• Start point determines result

• Depends on rotation

Chain Coding issues/drawbacks

->Use larger grid spacing, smooth/edit the code

->Choose appropriate grid spacing

->Treat code as circular (minimum magnitude integer)754310 -> 075431

->Calculate difference code (counterclockwise) 075431 -> 767767

Page 14: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

14

Example: editing the chain code

replace 0710 with 0000

Page 15: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

15

• A digital boundary can be approximated (simplified)

• For closed boundaries:• Approximation becomes exact when no. of

segments of the polygons is equal to the no. of points in the boundary

• Goal is to capture the essence of the object shape• Approximation can become a time consuming

iterative process

Polygonal Approximations

Page 16: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

16

• Minimum Perimeter Polygons (MPPs)• Cover the boundary with cells of a chosen size and

force a rubber band like structure to fit inside the cells

Polygonal Approximations

Page 17: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

17

• Merging techniques1. Walk around the boundary and fit a least-square-error line to

the points until an error threshold is exceeded2. Start a new line, go to 13. When the start point is reached the intersections of adjacent

lines are the vertices of the polygon

Polygonal Approximations

Page 18: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

18

• Splitting techniques1. Start with an initial guess2. Calculate the orthogonal distance from lines to all points3. If maximum distance > threshold, create new vertex there4. Repeat until no points exceed criterion

Polygonal Approximations

Page 19: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

19

Boundary representation: signatures

Page 20: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

20

• A 1D representation of a boundary• Could be implemented in different ways

• Distance from centre point to border as a function of angle• Angle between the tangent in each point and a reference line

(histogram of this is called slope density function)

• Independent of translation, but not rotation & scaling.

Signatures

->Select unique starting point (e.g. based on major axis)->Normalize amplitude of signature (divide by variance)

Page 21: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

21

• When a boundary contains major concavities that carry shape information it can be worthwhile to decompose it into segments

• A good way to achieve this is to calculate the convex Hull of the region enclosed by the boundary = minimal enclosing convex region

• Can be a bit noise sensitive

Boundary segments

->Smooth prior to Convex hull calculation->Calculate Convex Hull on polygon approximation

Page 22: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

22

Convex hull, deficiency and concavity treeConvex Hull = minimal enclosing

convex region

Convex region = all points can be connected through a straight line inside the region

Convex deficiency = Convex hull – object

The number and distribution of convex deficiency regions may also be useful

=> Concavity tree, generate convex hulls and deficiencies recursively to create at concavity tree

Page 23: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

23

Skeletons“Curve representation” of the object

Should in general be thin, centered, topologically equivalent to original object and reversible

Can be created by thinning =iteratively removing pixels from the border while keeping the overall shape and topology (see book for detailed description) or by medial axis transform (MAT) = all inscribed circles touching two or more points at the border at the same time

Skeletons are sensitive to small changes in shape

- >smooth first or ”prune” skeleton afterwards

Page 24: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

24

Skeleton from medial axis

Page 25: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

25

Skeleton example

Skeleton or medial axis representation used for length measurements

Largest connected component is chosen as object of interest

Page 26: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

26Skeleton example: Neurite outgrowth analysis

Page 27: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

27

• After representation, the next step is to describe our boundaries and regions so that we later can classify them (next lecture)

• A description is an aspect of the representation• What descriptor is useful for classification of

• adults / children• pears / bananas / tomatoes

Descriptors

Page 28: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

28

• Length (perimeter)• Diameter = = major axis• Minor axis (perpendicular to major axis)• Basic rectangle = major × minor• Eccentricity = major / minor• Curvature= rate of change of slope

Simple boundary (segment) descriptors

Page 29: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

29

• Represent the boundary as a sequence of coordinates

• Treat each coordinate pair as a complex number

Fourier descriptors

Page 30: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

30

• From the DFT of the complex number we get the Fourier descriptors (the complex coefficients, a(u))

• The IDFT from these coefficients restores s(k)

• We can create an approximate reconstruction of s(k) if we use only the first P Fourier coefficients

Fourier descriptors

Page 31: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

31

• Boundary reconstruction using 546, 110, 56, 28, 14 and 8 Fourier descriptors out of a possible 1090.

Fourier descriptors

Page 32: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

32

• This boundary consists of 64 point, P is the number of descriptors used in the reconstruction

Fourier descriptors

Page 33: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

33

• Useful for describing the shape of boundary segments and signatures

• 2nd moment gives spread around mean (variance)• 3rd moment gives symmetry around mean (skewness)

Statistical moments

Page 34: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

34

• Can also be applied to amplitude histograms• Let the amplitude of g be a discrete variable v and create an

amplitude histogram where A is the number of amplitude increments

• The nth statistical moment of v (about its mean) is calculated as:

Statistical moments

n

Page 35: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

35

• Area = number of pixels in a region

• Compactness (P2A) = perimeter^2 / area

• Circularity ratio = 4×π area / perimeter^2ו Graylevel measures

• Mean• Median• Max• Etc.

Simple Regional Descriptors

Page 36: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

36

Examples of P2A vs area

Page 37: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

37

• Topology = The study of the properties of a figure that are unaffected by any deformation

• Topological descriptors

• Number of holes in a region, H

• Number of connected components, C

• Euler number, E = C – H

Topological descriptors

A B C i o å ö 5 9 8

Page 38: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

38

• Textures can be very valuable when describing objects

• Example below: Smooth, coarse and regular textures

Texture

Page 39: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

39

• Statistical texture descriptors: • Histogram based• Co-occurence based

(Statstical moments, Uniformity, entropy,... )

• Spectral texture descriptor • Use fourier transform

Texture

Page 40: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

40

• Properties of the graylevel histogram, of an image or region, used when calculating statistical moments• z : discrete random variable representing discrete graylevels in

the range [0 , L-1]• P(zi) : normalized histogram component, i.e. the probability of

finding a gray value corresponding to the i:th gray level zi.

2nd moment : Variance of z (contrast measure)3rd moment : Skewness4th moment : Relative flatness

Histogram based descriptors

Page 41: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

41

Two other common histogram based texture measures:

• Uniformity (maximum for image with just one grayvalue):

• Average entropy (measure of variability, 0 for constant images)

Histogram based descriptors

Page 42: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

42

Intensity histogram says nothing about the spatial distribution of the pixel intensities

Page 43: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

43

• For an image with N graylevels, and P, a positional operator, generate A, a N × N matrix, where ai,j is the number of times a pixel with graylevel value zi is in relative position P to graylevel value zj

• Divide all elements in A with the sum of all elements in A. This gives a new matrix C where ci,j is the probability that a pair of pixels fulfilling P has graylevel values zi and zj which is called the co-occurrence matrix

Co-occurrence matrix

Page 44: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

44

Building the matrix A

P=one pixel to the right

0 1 2

0

1

2

x

1

1

26

5

x

1

1

6

5

x

36

36

30

30

0 1 2

0

1

2 33

66

33

What will the matrix look like for the striped image if P= one pixel down?

Page 45: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

45

• Maximum probability (strongest response to P)

• Uniformity

• Entropy (randomness)

Co-occurrence matrix Descriptors

How can rotation robust measures be achieved?

Page 46: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

46

• Match image with a co-occurrence matrix!

Co-occurrence matrix

max prob: 0.00006 0.01500 0.0680Uniformity: 0.00002 0.01230 0.00480Entropy: 15.75 6.43 13.58

Page 47: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

47

• Peaks in the Fourier spectrum give information about direction and spatial period patterns

• The spectrum can be described using polar coordinates S(r,θ)

• For each angle θ, S(r,θ) is a 1D function Sθ(r)

• Similarly, for each frequency r, Sr(θ) is a 1D function

• A global description can be obtained by summing Sθ(r) and Sr(θ)

Spectral Analysis

Page 48: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

48

S(θ)S(r)

Spectral Analysis

Page 49: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

49

• For a 2D continuous function f(x,y), the moment of order (p + q) is defined as

for p, q = 0,1,2,…

• The central moments are defined as

where

Central Moments

Page 50: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

50

• If f(x,y) is a digital image, the central moments become

• The normalized central moments, denoted ηpq, are defined as

where for p+q = 2,3,…

Central Moments

Page 51: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

51

• A set of seven invariant moments can be derived from the 2nd and 3rd moments

• These moments are invariant to changes in translation, rotation and scale

Moment Invariants

Page 52: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

52

Page 53: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

53

Principal component analysis (PCA)

• Calculate Cx, covariance matrix of data X

• Find eigenvectors and corresponding eigen values of covariance

matrix (Cxei = λiei)

• Find A which is a matrix with the eigenvectors as rows, ordered

corresponding to decreasing eigenvalue

• Use A to transform x to y: y = A(x – mx).

• Any vector x can be recovered from y by: x = ATy + mx and

approximated by only using some (say k) of the eigenvalues and an Ak

matrix constructed from the k eigenvectors

Principal components

Page 54: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

54

Principal component analysis (PCA)

• The first principal component has the largest possible variance (that is, accounts for as much of the variability in the data as possible), and each succeeding component in turn has the highest variance possible under the constraint that it is orthogonal to the preceding components

Page 55: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

55

Principal components of a multispectral image

channel 1 channel 2 channel 3

PC 1 PC 2 PC 3

Page 56: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

56

Face recognition using PCA

Page 57: Lecture 7 Object representation and description...• The spectrum can be described using polar coordinates S(r,θ) • For each angle θ, S(r,θ) is a 1D function Sθ(r) • Similarly,

57

How to choose or design representations and descriptors:

• Find/create representations/descriptors that are invariant to things that are unimportant for your task:

• I.e. Noise, scale, blur, …

• Find/create representations and descriptors that are relevant for your question

• height, to classify adults / children

• color and shape to separate bananas, pears and tomatoes

• Be creative

• Stay as simple as possible