morphological operators
play

Morphological Operators CS/BIOEN 4640: Image Processing Basics - PowerPoint PPT Presentation

Morphological Operators CS/BIOEN 4640: Image Processing Basics February 23, 2012 Common Morphological Operations Shrinking the foreground (erosion) Expanding the foreground (dilation) Removing holes in the foreground


  1. Morphological Operators CS/BIOEN 4640: Image Processing Basics February 23, 2012

  2. Common Morphological Operations ◮ Shrinking the foreground (“erosion”) ◮ Expanding the foreground (“dilation”) ◮ Removing holes in the foreground (“closing”) ◮ Removing stray foreground pixels in background (“opening”) ◮ Finding the outline of the foreground ◮ Finding the skeleton of the foreground

  3. Pixel Neighborhoods Remember the two definitions of “neighbors” that we’ve discussed: 4 Neighborhood 8 Neighborhood

  4. Erosion Example Change a foreground pixel to background if it has a background pixel as a 4-neighbor.

  5. Dilation Example Change a background pixel to foreground if it has a foreground pixel as a 4-neighbor.

  6. Structuring Element Definition A structuring element is simply a binary image (or mask) that allows us to define arbitrary neighborhood structures. Example: This is the structuring element for the 4-neighborhood.

  7. Binary Images as Sets We can think of a binary image I ( u , v ) as the set of all pixel locations in the foreground: Q I = { ( u , v ) | I ( u , v ) = 1 } To simplify notation, we’ll use a single variable for a coordinate pair, p = ( u , v ) . So, Q I = { p | I ( p ) = 1 }

  8. Set Operations = Point Operations ◮ Complement = Inversion Let I denote image inversion (pointwise NOT) Q I = Q I = { p ∈ Z 2 | p / ∈ Q I } ◮ Union = OR Let I 1 ∨ I 2 be pointwise OR operation Q I 1 ∨ I 2 = Q I 1 ∪ Q I 2 ◮ Intersection = AND Let I 1 ∧ I 2 be pointwise AND operation Q I 1 ∧ I 2 = Q I 1 ∩ Q I 2

  9. More Image Operations (Instead of Q I , we’ll just use I to denote the set) ◮ Translation: Let d ∈ Z 2 I d = { ( p + d ) | p ∈ I } ◮ Reflection: I ∗ = {− p | p ∈ I }

  10. Dilation Definition A dilation of an image I by the structure element H is given by the set operation I ⊕ H = { ( p + q ) | p ∈ I , q ∈ H } Alternative definition: Take the union of copies of the structuring element, H p , centered at every pixel location p in the foreground: � I ⊕ H = H p p ∈ I

  11. Dilation Algorithm Uses equivalent formula I ⊕ H = � q ∈ H I q : Input: Image I , structuring element H Output: Image I ′ = I ⊕ H 1. Start with all-zero image I ′ 2. Loop over all q ∈ H Compute shifted image I q 3. Update I ′ = I ′ ∨ I q 4.

  12. Erosion Definition A erosion of an image I by the structure element H is given by the set operation I ⊖ H = { p ∈ Z 2 | ( p + q ) ∈ I , for every q ∈ H } Alternative definition: Keep only pixels p ∈ I such that H p fits inside I : I ⊖ H = { p | H p ⊆ I }

  13. Duality of Erosion and Dilation Erosion can be computed as a dilation of the background: I ⊖ H = ( I ⊕ H ∗ ) Same duality for dilation: I ⊕ H = ( I ⊖ H ∗ )

  14. Erosion Algorithm Uses dual, I ⊖ H = ( I ⊕ H ∗ ) Input: Image I , structuring element H Output: Image I ′ = I ⊖ H 1. Start with inversion, I ′ = I 2. Dilate I ′ with reflected structure element, H ∗ 3. Invert I ′

  15. Properties of Dilation Similar to convolution properties, we need to assume the image domains are large enough that operations don’t “fall off” the edges. Commutativity: I ⊕ H = H ⊕ I Means we can switch the roles of the structuring element and the image

  16. Properties of Dilation Associativity: I 1 ⊕ ( I 2 ⊕ I 3 ) = ( I 1 ⊕ I 2 ) ⊕ I 3 Means that we can sometimes break up a big structuring element into smaller ones: That is, if H = H 1 ⊕ H 2 ⊕ . . . ⊕ H n , then I ⊕ H = ((( I ⊕ H 1 ) ⊕ H 2 ) ⊕ . . . ⊕ H n )

  17. Properties of Erosion ◮ It is NOT commutative: I ⊖ H � = H ⊖ I ◮ It is NOT associative, but: ( I ⊖ H 1 ) ⊖ H 2 = I ⊖ ( H 1 ⊕ H 2 )

  18. Some Particular Dilation Operators ◮ Identity: id = { ( 0 , 0 ) } I ⊕ id = id ⊕ I = I ◮ Shift by k pixels in x : S x = { ( k , 0 ) } ◮ Shift by k pixels in y : S y = { ( 0 , k ) }

  19. Opening Opening operation is an erosion followed by a dilation: I ◦ H = ( I ⊖ H ) ⊕ H Stray foreground structures that are smaller than the H structure element will disappear. Larger structures will remain.

  20. Closing Closing operation is a dilation followed by an erosion: I • H = ( I ⊕ H ) ⊖ H Holes in the foreground that are smaller than H will be filled.

  21. Improving a Segmentation Original image Initial threshold

  22. Improving a Segmentation Original image After opening

  23. Improving a Segmentation Original image After closing

  24. Outline The outline image B ( u , v ) of a binary object can be computed using a dilation followed by a subtraction (or XOR operation): I ′ = I ⊖ H B ( u , v ) = XOR ( I ′ ( u , v ) , I ( u , v ))

  25. Outline

  26. Outline Example Binary segmentation After outline operation

  27. Skeletonize Repeatedly run erosion, stop when 1-pixel thick

  28. Grayscale Morphology ◮ We can also apply morphological operators to grayscale images. ◮ Now our structuring elements are real-valued H ( i , j ) ∈ R . That is, they are grayscale images. ◮ Need to make a distinction between 0 and “don’t care” entries.

  29. Grayscale Morphology Dilation: ( I ⊕ H )( u , v ) = max ( i , j ) ∈ H { I ( u + i , v + j ) + H ( i , j ) } Erosion: ( I ⊖ H )( u , v ) = min ( i , j ) ∈ H { I ( u + i , v + j ) + H ( i , j ) }

  30. Link to ImageJ Morphology Package http://rsbweb.nih.gov/ij/plugins/ gray-morphology.html

Recommend


More recommend