Toolbox ia870 | List of Figures | Fig. 7.6 | Fig. 7.9

Figure 7.8 - Watershed segmentation of a cedar cross section

Description

The Figure 7.8 illustrates the watershed segmentation of a cedar cross section.

Demo Script

 1 import ia870 as MT
 2 import numpy as np
 3 
 4 f = adreadgray('MVBook/cer_tr10.png')
 5 
 6 fneg = MT.ianeg(f)
 7 B8 =  MT.iasebox();
 8 
 9 ws =  MT.iacwatershed(fneg,MT.iaregmin(fneg,B8),B8)
10 ws_area = MT.iacwatershed(fneg,MT.iaregmin(MT.iaareaclose(fneg,100,B8),B8),B8)
11 ws_close = MT.iacwatershed(fneg,MT.iaregmin(MT.iaclose(fneg,MT.iasedisk()),B8),B8)
12 ws_h = MT.iacwatershed(fneg,MT.iaregmin(MT.iahmin(fneg,20,B8),B8),B8)
13 
14 adshow(MT.iapad(MT.ianeg(f)), '(a)')
15 adshow(MT.iapad(MT.ianeg(ws)), '(b)')
16 adshow(MT.iapad(MT.ianeg(ws_area)), '(c)')
17 adshow(MT.iapad(MT.ianeg(ws_close)), '(d)')
18 adshow(MT.iapad(MT.ianeg(ws_h)), '(e)')

(a)

(b)

(c)

(d)

(e)