Toolbox ia870 | List of Figures | Fig. 3.6 | Fig. 3.8

Figure 3.7 - 4-connected boundaries

Description

For digital implementation the type of boundary depends on the selection of a digital structuring element to take the place of the disk in the Euclidean procedure. Figure 3.7 illustrates boundaries resulting from the 8-neighbors structuring element.

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 
 4 S = MT.iabinary([
 5        [0,0,0,0,0,0,0,0,0],
 6        [0,0,0,1,1,1,0,0,0],
 7        [0,0,0,1,1,1,0,0,0],
 8        [0,1,1,1,1,1,1,1,0],
 9        [0,1,1,1,1,1,1,1,0],
10        [0,1,1,1,1,1,1,1,0],
11        [0,0,0,1,1,1,1,1,0],
12        [0,0,0,1,1,1,1,1,0],
13        [0,0,0,0,0,1,0,0,0],
14        [0,0,0,0,0,0,0,0,0]])
15 
16 DS = MT.iathreshad(S,0)
17 
18 B0 = MT.iasecross(0)
19 B4 = MT.iasecross()
20 B8 = MT.iasebox()
21 
22 a = MT.iabshow(DS,S)
23 b = MT.iabshow(DS, MT.iadil(S,B8))
24 c = MT.iabshow(DS,MT.iaero(S,B8))
25 d = MT.iabshow(DS,MT.iagradm(S,B8,B0))
26 e = MT.iabshow(DS,MT.iagradm(S,B0,B8))
27 f = MT.iabshow(DS,MT.iagradm(S,B8,B8))
28 
29 adshow(MT.ianeg(a), '(a) input image')
30 adshow(MT.ianeg(b), '(b) dilation')
31 adshow(MT.ianeg(c), '(c) erosion')
32 adshow(MT.ianeg(d), '(d) 4-connected external boundary')
33 adshow(MT.ianeg(e), '(e) 4-connected internal boundary')
34 adshow(MT.ianeg(f), '(f) morphological gradient')

(a) input image

(b) dilation

(c) erosion

(d) 4-connected external boundary

(e) 4-connected internal boundary

(f) morphological gradient