1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

56
1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009

Transcript of 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Page 1: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

1

Regions and Binary Images

Hao Jiang

Computer Science Department

Sept. 24, 2009

Page 2: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Figure Ground Separation

2

Page 3: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Brightness Thresholding

3

Page 4: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

=-

Thresholding Given a grayscale image or an intermediate matrix

threshold to create a binary output.

Example: background subtraction

Looking for pixels that differ significantly from the “empty” background.

fg_pix = find(diff > t);Slide from Kristen Grauman

Page 5: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Thresholding Given a grayscale image or an intermediate matrix

threshold to create a binary output.

Example: color-based detection

Looking for pixels within a certain hue range.

fg_pix = find(hue > t1 & hue < t2);

Slide from Kristen Grauman

Page 6: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

More Binary Images

6

Slide from Kristen Grauman

Page 7: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Issues

How to demarcate multiple regions of interest? Count objects Compute further features per

object

What to do with “noisy” binary outputs? Holes Extra small fragments

Slide from Kristen Grauman

Page 8: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Find Connected Regions

8

Page 9: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Find Connected Regions

9

Our target in this image is the largest blob.

Page 10: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Connected Components

Identify distinct regions of “connected pixels”

Shapiro and Stockman

Page 11: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Pixel Neighbors

11

4 neighboring pixels of the blue pixel

Page 12: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Pixel Neighbors

12

8 neighboring pixels of the blue pixel

Page 13: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Recursive Method

13

label = 2for i = 1 to rows for j = 1 to cols if I(i, j) == 1 labelConnectedRegion(i, j, label) label ++; endend

Page 14: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Recursive Method

14

function labelConnectedRegion(int i, int j, int label) if (i,j) is labeled or background or out of boundary return

I(i,j)=label for (m,n) belongs to neighbors of (i,j) labelConnectedRegion(m,n,label) end

Page 15: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Two Pass Method

We check each pixel from left to right and up to bottom If a pixel has no left and up foreground neighbor, we assign a

new label to the pixel If a pixel has only one left or up foreground neighbor, we

assign the label of the neighbor to the pixel If a pixel has both left and up foreground neighbors, and their

labels are the same, we assign the label of the neighbor to the pixel

If a pixel has both left and up foreground neighbors, and their labels are the different, we assign the label of the left neighbor to the pixel and use the up-left label pair to update the equivalency table.

We go through another pass to replace the labels to corresponding labels in the equivalency table

15

Page 16: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

16

1 1 1 1 1

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 17: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

17

2 1 1 1 1

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 18: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

18

2 2 1 1 1

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 19: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

19

2 2 3 1 1

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 20: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

20

2 2 3 3 1

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 21: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

21

2 2 3 3 3

1 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 22: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

22

2 2 3 3 3

2 1 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 23: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

23

2 2 3 3 3

2 2 1 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 24: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

24

2 2 3 3 3

2 2 2 1

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 25: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

25

2 2 3 3 3

2 2 2 2

1 1 1 1

1 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

(2,3)

Page 26: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

26

2 2 3 3 3

2 2 2 2

2 1 1 1

1 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 27: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

27

2 2 3 3 3

2 2 2 2

2 2 1 1

1 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 28: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

28

2 2 3 3 3

2 2 2 2

2 2 4 1

1 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 29: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

29

2 2 3 3 3

2 2 2 2

2 2 4 4

1 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 30: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

30

2 2 3 3 3

2 2 2 2

2 2 4 4

5 1 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 5

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 31: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

31

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 1 1 1

1 1 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

(5,2)

Page 32: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

32

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 1 1

1 1 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 33: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

33

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 1

1 1 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 34: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

34

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

1 1 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 35: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

35

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

5 1 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 36: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

36

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

5 5 1 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 37: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

37

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

5 5 5 1 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 38: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

38

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

5 5 5 5 1

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

(5,2)

Page 39: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

39

2 2 3 3 3

2 2 2 2

2 2 4 4

5 5 2 4 4

5 5 5 5 4

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 40: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example

40

3 3 3 3 3

3 3 3 3

3 3 4 4

3 3 3 4 4

3 3 3 3 4

2 3

3 3

4 4

5 3

6 6

7 7

8 8

9 9

Image Label equivalence table

Page 41: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operations

Define

At = { p + t | p is a point in A}

Erosion

41

T = { t | At belongs to S}

A

S

Erosion(S, A)

Page 42: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operations

Define

At = { p + t | p is a point in A}

Erosion

42

T = { t | At belongs to S}

S

What if A is

Page 43: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operations

Define

At = { p + t | p is a point in A}

Dilation

43

T = Union of At and S for all t in S

S

What if A is Erosion(S, A)

Page 44: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operations

Define

At = { p + t | p is a point in A}

Dilation

44

T = Union of At and S for all t in S

S

What if A is

Page 45: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operations Define

At = { p + t | p is a point in A}

Dilation

45

T = Union of At and S for all t in S

What if A is

Page 46: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Opening

Erode, then dilate Remove small objects, keep original shape

Before opening After opening

Slide from Kristen Grauman

Page 47: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Closing

Dilate, then erode Fill holes, but keep original shape

Before closing After closing

Slide from Kristen Grauman

Page 48: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Morphology Operators on Grayscale Images

Dilation and erosion typically performed on binary images. If image is grayscale: for dilation take the neighborhood max, for erosion

take the min.

original dilated eroded

Slide from Kristen Grauman

Page 49: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Matlab

Create structure element

se = strel(‘disk’, radius); Erosion

imerode(image, se); Dilation

imdilate(image, se); Opening

imopen(image, se); Closing

imclose(image, se); More possibilities

bwmorph(image, ‘skel’);

49

Page 50: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Figure Ground Separation

50

Page 51: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Brightness Thresholding

51

Page 52: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Opening

52

Page 53: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Find the Largest Connected Region

53

Page 54: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example Using Binary Image Analysis: segmentation of a liver

Slide credit: Li Shen Slide from Kristen Grauman

Page 55: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

Example Using Binary Image Analysis:Bg subtraction + blob detection

Slide from Kristen Grauman

Page 56: 1 Regions and Binary Images Hao Jiang Computer Science Department Sept. 24, 2009.

University of Southern Californiahttp://iris.usc.edu/~icohen/projects/vace/detection.htm

Example Using Binary Image Analysis:Bg subtraction + blob detection

Slide from Kristen Grauman