Sed For: GW 9 Ida-Maria • Pre-Processing Suggested Problem: 9.7 a • Noise Filtering, Shape Simplification,
Total Page:16
File Type:pdf, Size:1020Kb
Morphology-form and structure Lecture 6, Morphological image processing I mathematical framework used for: GW 9 Ida-Maria • pre-processing Suggested problem: 9.7 a • noise filtering, shape simplification, ... Sketch the result of A first eroded by • enhancing object structure B4 and then dilated by B2 • skeletonization, convex hull... • segmentation L • quantitative description L/4 . L L • area, perimeter, ... B2 B4 A Some set theory Some more set theory A is a set in Z2. ∈ If a=(a 1,a 2) is an element in A: a A. AC ∉ C If a=(a 1,a 2) is not an element in A: a A complement of A: A ={w|w ∉A} empty set : ∅ difference of A and B: set specified using { }, e.g., C={w|w=-d, for d∈D} A-B={w|w ∈A,w ∉B}=A ∩BC A-B every element in A is also in B (subset): A ⊆B A∪B reflection of A: union of A and B: Â={w|w=-a, for a∈A} C=A ∪B={c|c ∈A or c∈B} intersection of A and B: translation of A by a point z=(z 1,z 2): C=A ∩B={c|c ∈A and c∈B} (A) ={c|c=a+c, for a∈A} ∩ z ∩ ∅ A B disjoint/mutually exclusive : A B= (A) Z Logical operations • pixelwise combination of images (AND, OR, NOT, XOR) structuring element (SE) A B • small set to probe the image under study • for each SE, define origo – SE in point p: origo coincides with p NOT A A AND B • shape and size must be adapted to geometric properties for the objects A OR B A XOR B basic idea how to describe SE many different ways! • in parallel for each pixel in binary image: information needed: • position of origo for SE – check if SE is ”satisfied” • positions of elements belonging to SE – output pixel is set to 0 or 1 depending on used operation line segment line segment line segment (origo is not in SE) (origo is not in SE) origo pixels in output pair of points image if check is: (separated by one pixel) SE fits Five binary morphological transforms Erosion (shrinking) does the structuring element fit the set? Erosion ε erosion of a set X by structuring element B, B(X): Dilation all x in X such that B is in X when origin of B=x ε ( ) = { ⊆ } Opening B X x | Bx X Closing Gonzalez-Woods: Θ = { ( ) ⊆ } Hit-or-Miss transform X B x | B x X shrink the object Example: erosion (fill in!) Dilation (growing) does the structuring element hit the set? δ dilation of a set X by structuring element B, B(X): all x in X such that the reflection of B hits X when origin of B=x SE= δ ( ) = { ˆ ∩ ≠ } B X x (| B)x X 0 Gonzalez-Woods: ⊕ = { ( ˆ) ∩ ≠ } X B x | B x X 0 grow the object Different SE give different results Example: dilation (fill in!) SE= duality erosion and dilation are dual with respect to complementation and reflection C C ( Θ ) = ⊕ ˆ A B A B AA B (A B) C B = Bˆ origo AC AC ¡ B useful erosion: • erosion SE=square of – removal of structures of certain shape and size, size 13x13 given by SE (structure element) Example 3x3 SE • dilation input: squares of size 1x1, – filling of holes of certain shape and size, given 3x3, 5x5, 7x7, 9x9, by SE Dilation of and 15x15 pixels erosion result: Example SE=square of 3x3 SE size 13x13 fig 9.7 Use dilation to bridge gaps of broken segments combining erosion and dilation W 137D: remove structures / fill holes without affecting remaining parts SOLUTION: combine erosion and dilation (using same SE) Opening Closing B= opening Example opening (fill in!) erosion followed by dilation, denoted A AA B = (AΘB)⊕ B B O • eliminates protrusions • breaks necks • smoothes contour A A B opening: roll ball(=SE) inside object closing see B as a ”rolling ball” dilation followed by erosion, denoted • boundary of A B = points in B that reaches closest to A boundary when B is rolled inside A A A• B = (A⊕ B)ΘB B fig 9.8 O • smooth contour • fuse narrow breaks and long thin gulfs • eliminate small holes • fill gaps in the contour -# Example closing (fill in!) Closing: roll ball(=SE) outside object boundary of A B = points in B that reaches closest to A boundary when B is rolled outside A Fill in true border after closing with ball as SE ¡ - ¡ hit-or-miss transformation ( ,HMT) hit-or-miss transformation ( ¢ ,HMT) ind location of one shape among a set of shapes ”template matching” find location of one shape among a set of shapes ⊗ = ( Θ )∩ [ C Θ( − )] A⊗ B = (AΘB )∩ (ACΘB ) A B A X A W X 1 2 ⊗ = ( Θ )∩ ( CΘ ) A B A B1 A B2 composite SE: object part (B 1) and background part (B 2) ⊗ = ( Θ )− ( ⊕ ˆ ) A B A B1 A B2 does B1 fits the object while, simultaneously, B2 misses the object, i.e., fits the background ? B=(B 1,B 2) B1=X B2=W-X X W W-X Example: Hit-or-Miss transform (fill in!) basic morphological algorithms Search for: B1 B2 use erosion, dilation, opening, closing, hit-or-miss O O for XXc • boundary extraction • region filling • extraction of connected components (labelling) • defining the convex hull boundary of A= β(A) boundary extraction by erosion and set difference region filling β ( ) = − ( Θ ) fill a region A given its boundary β(A) A A A B β x=X 0 is known and inside (A) = ( ⊕ )∩ C = X k X k−1 B A ,k 3,2,1 ,... continue until Xk=X k-1 ∪ filled region A Xk use to fill holes! 8-connected boundary 4-connected boundary CONDITIONAL DILATION β(A) =pixels with edge β(A) =pixels with edge or point neighbour in A C neighbour in A C compare with removing holes using two- pass labeling algorithm (segmentationlecture) connected component labelling: AAC • label the inverse image X X 0 1 • remove connected components touching the image border • output = holes + original image 2 scans + 1 scan (straightforward...) ... mathematical morphology: iterate: dilation, set intersection dependent on size & shape of the hole needed: initialization !! ∪ X2 X6 X7 X7 A convex hull to compute convex hull i = ( ⊗ i )∪ = = • convex region R X k X k−1 B A,i ,4,3,2,1 k 3,2,1 ,... i – for any x ,x ∈R, straight line between x and x = i 1 2 1 2 X 0 A converges to D (X k=X k-1) is in R 4 • convex hull H of a region R i CH ()A = 8 D – smallest convex set containing R i=1 • convex deficiency D=H-R Bi, i=1,2,3,4 rotate! don’t care 1 X 0=A (fill in!) B1 B2 B3 B4 Alternative approach • Count the number of neighbors of a pixel, if more than three, mark the pixel! Gives octagon instead of rectangle (by Gunilla Borgefors, CBA) 1 2 3 4 X 5 X 2 X 7 X 2 fig 9.19.