from morph import *
a = mmreadgray('crystals.tif');
b = mmasf(a,'oc',mmsedisk(2,'2D','octagon'),10); # background estimation
c = uint8(mmstats(b,'min')* a/b);
d = mmcloseth( c,mmsedisk(4,'2D','octagon'));
e = mmhmin(mmareaclose(d,7),8);
f = mmwatershed(e);
g = mminfrec(mmframe(f),mmneg(f));
h = mmintersec(f,mmneg(mmclose(g)));
mmshow(a);
mmshow(b);
mmshow(c);
mmshow(d);
mmshow(e);
mmshow(f);
mmshow(g);
mmshow(h);
mmshow(a,h,h);