[hofig6s18] [Up] [hofig6s21] Chapter 6 - Morphological Processing of Gray-Scale Images

hofig6s20
Connected pyramid

Description

This figure illustrates the construction of a connected pyramid with flat-zone image simplification by connected ASF filters of increasing stages.

Demo Script

.

from morph import *
from Numeric import log
aux   = mmreadgray('lenina.tif');
a1    = log(aux+1)
a1max = max(a1.flat)
a1min = min(a1.flat)
a = uint8(255 * (a1-a1min)/(a1max-a1min))
a_lab = mmlabelflat(a,mmsebox());
nfz=mmstats(a_lab,'max')
print 'n. of flat zones = ',nfz
n. of flat zones =  35335.0
b=mmasfrec(a,'CO',mmsebox(),mmsebox(),2);
c=mmasfrec(a,'CO',mmsebox(),mmsebox(),4);
d=mmasfrec(a,'CO',mmsebox(),mmsebox(),16);
b_lab=mmlabelflat(b,mmsebox());
c_lab=mmlabelflat(c,mmsebox());
d_lab=mmlabelflat(d,mmsebox());
print mmstats(b_lab,'max')
21647.0
print mmstats(c_lab,'max')
18490.0
print mmstats(d_lab,'max')
9460.0
mmshow(a)
mmshow(b)
mmshow(c)
mmshow(d)
mmlblshow(a_lab);
mmlblshow(b_lab);
mmlblshow(c_lab);
mmlblshow(d_lab);
a b
c d
a_lab b_lab
c_lab d_lab

[hofig6s18] [Up] [hofig6s21] http://www.python.org