[hofig2s9] [Up] [hofig2s11] Chapter 2 - Binary Opening and Closing

hofig2s10
Filtering salt-and-pepper noise

Description

This figure illustrates the use of opening and closing for restoration of salt-and-pepper noise.

Demo Script

.

from morph import *
from handson import *
from Numeric import shape
f=mmreadgray('text1.tif')
n_salt=mmbggmodel(shape(f),mmsecross(),1,0.1)
n_pepper=mmbggmodel(shape(f),mmsecross(),1,0.1)
fbin=mmintersec(mmunion(f,n_salt),mmneg(n_pepper))
B=mmbinary([[1, 1],
            [1, 1]])
g=mmasf(fbin,'oc',B,1)
mmshow(fbin)
mmshow(g)
fbin g

[hofig2s9] [Up] [hofig2s11] http://www.python.org