Morphological Operations

Morphological Operations

Morphological Operations 1 Outline • Basic concepts: • Erode and dilate • Open and close. • GltGranulometry • Hit and miss transform • Thinning and thickening • Skeletonization and the medial axis transform • Introduction to gray level morphology. 2 Pixel connectivity • We need to define which pixels areWarning: neighbors. • Are the Pdarkilixe ls are sampl es, pix els in thisnot arraarray squares . connected? 4 Pixel connectivity • We need to define which pixels are neighbors. • Are the dark pixels in this array connected? 5 Pixel Neighborhoods 4-neighborhood 8-neighborhood 6 Pixel paths • A 4-connected path between pixels p1 and pn is a set of pixels {p1, p2, …, pn} such that pi is a 4-neighbor of pi+1, i=1,,,…,n-1. • In an 8-connectedhd path, pi is an 8-neihbighbor of pi+1. 7 Connected regions • A region is 4-connected if it contains a 4- connected path between any two of its pixels. •A regiiion is 8-connectedifid if it contai ns an 8- connected path between any two of its pixels. 8 Connected regions • Now what can we say about the dark pixels in this array? • What about the light pixels? 9 Connected components labelling • Labels each connected component of a binary image with a separate number. 1 1 1 1 1 1 1 1 1 112213111 111221111 111111111 141155111 111155511 661111551 761188111 761188111 10 Foreground labelling • Only extract the connected components of the foreground 1 1 1 1 1 1 1 1 1 110010111 111001111 111111111 101100111 111100011 001111001 201100111 201100111 11 What Are Morphological Operators? • Local pixel transformations for processing region shapes • Most often used on binary images • Logical transformations based on comparison of pixel neighbourhoods with a pattern. 18 Simple Operations - Examples • Eight-neighbour erode – a.k.a. Minkowski subtraction • Erase any foreground pixel that has one eight-connected neighbour that is background. 19 8-neighbour erode Threshold Erode ×1 Erode ×2 Erode ×5 20 8-neighbour dilate • Eight-neighbour dilate • a.k.a. Minkowski addition • Paint any background pixel that has one eight-connected neighbour that is foreground. 21 8-neighbour dilate Dilate ×1 Dilate ×2 Dilate ×5 22 Why? • Smooth region boundaries for shape analysis. • Remove noise and artefacts from an imperfect segmentation. • Match particular pixel configurations in an image for simple object recognition. 23 Structuring Elements • Morphological operations take two arguments: • A binaryyg image •A structuring element. • Compare the structuring element to the neighbourhood of each pixel. • This determines the output of the morppghological op eration. 24 Structuring elements • The structuring element is also a binary array. • A structuring element has an origin . 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 0 25 Binary images as sets • We can think of the binary image and the structuring element as sets containing the pixels with value 1. 1 1 1 0 0 0 1 1 0 0 I = {(1,1), (2,1), (3,1), 0 0 0 0 0 (2,2), (3,2), (4,4)} 0 0 0 1 0 0 0 0 0 0 (Matlab) S = SPARSE(X) converts a sparse or full matrix to sparse form by squeezing out any zero elements26 Some sets notation • Union and • Difference iiintersection: I1 \ I2 = {x : x ∈ I1 and x ∉ I2} I1 ∪ I2 = {}x : x ∈ I1 or x ∈ I2 I1 ∩ I2 = {}x : x ∈ I1 and x ∈ I2 • We use φ for the • Complement empty set . I C = {}x : x ∉ I 27 More sets notation •The symmetrical set of S with respect to point o is 0 1 1 1 0 ( 1 1 1 1 1 S = {o − x : x ∈ S} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 0 28 Fitting, Hitting and Missing • S fits I at x if {y : y = x + s,s ∈ S} ⊂ I • S hits I at x if {y : y = x + s, s ∈ S} ∩ I ≠ φ • S misses I at x if {y : y = x + s, s ∈ S} ∩ I = φ 29 Fitting, Hitting and Missing Image Structuring element 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 30 Erosion • The image E = ISis the erosion of image I by structuring element S. ⎧1 if S fits I at x E(x) = ⎨ ⎩0 otherwise E = {y : y = x + s ∈ I for every s ∈ S} 31 Implementation (naïve) % I is the input image, S is a structuring element % with origin (ox, oy). E is the output image. function E = erode(I, S, ox, oy) [X,Y] = size(I); [SX, SY] = size(S); E = ones(X, Y); for x=1:X; for y=1:Y fi1fj1for i=1:SX; for j=1:SY if(S(i,j)) E(x,y ) = E(x,y ) & ImageEntry(I, x +i-ox, y+j-oy); end end; end end; end 32 Example 1 1 1 1 1 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 Example 0 1 1 1 0 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 34 Example 1 0 0 0 0 Structuring 0 1 0 0 0 element 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 35 Dilation • The image D = I ⊕ S is the dilation of image I by structuring element S. ⎧1 if S hits I at y D(x) = ⎨ ⎩0 otherwi se D = {y : y = x + s ∈ I for any s ∈ S} 36 Alternative Implementation • For another implementation of erosion and dilation, note that: E(x) = min(I(x + s)) s∈S D(x) = max(I(x + s)) s∈S 37 Example 1 1 1 1 1 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 38 Example 0 1 1 1 0 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 39 Example 1 0 0 0 0 Structuring 0 1 0 0 0 element 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 40 Erosion and dilation • Erosion and dilation are dual operations: (I S)C = I C ⊕ S( • Commutativity and associativity I ⊕ S = S ⊕ I (I ⊕ S) ⊕T = I ⊕ (S ⊕T ) I S ≠ S I (I S) T = I (S ⊕T ) 41 42 Input Output Structuring Element: 43 Opening and Closing •The opening of I by S is I o S = (I S) ⊕ S •The closing of I by S is I • S = (I ⊕ S) S 44 Opening and Closing • Opening and closing are dual transformations: C C ( (I • S) = I o S • Opening and closing are idempotent operations: I o S = (I o S) o S I • S = (I • S) • S 45 Example close 1 1 1 1 1 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 open 1 1 1 1 1 46 Example close 0 1 1 1 0 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 open 0 1 1 1 0 47 Example close 1 0 0 0 0 Structuring 0 1 0 0 0 element 0 0 1 0 0 0 0 0 1 0 open 0 0 0 0 1 48 Morphological filtering • To remove holes in the foreground and islands in the background, do both opening and closing . • The s ize and sh ape of th e structuri ng el ement determine which features survive. • In the absence of knowledge about the shape of filifeatures to remove, use a circular structuring element. 49 Example Close then open 1 1 1 1 1 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 Open then close 1 1 1 1 1 50 Example Close then open 0 1 1 1 0 Structuring 1 1 1 1 1 element 1 1 1 1 1 1 1 1 1 1 Open then close 0 1 1 1 0 51 Example Close then open 1 0 0 0 0 Structuring 0 1 0 0 0 element 0 0 1 0 0 0 0 0 1 0 Open then close 0 0 0 0 1 52 Count the Red Blood Cells 53 Granulometry • Provides a size distribution of distinct regions or “granules” in the image. • We open the image with increasing structuring element size and count the number of regions after each operation . • Creates a “morphological sieve”. 54 Granulometry function gSpec = granulo(I, T, maxRad) % Segment the image I B = (I>T); % Open the image at each structuring element size up to a %i% maximum and count the rema iiiining regions. for x=1:maxRad O = imopen (B,s tre l(‘dis k’,x )); numRegions(x) = max(max(connectedComponents(O))); end gSpec = diff(numRegions); 55 Count the Red Blood Cells 56 Threshold and Label 57 Disc(11) 58 Disc(19) 59 Disc(59) 60 Number of regions smaller than radius Number ofRe Struct.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    95 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us