This figure illustrates the use of closing for restoration of pepper noise.
.
from morph import *
from handson import *
from Numeric import shape
f=mmreadgray('text1.tif')
n=mmbggmodel(shape(f),mmsecross(),1,0.003)
n=mmdil(n,mmsecross())
f_cor=mmintersec(f,mmneg(n))
B=mmbinary([[1, 1], [1, 1]])
g=mmclose(f_cor,B)
mmshow(f)
mmshow(f_cor)
mmshow(g)