Toolbox ia870 | List of Figures | Fig. 2.17 | Fig. 3.7

Figure 3.6 - Morphological boundaries

Description

Dilation by a disk expands an image and erosion by a disk shrinks an image. Both can be used for finding boundaries for binary images. Three possibilities are shown in Fig. 3.6:

  • Fig (a) image ;
  • Fig. (b) disk ;
  • Fig. (c) gives an external boundary;
  • Fig. (d) an internal boundary; and
  • Fig. (e)

a boundary that straddles the actual Euclidean boundary and is known as the morphological gradient

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 from handson.lib import iabggmodel, draw_se_axis
 4 
 5 y,x = np.indices((70,70))
 6 F = MT.iabinary((x) < (y))
 7 F = MT.iaunion(F,np.fliplr(F))
 8 F = np.flipud(MT.iaconcat('H',F,MT.ianeg(F)))
 9 F = MT.iapad(F,MT.iasebox(15))
10 
11 adshow(MT.ianeg(F), '(a) input image')
12 
13 B = MT.iasedisk(10)
14 
15 adshow(MT.ianeg(draw_se_axis(MT.iaseshow(B))),  '(b) structuring element')
16 
17 GX = MT.iasubm(MT.iadil(F,B),F)
18 GI = MT.iasubm(F,MT.iaero(F,B))
19 G = MT.iasubm(MT.iadil(F,B), MT.iaero(F,B))
20 
21 adshow(MT.ianeg(GX), '(c) external')
22 adshow(MT.ianeg(GI), '(d) internal')
23 adshow(MT.ianeg(G), '(e) morphological gradient')

(a) input image

(b) structuring element

(c) external

(d) internal

(e) morphological gradient