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

What is in Common?

  • Upload
    calder

  • View
    45

  • Download
    0

Embed Size (px)

DESCRIPTION

What is in Common?. A BW Image and Its Inverse. Application (I): FAX Document. Application (II): Scanned Documents. Application (III): Biometrics. Application (IV): Image Matting. figure-ground segmentation in computer vision. Binary Image Processing. Introduction Set theory review - PowerPoint PPT Presentation

Citation preview

Page 1: What is in Common?

EE465: Introduction to Digital Image Processing

1

What is in Common?

Page 2: What is in Common?

EE465: Introduction to Digital Image Processing

2

A BW Image and Its Inverse

Page 3: What is in Common?

EE465: Introduction to Digital Image Processing

3

Application (I): FAX Document

Page 4: What is in Common?

EE465: Introduction to Digital Image Processing

4

Application (II): Scanned Documents

Page 5: What is in Common?

EE465: Introduction to Digital Image Processing

5

Application (III): Biometrics

Page 6: What is in Common?

EE465: Introduction to Digital Image Processing

6

Application (IV): Image Matting

figure-ground segmentationin computer vision

Page 7: 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: 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: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

12

Translation Operator

},|{)( AazawwA z

),( 21 zzz

Example

Page 13: What is in Common?

EE465: Introduction to Digital Image Processing

13

Reflection Operator

},|{ˆ BbbwwB

Example

B B̂

Page 14: 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: 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: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

19

mask B

XY

Illustration By Animation

Page 20: 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: What is in Common?

EE465: Introduction to Digital Image Processing

21

X

B

Xc

(X B)c_X B_

XcB̂

Example

Page 22: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

24

Geometric Interpretation of Opening Operator

Page 25: 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: What is in Common?

EE465: Introduction to Digital Image Processing

26

Geometric Interpretation of Closing Operator

Page 27: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

29

A Little Game of Matching

Templates

A

B

Page 30: 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: 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: 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: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

36

“BAD EXAMPLE”

Y=X-(X B)_

mask B

X X B_

Page 37: 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: What is in Common?

EE465: Introduction to Digital Image Processing

38

XX

Image Example

Page 39: What is in Common?

EE465: Introduction to Digital Image Processing

39

Inner vs. Outer Boundary

Page 40: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

43

Additional Example

P

Page 44: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

47

Image Example

Page 48: What is in Common?

EE465: Introduction to Digital Image Processing

48

Image Example (Con’t)

Binary fingerprint image Skeleton image

Page 49: 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: What is in Common?

EE465: Introduction to Digital Image Processing

50

Textbook Example*

Page 51: What is in Common?

EE465: Introduction to Digital Image Processing

51

Image Example*

Binary fingerprint image Skeleton image

Page 52: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

54

What is Common?

Page 55: 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: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

58

Image Examples

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

Page 59: 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: What is in Common?

EE465: Introduction to Digital Image Processing

60

Distance Transform

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

Page 61: 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: 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: What is in Common?

EE465: Introduction to Digital Image Processing

63

Image Example

original skeleton

Page 64: What is in Common?

EE465: Introduction to Digital Image Processing

64

Binary Image Processing Summary