
286 A Computational Introduction to Digital Image Processing, Second Edition
by dilating twice:
((A B) ⊕ B) ⊕ B.
The first dilation returns the holes to their original size; the second dilation removes them.
But this will enlarge the objects in the image. To reduce them to their correct size, perform
a final erosion:
(((A B) ⊕ B) ⊕ B) B.
The inner two operations constitute an opening; the outer two operations a closing. Thus,
this noise removal method is in fact an opening followed by a closing:
(A ◦B) •B).
This is called morphological filtering.
Suppose we take an image and apply 10% shot noise to it. This can be done in MATLAB
or Octave by:
MATLAB/Octav ...