Toolbox ia870 | List of Figures | Fig. 7.19 | Fig. 7.23

Figure 7.20 - Watershed lines on a plateau

Description

We end this section by illustrating the behavior of the watershed algorithm using the hierarchical FIFO queue. Figure 7.20 shows the watershed lines on a constant image with the markers being random points, like the one used in the illustration of the SKIZ (Fig. 7.9). Parts (a) and (b) of Fig. 7.20 show the watershed lines using the algorithm implemented with a hierarchical FIFO ordered queue with 4- and 8-adjacency, respectively. These are equivalent to the city-block and chessboard SKIZ, respectively. Part (c) shows the Euclidean SKIZ for comparison.

Demo Script

 1 import ia870 as MT
 2 import numpy as np
 3 
 4 a = (np.random.rand(256,256) > 0.999)
 5 an = MT.ianeg(a)
 6 
 7 ws_4 = MT.iacwatershed(an,MT.iaregmin(an));
 8 ws_8 = MT.iacwatershed(an,MT.iaregmin(an), MT.iasebox());
 9 
10 de = MT.iadist(an,MT.iasebox(),'EUCLIDEAN');
11 wse = MT.iacwatershed(de,MT.iaregmin(de));
12 
13 adshow(MT.iapad(MT.ianeg(MT.iaunion(ws_4,a))), '(a)')
14 adshow(MT.iapad(MT.ianeg(MT.iaunion(ws_8,a))), '(b)')
15 adshow(MT.iapad(MT.ianeg(MT.iaunion(wse,a))), '(c)')

(a)

(b)

(c)