image and multidimensional signal...

Post on 04-Aug-2020

17 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Colorado School of Mines

Image and Multidimensional Signal Processing

Professor William Hoff

Dept of Electrical Engineering &Computer Science

http://inside.mines.edu/~whoff/

Colorado School of Mines Department of Electrical Engineering and Computer Science

Morphological Image Processing

2

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Preview

• “Morphological” = shape, form, structure

• Notes

– Useful for extracting and describing image component regions

– Usually applied to binary (black & white, or 0 & 1) images

– Based on set theory

• Key topics:

– Set theory

– Binary operations: dilation, erosion, opening, closing

– Connected components

– Morphological algorithms

– Gray scale morphology

3

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Binary Images

• Obtained from – Thresholding gray level images (e.g., Matlab’s “im2bw”)

– Or, as a resulting product of feature detectors

• Often want to count or measure shape of 2D binary image regions

• Typical applications – Objects on a conveyor belt

– Characters and text, maps

– Chromosomes

– Fingerprints

– Circuit boards

– Overhead aerial images

4

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Set Theory Concepts

• For 2D binary images, A is the (unordered) set of pairs (x,y) such

that the image value at (x,y) is equal to 1

• “Union” of two sets A and B

– The set of elements belonging to A, B, or both

• “Intersection” of two sets A and B

– The set of elements belonging to both A and B

• w “is an element of” set A

, | ( , ) 1AA x y I x y

The vertical bar means “such that”

A B

A B

w A

5

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Set Theory Concepts

• “Complement”

– The set of elements that are not in A

• “Difference” of two sets A and B

– The set of elements belonging to A, but not to B

• “Subset”

– A is a subset of B if every element of A is also in B

• The empty set { }

|cA w w A

| ,A B w w A w B

A B

Comma means “and”

6

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Set Operations

, | ( , ) 1 , , | ( , ) 1A BA x y I x y B x y I x y

7

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Reflection and Translation

ˆ ,B w w b for b B

,z

B c c b z for b B

8

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Structuring Elements

• Morphological operations are defined based on “structuring

elements”

• A structuring element is a small set or subimage, used to probe for

structure

• Examples

9

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Erosion

• The erosion of set A by set (i.e., structuring element) B is

AӨB =

• Interpretation: shift B by z, if it is completely inside A, output a 1

• Example

10

ABz z |

1 1 1

1

1

1

1 1 1 1 1

A

B

Origin of B

AӨB

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Erosion Examples

w

w

w/2

AӨB

Radius r r

AӨB

w w

w AӨB

11

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Erosion

• Erosion enlarges holes,

breaks thin parts, shrinks

object

• Is not commutative

B A

AӨB ≠ BӨA

12

AӨB

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Dilation

• The dilation of set A by set (structuring element) B is

• Interpretation: reflect B, shift by z, if it overlaps with A, output a 1 at

the center of B

• Example

13

ˆ|z

A B z B A

A B

1

1

1

1

1

1

1

1 1

A

B

Origin of B

1 1

Colorado School of Mines Department of Electrical Engineering and Computer Science

Another dilation example

• Example

1

1

1

1 1

1

1

1

A

B

Origin of B

A B

14

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Dilation Examples

w

w

w/2

A B

w

A B

w

w

Radius r r

A B

15

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Dilation Example

A BA

B

16

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Dilation

• Dilation fills in holes,

thickens thin parts, grows

object

B A

17

A B

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Dilation Properties

• Is commutative

• and associative

• Proof of commutative property

– If we translate both sets, the intersection

area is the same

– If we reflect both sets, the intersection

area is the same

A B B A

A B C A B C

ˆ|z

A B z B A

ˆ|z

z B A

ˆ|z

z B A B A

B̂B

A

z

18

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Duality of Dilation and Erosion

BAc ˆ (AӨB)c =

• Proof

Recall that Ac means the

complement of set A

ABz z |AӨB =

| c

zz B A

(AӨB)c = |c

c

zz B A

|

ˆ

c

z

c

z B A

A B

If set (B)z is contained in A, then

the intersection of (B)z with the

complement of A is empty

Complement both sides

By the definition of dilation

19

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Example

1

1

1

1

1 1

A

B

Origin of B

1

Origin of A

AӨB

(AӨB)c

cA

BAc ˆ

20

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Matlab examples

• Make a structuring element

– SE = strel('square', W)

or

– SE = strel('disk', R )

• Dilation and erosion

– imdilate(IM, SE)

– imerode(IM, SE)

• Try image ‘blobs.png’

21

Colorado School of Mines Department of Electrical Engineering and Computer Science

Opening

• Opening – an erosion followed by a dilation

– Use the same structuring element B for both

• Is the union of all translates of B, that fit into A

BBABA

|z z

A B B B A

http://en.wikipedia.

org/wiki/Mathemat

ical_morphology

The opening of the

dark-blue square by a

disk, resulting in the

light-blue square with

round corners.

22

Colorado School of Mines Department of Electrical Engineering and Computer Science

Opening

• Intuitive description

– Let B be a disk

– The boundary of the opening is the points in B that reach the

farthest into A as B is rolled around inside of A

23

Colorado School of Mines Department of Electrical Engineering and Computer Science

Closings

• Closing – a dilation followed by an erosion

– Use the same structuring element B for both

• Take the union of all the translates of B that do not intersect A;

the closing is the complement of that

BBABA

The closing of the dark-blue

shape (union of two squares)

by a disk, resulting in the

union of the dark-blue shape

and the light-blue areas.

http://en.wikipedia.

org/wiki/Mathemat

ical_morphology

24

Colorado School of Mines Department of Electrical Engineering and Computer Science

Closings

• Intuitive description

– Let B be a disk

– We roll B around the outside of A

– The boundary of the closing is the points of B that just touch A

25

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Example - opening

B

26

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Example - closing

B

27

Colorado School of Mines Department of Electrical Engineering and Computer Science

Openings and Closings

• Are duals of each other

• Properties

is a subset of A

A is a subset of

• Once an image has been opened (or closed), the re-application of

the same operation has no effect

BABA cc ˆ

BABBA

BABBA

A B

A B

28

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

29

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Matlab examples

• Make a structuring element

– SE = strel('square', W)

or

– SE = strel('disk', R, N)

• Dilation and erosion

– imopen(IM, SE)

– imclose(IM, SE)

• Try image ‘blobs.png’

30

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Connected Components

• Define adjacency

– 4-adjacent

– 8-adjacent

• Two pixels are connected in S if there is a path between them consisting entirely of pixels in S

• S is a (4- or 8-) connected component (“blob”) if there exists a path between every pair of pixels

• “Labeling” is the process of assigning the same label number to every pixel in a connected component

4-connected 8-connected

31

Colorado School of Mines Department of Electrical Engineering and Computer Science

Example

1 1

1 1

1 1

1 1 1

1 1 1

• Hand label simple binary image

Binary image Labeled image

(4-connected)

Labeled image

(8-connected)

32

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

A Fast Labeling Algorithm

• One pass through image to assign temporary labels and

record equivalences

• Second pass to replace temporary labels with

equivalence labels

• Let

– B(r,c) is the input binary image

– L(r,c) is the output image of labels

• Side note – faster labeling algorithms do exist. They use 2x2 blocks to search for connected

components and use the fact that all the pixels within the block are 8-connected.

• C. Grana, D. Borghesani, and R. Cucchiara. “Fast block based connected components labeling.”

Proc of ICIP, pages 4061-4064, 2009.

33

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

for c=1 to MAXCOL {

for r=1 to MAXROW {

if B(r,c) == 0 then

L(r,c) = 0; % if pixel not white, assign no label

else {

34

Colorado School of Mines Department of Electrical Engineering and Computer Science

Example

1 1 1

1 1 1

1 1 1

1 1 1

Binary image Temporary labels

after 1st pass Final (equivalence)

labels after 2nd pass

35

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Matlab Example

• Labeling connected components (white blobs) – im2bw

• threshold to convert to binary image

– bwlabel

• do connected component labeling

• generate an image of labels

– label2rgb

• for visualization

• converts each label to a random color

• If we want to find black blobs – imcomplement

• Flip black and white regions

– then repeat steps

Image Fig9-16(a).jpg

36

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

>> I = imread('Fig9.16(a).jpg');

>> imshow(I,[])

>> whos

Name Size Bytes Class Attributes

I 512x512 262144 uint8

>> BW = im2bw(I, graythresh(I));

>> figure, imshow(BW)

>> [L,num] = bwlabel(BW);

>> figure, imshow(L,[])

>> num

num =

17

>> RGB = label2rgb(L);

>> figure, imshow(RGB)

>> BW = imcomplement(BW);

>> [L,num] = bwlabel(BW);

>> RGB = label2rgb(L);

>> figure, imshow(RGB)

37

Colorado School of Mines Department of Electrical Engineering and Computer Science Colorado School of Mines Department of Electrical Engineering and Computer Science

Summary / Questions

• Morphological operations on binary images

involve a “structuring element”.

– A structuring element is a small subimage, used to

probe for structure.

• Morphological operations are useful for:

– Eliminating small regions or filling in “holes”.

– Finding “connected components”.

• What is a “connected component”?

38

top related