390 likes | 1.04k Views
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) D f and (x,y)D b }
E N D
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
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 b(x) A x x a 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 {f(s1-x)+b(x)| )|(s-x)Df and x[-a/2,a/2]} f ⊕ b A A A+a/2 s s s1
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
Flat Gray-Scale Dilation (f⊕b)(s)=max{f(s-x)| xDb} f(x) with slope 1 Db 1 A x x a f ⊕ b s
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
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
Gray-Scale Erosion (f⊖b)(s)=min{f(s+x)-b(x)|(s+x)Df and xDb} f(x) with slope 1 b(x) A x x a 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 f ⊖ b A+a/2 A {f(s1+x)-b(x)| )|(s+x)Df and x[-a/2,a/2]} s s s1
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
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
Examples Reduced Eliminated Eliminated Reduced
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
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
Properties of Gray-Scale Opening and Closing • Opening • ( f◦ b ) f • If f1 f2, then (f1◦ b) (f2◦ b ) • (f ◦ b )◦ b =f ◦ b • Closing • f ( f• b ) • If f1 f2, then (f1 •b) (f2 •b ) • (f•b•b) =f•b • 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) • The above properties can be justified using the the geometric interpretation of opening and closing shown previously
Example 9.31 (a) may be not correct
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•b2◦b2•b3◦b3•b4◦b4•b5◦b5 A◦b5•b5
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
Applications of Gray-Scale Morphology • Top-hat transform • Defined as h = f – (f◦b) • Useful for enhancing details in the presence of shading
Another Application of Top-Hat Transform • Compensation for nonuniform background illumination