Transcript
Page 1: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Gray-Scale Morphological Filtering

• Generalization from binary to gray level• Use f(x,y) and b(x,y) to denote an image and a structuring

element• Gray-scale dilation of f by b

– (f⊕b)(s,t)=max{f(s-x,t-y)+b(x,y)|(s-x), (t-y)Df and (x,y)Db}– Df and Db are the domains of f and b respectively– (f⊕b) chooses the maximum value of (f+ ) in the interval defined

by , where is structuring element after rotation by 180 degree ( )

• Similar to the definition of convolution with – The max operation replacing the summation and– Addition replacing the product

• b(x,y) functions as the mask in convolution– It needs to be rotated by 180 degree first

b̂ b̂b̂ ),(ˆ yxbb

Page 2: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Gray-Scale Dilation• Illustrated in 1D

– (f⊕b)(s)=max{f(s-x)+b(x)|(s-x)Df and xDb}

f(x) with slope 1

x xA

a

b(x)

s

{f(s1-x)+b(x)| )|(s-x)Df and x[-a/2,a/2]}

A

s1

max{f(s1-x)+b(x)| )|(s-x)Df and x[-a/2,a/2]}

=f(s1+a/2)+b(-a/2)= f(s1+a/2)+A=f(s1)+a/2+A

s

A

f ⊕b

A+a/2

Page 3: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Flat Gray Scale Dilation

• In practice, gray-scale dilation is performed using flat structuring element– b(x,y)=0 if (x,y)Db; otherwise, b(x,y) is not defined

– In this case, Db needs to be specified as a binary matrix with 1s being its domain

– (f⊕b)(x,y)=max{f(x-x’,y-y’), (x’,y’)Db}

– It is the same as the “max” filter in order statistic filtering with arbitrarily shaped domain

– Db can be obtained using strel function as in binary dilation case

Page 4: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Flat Gray-Scale Dilation

(f⊕b)(s)=max{f(s-x)| xDb}

f(x) with slope 1

x xA

a

Db

s

f ⊕b

1

Page 5: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Effects of Gray-Scale Dilation

• Depending on the structuring element adopted

• If all the values are non-negative (including flat gray scale dilation), the resulting image tends to be brighter

• Dark details are either reduced or eliminated– Wrinkle removal

Page 6: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Gray-Scale Erosion

• Gray-scale erosion of f by b– (f⊖b)(s,t)=min{f(s+x,t+y)-b(x,y)|(s+x), (t+y)Df and

(x,y)Db}

– Df and Db are the domains of f and b respectively

– (f⊖b) chooses the minimum value of (f-b) in the domain defined by the structuring element

Page 7: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Gray-Scale Erosion (f⊖b)(s)=min{f(s+x)-b(x)|(s+x)Df and xDb}

f(x) with slope 1

x xA

a

b(x)

s

{f(s1+x)-b(x)| )|(s+x)Df and x[-a/2,a/2]}A

s1

min{f(s1+x)-b(x)| )|(s+x)Df and x[-a/2,a/2]}

=f(s1-a/2)-b(-a/2)= f(s1-a/2)-A= f(s1)-a/2-A

s

A+a/2

f ⊖ b

Page 8: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Flat Gray Scale Erosion

• In practice, gray-scale erosion is performed using flat structuring element– b(x,y)=0 if (x,y)Db; otherwise, b(x,y) is not defined

– In this case, Db needs to be specified as a binary matrix with 1s being its domain

– (f⊖b)(x,y)=min{f(x+x’,y+y’), (x’,y’)Db}

– It is the same as the “min” filter in order statistic filtering with arbitrarily shaped domain

– Db can be obtained using strel function as in binary case

Page 9: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Effects of Gray-Scale Erosion• Depending on the structuring element

adopted

• If all the values are non-negative (including flat gray scale dilation), the resulting image tends to be darker

• Bright details are either reduced or eliminated

Page 10: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Examples

Reduced

Eliminated

Reduced

Eliminated

Page 11: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Dual Operations

• Gray-scale dilation and erosion are duals with respect to function complementation and reflection– ⊖

– It means dilation of a bright object is equal to erosion of its dark background

),(ˆ and ),( where

),() (),)(ˆ(

yxbbyxff

tsbftsbfc

cc

Page 12: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Gray-Scale Opening and Closing

• The definitions of gray-scale opening and closing are similar to that of binary case– Both are defined in terms of dilation and erosion

• Opening (erosion followed by dilation)– A◦b=(A⊖b)⊕b

• Closing (dilation followed by erosion)– A•b=(A⊕b)⊖b

• Again, opening and closing are dual to each other with respect to complementation and reflection– )ˆ(or )ˆ( bfbfbfbf cc

Page 13: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Geometric Interpretation

Page 14: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Properties of Gray-Scale Opening and Closing

• Opening1. ( f ◦ b ) f2. If f1 f2, then (f 1◦ b) (f 2◦ b )3. (f ◦ b )◦ b =f ◦ b

• Closing– f ( f • b ) – If f1 f2, then (f 1 • b) (f 2 • b )– (f • b • b) =f • b

1. The notation e r is used to indicate that the domain of e is a subset of r and e(x,y)r(x,y)

2. The above properties can be justified using the the geometric interpretation of opening and closing shown previously

Page 15: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Example9.31 (a) may be not correct

Page 16: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Applications of Gray-Scale Morphology

• Morphological smoothing– Opening (reduce bright details) followed by closing (reduce dark details) – Alternating sequential filtering

• Repeat opening followed by closing with structuring elements of increasing sizes

A◦b5

A◦b5•b5 A•b2◦b2•b3◦b3•b4◦b4•b5◦b5

Page 17: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Applications of Gray-Scale Morphology

• Morphological gradient– Effects of dilation (brighter) and erosion

(darker) are manifested on edges of an image– g = (f⊕b) - (f⊖b) can be used to bring out

edges of an image

Page 18: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Applications of Gray-Scale Morphology

• Top-hat transform– Defined as h = f – (f◦b)– Useful for enhancing details in the

presence of shading

Page 19: Gray-Scale Morphological Filtering Generalization from binary to gray level Use f(x,y) and b(x,y) to denote an image and a structuring element Gray-scale

Another Application of Top-Hat Transform

• Compensation for nonuniform background illumination


Recommended