L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel...

95
Morphological Operations 1

Transcript of L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel...

Page 1: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Morphological Operations

1

Page 2: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Outline

• Basic concepts:• Erode and dilate• Open and close.

G l t• Granulometry• Hit and miss transform• Thinning and thickening• Skeletonization and the medial axis transformSkeletonization and the medial axis transform• Introduction to gray level morphology.

2

Page 3: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Pixel connectivity

• We need to define which pixels are neighbors. Warning:

i l lg

• Are the dark pi els in this arra

Pixels are samples, not squarespixels in this array

connected? not squares.

4

Page 4: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Pixel connectivity

• We need to define which pixels are neighbors.g

• Are the dark pixels in this arraypixels in this array connected?

5

Page 5: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Pixel Neighborhoods

4-neighborhood 8-neighborhood

6

Page 6: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Pixel paths

• A 4-connected path between pixels p1 and pn is a set of pixels {p1, p2, …, pn} such that pi is a 4-neighbor of pi+1, i=1,…,n-1.pi g pi+1, , ,

d h i i hb• In an 8-connected path, pi is an 8-neighbor of pi+1.i 1

7

Page 7: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Connected regions

• A region is 4-connected if it contains a 4-connected path between any two of its pixels.p

i i d if i i• A region is 8-connected if it contains an 8-connected path between any two of its pixels.

8

Page 8: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Connected regions

• Now what can we say about the dark pixels in this parray?

• What about the light pixels?

9

Page 9: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Connected componentsConnected components labellinglabelling

• Labels each connected component of a binary image with a separate number.

1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 11 1 2 2 1 3 1 1 11 1 1 2 2 1 1 1 11 1 1 1 1 1 1 1 11 4 1 1 5 5 1 1 11 1 1 1 5 5 5 1 16 6 1 1 1 1 5 5 17 6 1 1 8 8 1 1 17 6 1 1 8 8 1 1 1

10

Page 10: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Foreground labelling

• Only extract the connected components of the foreground

1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 11 1 0 0 1 0 1 1 11 1 1 0 0 1 1 1 11 1 1 1 1 1 1 1 11 0 1 1 0 0 1 1 11 1 1 1 0 0 0 1 10 0 1 1 1 1 0 0 12 0 1 1 0 0 1 1 12 0 1 1 0 0 1 1 1

11

Page 11: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

What Are MorphologicalWhat Are Morphological Operators?Operators?

• Local pixel transformations for processing region shapes

• Most often used on binary imagesMost often used on binary images

• Logical transformations based on comparison of pixel neighbourhoods with acomparison of pixel neighbourhoods with a pattern.

18

Page 12: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Simple Operations - Examples

• Eight-neighbour erode– a.k.a. Minkowski subtraction

• Erase any foreground pixel that has one eight-connected neighbour that is background. g

19

Page 13: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

8-neighbour erode

Threshold

Erode ×1 Erode ×2 Erode ×5

20

Page 14: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

8-neighbour dilate

• Eight-neighbour dilate• a.k.a. Minkowski addition

• Paint any background pixel that has one eight-connected neighbour that is foreground.

21

Page 15: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

8-neighbour dilate

Dilate ×1 Dilate ×2 Dilate ×5

22

Page 16: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Why?

• Smooth region boundaries for shape analysis.

• Remove noise and artefacts from anRemove noise and artefacts from an imperfect segmentation.

• Match particular pixel configurations in anMatch particular pixel configurations in an image for simple object recognition.

23

Page 17: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Structuring Elements

• Morphological operations take two arguments:

• A binary imagey g• A structuring element.

• Compare the structuring element to theCompare the structuring element to the neighbourhood of each pixel.

• This determines the output of the morphological operation.

24

p g p

Page 18: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Structuring elements

• The structuring element is also a binary array.

• A structuring element has an originA structuring element has an origin.

1 1 11 1 1

0 1 01 1 1

0 1 01 0 1

11

1 1 1 0 1 0 0 1 0 0

25

Page 19: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Binary images as sets

• We can think of the binary image and the structuring element as sets containing the pixels with value 1.p

1 1 1 0 0

0 1 1

0 0 0

0

0

0

0

0 0 0 1 0

I = {(1,1), (2,1), (3,1), (2,2), (3,2), (4,4)}

0 0 0 1 0

0 0 0 0 0 (Matlab)S = SPARSE(X) converts a sparse or

26full matrix to sparse form bysqueezing out any zero elements

Page 20: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Some sets notation

• Union and i i

• Differenceintersection:

{ }2121 or : IxIxxII ∈∈=∪{ }2121 and:\ IxIxxII ∉∈=

• We use φ for the

{ }2121 and : IxIxxII ∈∈=∩

• Complement• We use φ for the

empty set .{ }IxxI C ∉= :

27

Page 21: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

More sets notation

• The symmetrical set of S with respect to point o is

{ }SS :(

0 1 1

1 1 1

1

1

0

1{ }SxxoS ∈−= :

1 1 1 1

1 1 1 1 1

1 1 1 1 1

0 1 1 1 0

0 1 1 1 01 1 1

0 1 1

0 0 0

0 0 0

1 1 0

1 1 1

0 1 1

1 1 1

1 1 1

1

1

1

0

1

1

28

0 0 0 1 1 11 1 1 1 1

0 1 1 1 0

Page 22: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Fitting, Hitting and Missing

• S fits I at x if

• S hits I at x ifISssxyy ⊂∈+= },:{

• S hits I at x ifφ≠∩∈+= ISssxyy },:{

• S misses I at x ifφ=∩∈+= ISssxyy },:{ φyy },{

29

Page 23: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Fitting, Hitting and Missing

0 1 0 1 1 1 1 1

Image Structuring element

1 0 10 1 1

11

10

10

10

10

0 1 01 1 10 1 1 1 0 0 0 0

0 1 1 1 1 0 0 00 1 1 1 0 0 0 0 0 1 0

0 1 0 0 0 0 1 00 1 0 1 0 1 0 00 1 1 1 1 0 0 0

0 1 0 0 0 0 1 00 1 0 0 0 0 0 0

30

Page 24: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Erosion

• The image E = I S is the erosion of image I by structuring element S.

⎩⎨⎧

=otherwise 0

at fits if 1)(

xISxE

}every for :{ SsIsxyyE ∈∈+== }y{ yy

31

Page 25: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Implementation (naïve)Implementation (naïve)% I is the input image, S is a structuring element

% with origin (ox, oy). E is the output image.

function E = erode(I, S, ox, oy)

[X,Y] = size(I);

[SX, SY] = size(S);

E = ones(X, Y);

for x=1:X; for y=1:Y

f i 1 f j 1for i=1:SX; for j=1:SY

if(S(i,j))

E( ) E( ) & ImageEntr (I +i +j )E(x,y) = E(x,y) & ImageEntry(I, x+i-ox, y+j-oy);

end

end; end

32

end; end

end; end

Page 26: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

1 1 1 1 1

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

33

1 1 1 1 1

1 1 1 1 1

Page 27: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

0 1 1 1 0

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

34

1 1 1 1 1

0 1 1 1 0

Page 28: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

1 0 0 0 0

Structuring element

0 1 0

0 0 1

0

0

0

0

0 0 0 1 0

35

0 0 0 1 0

0 0 0 0 1

Page 29: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Dilation

• The image D = I ⊕ S is the dilation of image I by structuring element S.

⎩⎨⎧

=th i0

at hits if 1)(

yISxD

⎩ otherwise 0

}anyfor:{ SsIsxyyD ∈∈+== }any for :{ SsIsxyyD ∈∈+==

36

Page 30: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Alternative Implementation

• For another implementation of erosion and dilation, note that:

( ))(min)( sxIxE += ( )( ))(max)(

)(min)(

sxIxD

sxIxESs

+=

+=∈

( ))(max)( sxIxDSs

+∈

37

Page 31: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

1 1 1 1 1

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

38

1 1 1 1 1

1 1 1 1 1

Page 32: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

0 1 1 1 0

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

39

1 1 1 1 1

0 1 1 1 0

Page 33: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

1 0 0 0 0

Structuring element

0 1 0

0 0 1

0

0

0

0

0 0 0 1 0

40

0 0 0 1 0

0 0 0 0 1

Page 34: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Erosion and dilation

• Erosion and dilation are dual operations:SISI CC (

⊕=) (

• Commutativity and associativity

ISSIISSI

≠⊕=⊕

)()()()(

TSITSITSITSI⊕=⊕⊕=⊕⊕

ISSI ≠ )( ) ( TSITSI ⊕=

41

Page 35: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

42

Page 36: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Input OutputInput Output

Structuring Element:

43

Page 37: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Opening and Closing

• The opening of I by S isSSISI ⊕= ) (o

• The closing of I by S isSSISI )( ⊕=•

44

Page 38: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Opening and Closing

• Opening and closing are dual transformations:

SISI CC (o=• )(

• Opening and closing are idempotenti

SISI o=• )(

operations:SSISI = )( ooo

SSISI ••=• )()(

45

Page 39: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

close

1 1 1 1 1

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

46

1 1 1 1 1

1 1 1 1 1open

Page 40: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

close

0 1 1 1 0

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

47

1 1 1 1 1

0 1 1 1 0open

Page 41: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

close

1 0 0 0 0

Structuring element

0 1 0

0 0 1

0

0

0

0

0 0 0 1 0

48

0 0 0 1 0

0 0 0 0 1open

Page 42: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Morphological filtering

• To remove holes in the foreground and islands in the background do both opening and closingthe background, do both opening and closing.

Th i d h f h i l• The size and shape of the structuring element determine which features survive.

• In the absence of knowledge about the shape of f i l ifeatures to remove, use a circular structuring element.

49

Page 43: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

Close then open

1 1 1 1 1

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

50

1 1 1 1 1

1 1 1 1 1Open then close

Page 44: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

Close then open

0 1 1 1 0

Structuring element

1 1 1

1 1 1

1

1

1

1

1 1 1 1 1

51

1 1 1 1 1

0 1 1 1 0Open then close

Page 45: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

ExampleExample

Close then open

1 0 0 0 0

Structuring element

0 1 0

0 0 1

0

0

0

0

0 0 0 1 0

52

0 0 0 1 0

0 0 0 0 1Open then close

Page 46: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Count the Red Blood Cells

53

Page 47: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Granulometry

• Provides a size distribution of distinct regions or “granules” in the image.

• We open the image with increasingWe open the image with increasing structuring element size and count the number of regions after each operationnumber of regions after each operation.

• Creates a “morphological sieve”.

54

Page 48: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Granulometryfunction gSpec = granulo(I, T, maxRad)

% Segment the image I

B = (I>T);

% Open the image at each structuring element size up to a

% i i i i% maximum and count the remaining regions.

for x=1:maxRad

O i (B t l(‘di k’ ))O = imopen(B,strel(‘disk’,x));

numRegions(x) = max(max(connectedComponents(O)));

endend

gSpec = diff(numRegions);

55

Page 49: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Count the Red Blood Cells

56

Page 50: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Threshold and Label

57

Page 51: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Disc(11)

58

Page 52: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Disc(19)

59

Page 53: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Disc(59)

60

Page 54: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Number of Regionss s

freg

ions

n ra

dius

mbe

r of

ller t

han

Num

sma

61Struct. Elt. radius

Page 55: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

GranulometricGranulometric Pattern SpectrumPattern Spectrum

sfr

egio

nsm

ber o

f N

um

62Struct. Elt. radius

Page 56: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Hit-and-miss transform

• Searches for an exact match of the structuring element.

• H = I ⊗ S is the hit-and-miss transform of i b i limage I by structuring element S.

• Simple form of template matching.

63

Page 57: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Hit-and-miss transform1 0 1

1 1 0

1

1

1

0

0 1 0

0 0 1

0

0

0

0

1 0 0 1 1

1 1 0 1 1

1 0 1 0 1

1 0 1⊗ = 0 0 0 0 0

0 0 1 0 0

0 1 0 1 01 0 1 0 1 0 1 0 1 0

1 0 1 1 1 0 1 0 0 0

1 1 0

1 0 0

1

1

0

1* 1

⊗ =0 0 0

0 1 0

0

0

1

01 0

1 1 0 1 1

1 0 1 0 1

10 0 1 0 0

0 0 0 0 0

64

Page 58: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Upper-Right Corner Detector

65bwhitmiss(BW1,SE1,SE2) ==

imerode(BW,SE1) & imerode(~BW,SE2)

Page 59: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Thinning and Thickening

• Defined in terms of the hit-and-miss transform:

• The thinning of I by S isThe thinning of I by S is)(\ SIISI ⊗=

• The thickening of I by S is)( SIISI ⊗∪=

• Dual operations:)( SIISI ⊗∪=

SISI CC ) ( =

66{ }2121 and :\ IxIxxII ∉∈=(Note) Difference:

Page 60: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

SequentialSequential Thinning/ThickeningThinning/Thickening

• These operations are often performed in sequence with a selection of structuring elements S1, S2, …, Sn.1, 2, , n

• Sequential thinning:{ } )))(((1 SSSIiSI

• Sequential thickening:

{ } ) )... ) (((,...,1: 21 ni SSSIniSI ==

Sequential thickening:{ } ) )... ) (((,...,1: 21 ni SSSIniSI ==

67

Page 61: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

SequentialSequential Thinning/ThickeningThinning/Thickening

• Several sequences of structuring elements are useful in practice

• These are usually the set of rotations of aThese are usually the set of rotations of a single structuring element.

• Sometimes called the Golay alphabet.Sometimes called the Golay alphabet.

68

Page 62: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Golay element L

* 1 *1 * 0* 0 00 0 0 * 1 *1 1 0* 0 0

L4

1 * 01 1 01 * 0

L3

* 0 01 1 0* 1 *

L2

0 0 0* 1 *1 1 1

L1

* 0 01 * 0* 1 *1 1 1

0 0 *0 1 1L

0 * 10 1 1L

* 1 *0 1 1L

1 1 1* 1 *L 0 1 1

* 1 *L80 1 1

0 * 1L70 1 1

0 0 *L6* 1 *

0 0 0L5

69

Page 63: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Sequential Thinning

• See bwmorph in matlab.

0 iterations 1 iteration 2 iterations 5 iterations Inf iterations

70

Page 64: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

S ti l Thi k iSequential Thickening

1 iteration 5 iterations

2 iterations Inf iterations

71

iterations

Page 65: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Skeletonization and the MedialSkeletonization and the Medial Axis TransformAxis Transform

• The skeleton and medial axis transform(MAT) ti k fi t ti f(MAT) are stick-figure representations of a region X ⊂ ℜ2.

• Start a grassfire at the boundary of the region.Start a grassfire at the boundary of the region.

Th k l i h f i hi h• The skeleton is the set of points at which two fire fronts meet.

72

Page 66: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Skeletons

73

Page 67: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Matlab ExampleI = imread('im1.bmp');image(bwdist(I)); colormap(gray)image(bwdist(I)); colormap(gray)

Idist = bwdist(I);IdistNormed = 255* (Idist / max(max(Idist)));IdistNormedThreshed = IdistNormed;

i iIdistNormedThreshed(IdistNormed<1) = NaN;surf(IdistNormedThreshed)

74

Page 68: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Medial axis transform

• Alternative skeleton definition:• The skeleton is the union of centres of maximal

discs within X.• A maximal disc is a circular subset of X that touches

the boundary in at least two places.

• The MAT is the skeleton with the maximalThe MAT is the skeleton with the maximal disc radius retained at each point.

75

Page 69: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Medial axis transform

76

Page 70: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Skeletonization usingSkeletonization using morphologymorphology

• Use structuring element 0 1 0

1 1 1B =

• The n th skeleton subset is

1 1 1

0 1 0

• The n-th skeleton subset is[ ]BBXBXXS nnn o) (\) ()( =

n denotes nsuccessive erosions

• The skeleton is the union of all the skeleton subsets:

erosions.

all the skeleton subsets:

U∞

= )()( n XSXS

77

U=1n

Page 71: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

MAT Implementation

• How can we extend the skeletonization algorithm to obtain the MAT?

78

Page 72: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Reconstruction

• We can reconstruct region X from its skeleton subsets:

U∞

⊕)( BXSX U=

⊕=0

)(n

nn BXSX

• We can reconstruct X from the MAT.• We cannot reconstruct X from S(X)• We cannot reconstruct X from S(X).

79

Page 73: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

DiFi: Fast 3D Distance Field Computation Using Graphics HardwareSud, Otaduy, Manocha, Eurographics 2004

80

, y, , g p

Page 74: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

MAT in 3D

from Transcendata Europe Medial Object

81

from Transcendata Europe Medial Object Price, Stops, Butlin Transcendata Europe Ltd

Page 75: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Applications and Problems

• The skeleton/MAT provides a stick figure i h i hrepresenting the region shape

• Used in object recognition, in particular, character recognition.

• Problems:• Definition of a maximal disc is poorly defined on a digital grid.• Sensitive to noise on the boundary.

• Sequential thinning output sometimes preferred to skeleton/MAT.

82

Page 76: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Example

k lSkeletons:

Thinned:

83

Page 77: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Gray-level Morphology

• Erosion, dilation• Opening and closing• The image and the structuring element areThe image and the structuring element are

gray level arrays.

• Used to remove speckle noise.• Also for smoothing, edge detection and

segmentation.84

g

Page 78: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Umbra{ })(:),()( xfyyxfU ≤=

f U ( f )85

f U ( f )

Page 79: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Top surface{ }RzxzyyxRT ∈≥= ),(allfor :),()(

T(R)R86

T(R)R

Page 80: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Gray level erode and dilate

• Erosion:))( )(( kUfUTkf =

• Dilation:))()(( kUfUTkf ⊕=⊕

• Open and close defined as before.87

p

Page 81: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

f U ( f )f U ( f )

k

)(kU

88))()(( kUfUT ⊕)()( kUfU ⊕

Page 82: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Max and min operators

• K is the domain of k.• Erosion:

{ })()(min)( zkzxfxkf −+= { })()(min)( zkzxfxkfKz

+∈

• Dilation:{ })()(max)( zkzxfxkf ++=⊕ { })()(max)( zkzxfxkf

Kz++=⊕

89

Page 83: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Erosion

S=ones(3,3) S=ones(5,5) S=ones(7,7)

90

Page 84: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Dilation

S=ones(3,3) S=ones(5,5) S=ones(7,7)

91

Page 85: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Speckle removalErode

Open

Salt and pepper noise

Close

92Dilate

Page 86: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Favorites

• E = medfilt2()• [D,L] = bwdist()

93

Page 87: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Summary

• Simple morphological operations• Erode and dilate• Open and close

• Applications:• GranulometryGranulometry• Thinning and thickening• Skeletons and the medial axis transform• Skeletons and the medial axis transform

• Gray level morphology

94

Page 88: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

95

Page 89: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Find the Letter ‘e’

96

Page 90: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Find the Letter ‘e’

97

Page 91: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Perception: ChangePerception: Change Detection?Detection?

• Examples from Daniel Simons’s many projectsprojects

• UBC examples of change blindness

Page 92: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Background Subtraction

• Chromakeying is often impracticalChromakeying is often impractical

• Camera pose is sometimes locked – opportunity!

Page 93: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Distance Measures

• Chromakey distance – remember?T>−= gIIα

T 20T = ~20g = ( 0 255 0 ) (for example)

• Plain Background-subtraction metric:TIII >= TIII >−= bgα

T = [ 20 20 10] (for example)[ ] ( p )Ibg = Background Image

Page 94: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Kylie Minogue, “Come Into My World”Di Mi h l G d

101

Director: Michel Gondry, Effects: Olivier “Twist” Gondry

Page 95: L3 Morphology 01.ppt - cs.brown.edu€¦ · • Introduction to gray level morphology. 2. Pixel connectivity • We need to define which pixels are neighbors. Warning: • Are the

Making of “Come Into My World”