Digital Image Processing Lecture 19 Segmentation Morphological Watersheds








![Flooding n n Initialization: C[min+1]=T[min+1] Obtain C[n] from C[n-1] (recursively): q q Let Q Flooding n n Initialization: C[min+1]=T[min+1] Obtain C[n] from C[n-1] (recursively): q q Let Q](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-9.jpg)
![Constructing C[n] n Scenario (a) [empty]: a new minimum is found q n Scenario Constructing C[n] n Scenario (a) [empty]: a new minimum is found q n Scenario](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-10.jpg)
![Dam Construction of height max+1 In C[n-1] q Scenario (c) 11 Dam Construction of height max+1 In C[n-1] q Scenario (c) 11](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-11.jpg)



![Step 1 (n=1): n n n T[1]=? C[1]=? Q[1]=? 15 Step 1 (n=1): n n n T[1]=? C[1]=? Q[1]=? 15](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-15.jpg)
![Step 2 (n=2): n n n T[2]=? Q[2]=? C[2]=? 16 Step 2 (n=2): n n n T[2]=? Q[2]=? C[2]=? 16](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-16.jpg)
![Step 3 (n=3, 4): n n T[3]=? Q[3]=? C[4]=? 17 Step 3 (n=3, 4): n n T[3]=? Q[3]=? C[4]=? 17](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-17.jpg)
![Step 5 (n=5): n n n T[5]=? Q[5]=? C[5]=? 18 Step 5 (n=5): n n n T[5]=? Q[5]=? C[5]=? 18](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-18.jpg)

- Slides: 19

Digital Image Processing Lecture 19: Segmentation: Morphological Watersheds Prof. Charlene Tsai 1

Introduction n Review: We have done q q q n Detection of discontinuities Thresholding Region processing Morphological watersheds embodies properties from other 3 approaches, therefore more superior. 2

Basic Concept n Visualize the image in 3 D topography (地勢) q n 3 types of points: q q q n 2 spatial coordinates + graylevel (a) Points in a regional minimum (b) Points on hills (c) Points on watershed lines Water level c b c a How to differentiate (b) & (c)? 3

Illustration n Objective: finding the watershed lines q Construction of dam to prevent catchment basins from merging Catchment basins Watershed lines Original image Topographic view 4

(con’d) n Punch a hole in each regional minimal for water to fill up the catchment basin. 5

(con’d) Water start merging, so shorter dam constructed Longer dam constructed Final result 6

Aside n Watershed algorithm is often applied to the gradient of an image, rather than to the image itself. q q Regional minima of catchment basins correlate nicely with the small value of the gradient corresponding the objects of interest Boundaries are highlighted as the watershed lines. 7

Watershed Segmentation Algorithm n Starting with the notation: q q g(x, y) is the image with min and max the lowest and highest graylevel, respectively M 1, M 2, … MR be the regional minima T[n]={ (s, t) | g(s, t)<n } Cn(Mi) is the set of (s, t) in the catchment basin of Mi that are flooded at stage n. q n C[n-1] is a subset of C[n] and C[n] is subset of T[n]. So it implies that q Each connected component (CC) of C[N-1] is contained in exactly one CC of T[n]. 8
![Flooding n n Initialization Cmin1Tmin1 Obtain Cn from Cn1 recursively q q Let Q Flooding n n Initialization: C[min+1]=T[min+1] Obtain C[n] from C[n-1] (recursively): q q Let Q](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-9.jpg)
Flooding n n Initialization: C[min+1]=T[min+1] Obtain C[n] from C[n-1] (recursively): q q Let Q be the set of CC in T[n], and 3 possibilities for : (a) empty (b) containing one CC of C[n-1] (c) containing more than one CC of C[n-1] 9
![Constructing Cn n Scenario a empty a new minimum is found q n Scenario Constructing C[n] n Scenario (a) [empty]: a new minimum is found q n Scenario](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-10.jpg)
Constructing C[n] n Scenario (a) [empty]: a new minimum is found q n Scenario (b) [containing 1 CC]: q lies in the catchment basin of some regional minimum q n q is incorporated into C[n-1] to form C[n] Scenario (c) [containing 1+ CC], part of the watershed line is encountered. q A dam must be build within q to prevent overflow between the catchment basins. 10
![Dam Construction of height max1 In Cn1 q Scenario c 11 Dam Construction of height max+1 In C[n-1] q Scenario (c) 11](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-11.jpg)
Dam Construction of height max+1 In C[n-1] q Scenario (c) 11

(con’d) n Dilate each CC of by the structuring element B, subject to 2 conditions: q q Dilation constrained to q (origin of B located in q) Dilation cannot cause merging of CC’s being dilated Change the height to max+1 B 12

Example Gradient image Segmente d image 13

Exercise n Give a step-by-step implementation of the dam building procedure for the onedimensional gray-level cross section shown. Show a drawing of the cross section at each step, showing “water” levels and dams constructed. g(x) 14 x
![Step 1 n1 n n n T1 C1 Q1 15 Step 1 (n=1): n n n T[1]=? C[1]=? Q[1]=? 15](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-15.jpg)
Step 1 (n=1): n n n T[1]=? C[1]=? Q[1]=? 15
![Step 2 n2 n n n T2 Q2 C2 16 Step 2 (n=2): n n n T[2]=? Q[2]=? C[2]=? 16](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-16.jpg)
Step 2 (n=2): n n n T[2]=? Q[2]=? C[2]=? 16
![Step 3 n3 4 n n T3 Q3 C4 17 Step 3 (n=3, 4): n n T[3]=? Q[3]=? C[4]=? 17](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-17.jpg)
Step 3 (n=3, 4): n n T[3]=? Q[3]=? C[4]=? 17
![Step 5 n5 n n n T5 Q5 C5 18 Step 5 (n=5): n n n T[5]=? Q[5]=? C[5]=? 18](https://slidetodoc.com/presentation_image_h/24c4d2c452f221a94aa19616bc092664/image-18.jpg)
Step 5 (n=5): n n n T[5]=? Q[5]=? C[5]=? 18

Dam Construction: 19