The two most basic morphological operators are dilation and
erosion. Dilation of the set A by set B,
denoted by
, is obtained by first reflecting B
about its origin and then translating the result by x. All x
such that A and reflected B translated by x that have
at least one point in common form the dilated set.
where,
denotes the reflection of
B i.e.,
and
denotes the translation
of B by
i.e.,
.
Thus, dilation of A by B expands the boundary of A.
It is easier to implement for gray-scales than the above description suggests.
Here, f and b denote images f(x,y) and b(x,y). f is
being dilated and
b is called the structuring element and
and
are the
domains of f and b respectively. Thus, in dilation we choose the
maximum value of f+b in a neighborhood defined by b. If all
elements of b are positive, the dilated image is brighter than the
original and the dark details are either reduced or eliminated.
Erosion of A by B, denoted by
,
is the set of all x such that B translated by x is
completely contained in A, i.e.,
For gray-scale images we have,
Erosion is thus based on choosing the minimum value of (f-b) in a neighborhood defined by the shape of b. If all elements of b are positive, the output image is darker than the original and the effect of bright details in the input image are reduced if they cover a region smaller than b.