[hofig3s7] [Up] [hofig3s9] Chapter 3 - Morphological Processing of Binary Images

hofig3s8
8-connected boundaries

Description

This figure illustrates the extraction of 8-connected boundaries, using 4-connected structuring elements.

Demo Script

.

from morph import *
S=mmbinary([
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,1,1,1,0,0,0],
       [0,0,0,1,1,1,0,0,0],
       [0,1,1,1,1,1,1,1,0],
       [0,1,1,1,1,1,1,1,0],
       [0,1,1,1,1,1,1,1,0],
       [0,0,0,1,1,1,1,1,0],
       [0,0,0,1,1,1,1,1,0],
       [0,0,0,0,0,1,0,0,0],
       [0,0,0,0,0,0,0,0,0]])
DS=mmthreshad(S,0)
Warning: Converting input image from binary uint8 to uint8.
Warning: Converting input image from int32 to uint8.
B0=mmsecross(0)
B4=mmsecross()
B8=mmsebox()
a = mmbshow(DS,S)
b = mmbshow(DS,mmdil(S,B4))
c = mmbshow(DS,mmero(S,B4))
d = mmbshow(DS,mmgradm(S,B4,B0))
e = mmbshow(DS,mmgradm(S,B0,B4))
f = mmbshow(DS,mmgradm(S,B8,B4))
mmshow(a)
mmshow(b)
mmshow(c)
mmshow(d)
mmshow(e)
mmshow(f)
a b c d
e f

[hofig3s7] [Up] [hofig3s9] http://www.python.org