ee465: introduction to digital image processing 1 what is in common?

64
EE465: Introduction to Di gital Image Processing 1 What is in Common?

Upload: toby-mills

Post on 21-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

1

What is in Common?

Page 2: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

2

A BW Image and Its Inverse

Page 3: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

3

Application (I): FAX Document

Page 4: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

4

Application (II): Scanned Documents

Page 5: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

5

Application (III): Biometrics

Page 6: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

6

Application (IV): Image Matting

figure-ground segmentationin computer vision

Page 7: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

7

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 8: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

8

Binary Images

Images only consist of two colors (tones): white or black

Numerical example (image of a square block)

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Page 9: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

9

Why are binary images special?

Since pixels are either white or black, the locations of white (black) pixels carry ALL information of binary imagesExample

0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1

f(m,n)

L={(3,3),(3,4),(4,3),(4,4)}

location of white pixels

It is often more convenient to consider the set representation than the matrix representation for binary images

matrix representation set representation

Page 10: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

10

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation

• Opening and closing

• Hit-or-miss

• Boundary extraction

• Region-filling

• Thinning (for finding skeleton) Other processing algorithms

• Area calculation, finding connected components

• Skeleton finding via distance transform

Page 11: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

11

Set Theory Review

}|{ AwwAc cBABwAwwBA },|{Think of sets A and B as the collections of spatial coordinates

Page 12: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

12

Translation Operator

},|{)( AazawwA z

),( 21 zzz

Example

Page 13: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

13

Reflection Operator

},|{ˆ BbbwwB

Example

B B̂

Page 14: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

14

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation

• Opening and closing

• Hit-or-miss

• Boundary extraction

• Region-filling

• Thinning (for finding skeleton) Other processing algorithms

• Area calculation, finding connected components

• Skeleton finding via distance transform

Page 15: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

15

Structuring Element B

Definition: a set of local neighborhood with specified origin

Examples

origin

B1 B2

Note: different structuring element leads to different filtering result

Page 16: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

16

mask B

X Y

XBBXBXYBb Xx

xb

Definition

Example

Dilation

})ˆ(|{ XBzBXY z

or

Page 17: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

17

X

Xca

B={a,b,c}

BX

a=(0,0),b=(0,-1),c=(-1,0)

origin

Xcb

B

XccBX c

Illustration by Animation

Page 18: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

18

mask B

X Y

Definition

Example

Erosion

Y=X B_ }:{}:{ cxx XBxXBx

Page 19: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

19

mask B

XY

Illustration By Animation

Page 20: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

20

(X B)c_ =XcB̂

Duality Property*

Proof:

(X B)c_={z | Bz A }c

= {z | Bz Ac = }c

= {z | Bz Ac }

=Xc B^

Page 21: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

21

X

B

Xc

(X B)c_X B_

XcB̂

Example

Page 22: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

22

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 23: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

23

(X B) B_ +Definition

mask B

X

_

+

BX

BX

Opening Operator

Example

Page 24: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

24

Geometric Interpretation of Opening Operator

Page 25: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

25

Definition (X B) B+ _

_

+

mask B

BX

X

BX

Closing Operator

Example

Page 26: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

26

Geometric Interpretation of Closing Operator

Page 27: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

27

Properties of Opening and Closing Operators*

Opening

Closing

XBX ●

BYBXYX BXBBX )(

BXX ●

BYBXYX BXBBX )(

BXBX CC ˆ)( BXBX CC ˆ)(

Page 28: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

28

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 29: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

29

A Little Game of Matching

Templates

A

B

Page 30: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

30

Illustration by a Simpler Case

Template B

How to find the match of A in Xusing a computer?

X

Hit: the southwest quadrant must be black in X

origin

Hit: the other three quadrants must be white in X

Hit: the southwest quadrant must be black in X

Hit: the other three quadrants must be black in Xc

Page 31: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

31

Matching via Hit-or-Miss

Template B

origin

Hit: the southwest quadrant must be black in X

Hit: the other three quadrants must be black in Xc

Template B1

Template B2

X1=X B1_

X2 =Xc B2_

To satisfy both conditions, we need to take the intersection of X1 and X2

Page 32: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

32

mask B1

(MATLAB function: bwhitmiss)

(X B1)(Xc B2)_ _X B=*

Hit Miss

mask B2

origin

mask B

x

x x

MATLAB

0 -1 -11 1 -10 1 0

Hit-or-Miss Operator

Definition

Structuring element example

Why ? _

Why complement?Why intersection?

Page 33: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

33

X

Example 1

mask B1 mask B2

origin

Xc Xc B2X B1_ _

X B*

Page 34: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

34

mask B1 mask B2 mask B MATLAB

-1 -1 -11 1 -11 1 -1

Example 2 origin

X Xc Xc B2X B1_ _

X B*Now, take the intersectionand note that only two pointsRemain (highlighted by red)

Page 35: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

35

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 36: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

36

“BAD EXAMPLE”

Y=X-(X B)_

mask B

X X B_

Page 37: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

37

X-(X B)_

mask B

X X B_

Boundary Extraction

Example

X=X-(X B)_Definition

X=(X B) – B?+

How about

cBABA Note that

Page 38: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

38

XX

Image Example

Page 39: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

39

Inner vs. Outer Boundary

Page 40: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

40

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 41: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

41

P

X

Iterations:

Y0=P

Yk=(Yk-1B)Xc, k=1,2,3…mask B

Terminate when Yk=Yk-1,output YkX

Idea: recursively expand the region around P but stopthe expansion at the boundary of X

Region Filling

expansion stop at the boundary

Why dilation?Why intersection with Xc?

Page 42: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

42

X Y0

P

Y0B Xc Y1

Y1B Y2Y2B Y3=Y2

Image Example

Page 43: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

43

Additional Example

P

Page 44: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

44

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 45: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

45

Thinning

thinning

Intuitively, thinning finds the skeleton of a binary image (you will learn adifferent way of finding skeleton by distance transform later)

Page 46: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

46

Thinning Algorithm

Basic idea: Use Hit-or-Miss operator as a sifter

Use multiple masks to characterize different patterns

x

xB2

x x

B1

x

x

B3

x

x

B4 B6

x x

B5 B7 B8

x

x x

x

x

x

X0=X

Xk=(…( (Xk-1 B1) B2 … B8)

where X B=X – X B*Stop the iteration when Xk=Xk-1

Why eight different B’s?Why hit-or-miss?

Page 47: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

47

Image Example

Page 48: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

48

Image Example (Con’t)

Binary fingerprint image Skeleton image

Page 49: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

49

Morphological Filtering: Skeletons*

X kB=(((X B) B) … B)_ _ _ _

k-fold

Define

Sk(A)=(A kB)-(A KB) B_ _and

Then the skeleton of an image A is given by

0

)()(k

k ASAS

Page 50: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

50

Textbook Example*

Page 51: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

51

Image Example*

Binary fingerprint image Skeleton image

Page 52: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

52

Summary of Morphological Filtering

MATLAB codes

circshift(A,z)

fliplr(flipud(B))

~A or 1-A

A &~B

imdilate(A,B)

imerode(A,B)

imopen(A,B)

imclose(A,B)

Page 53: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

53

Summary (Con’d)

bwhitmiss(A,B)

A&~(imerode(A,B))

region_fill.m

bwmorph(A,’thin’);

Page 54: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

54

What is Common?

Page 55: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

55

One-Minute Survey

If X={even integers}, Y={multiples of 6}, what is X-Y?

How long did you spend on CA#1? What do you think of the pace of this course so

far? What is the muddiest point in the last two

weeks’ lectures? Do you mind my posting the class grade using

the last 4-digit of your ID?

Page 56: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

56

Binary Image Processing Introduction Set theory review Morphological filtering operators

• Erosion and dilation• Opening and closing• Hit-or-miss • Boundary extraction• Region-filling• Thinning (for finding skeleton)

Other processing algorithms• Area calculation, finding connected components• Skeleton finding via distance transform

Page 57: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

57

Building New Pieces

How to calculate the perimeter of a binary object A?• Find the boundary first (MATLAB: bwperim(A))

How to calculate the area of a binary object A?• MATLAB: bwarea or sum(sum(A))

• Complication: what if there are multiple binary objects?

(this relates to binary image analysis. MATLAB: bwlabel)

How to get rid of small holes of a binary object?• Recall region filling routine (MATLAB: bwareaopen)

Page 58: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

58

Image Examples

A label2rgb(bwlabel(A)) bwareaopen(A,50)

Page 59: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

59

Medial Axis Transform (a.k.a. Skeleton)

• What is medial axis?

• Examples

Suppose that a fire line propagates with constant speed from thecontour of a connected object towards its inside, then all those points lying in positions where at least two wave fronts of the fire line meet during the propagation will constitute a form of a skeleton

Page 60: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

60

Distance Transform

http://demonstrations.wolfram.com/DistanceTransforms/

Page 61: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

61

Skeleton Algorithm

• Distance transform: find the distance from thenearest boundary for each point

• Skeleton is the set of points whose distance from thenearest boundary is locally maximum

),(),(0 nmxnmx - initialization

- iteration }1),;,(:),(min{),(),( 1 jinmdjixnmxnmx kok

}1),;,(),,(),(:),{( jinmdjixnmxnm kk

Page 62: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

62

1 1 1 1 11 1 1 1 11 1 1 1 11 1 1 1 11 1 1 1 1

1 1 1 1 11 2 2 2 11 2 2 2 11 2 2 2 11 1 1 1 1

1 1 1 1 11 2 2 2 11 2 3 2 11 2 2 2 11 1 1 1 1

1 1 2 2 3 2 21 1

x0(m,n) x1(m,n) x3(m,n) skeletonlocal maximum

• Example

Skeleton Algorithm (Cont’d)

Page 63: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

63

Image Example

original skeleton

Page 64: EE465: Introduction to Digital Image Processing 1 What is in Common?

EE465: Introduction to Digital Image Processing

64

Binary Image Processing Summary