The Mathematica Journal
Departments
Feature Articles
Columns
New Products
New Publications
Classifieds
Calendar
News Bulletins
Mailbox
Letters
Write Us
About the Journal
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues
Home
Download this Issue

4. Binary and Grayscale Morphological Operators

Mathematical morphology provides an approach to the processing of digital images that is based on the spatial structure of objects in a scene [2, 4, 5, 6, 7]. Unlike the linear operators discussed so far, morphological operators modify the shape of pixel groupings instead of their amplitude. The fundamental operators of binary morphology are erosion and dilation. These operators are typically defined using set-theoretic concepts, but here we restrict our discussion to their matrix formulations. In analogy with the linear operators discussed in the previous section, binary morphological operators may be implemented using convolution-like algorithms, with the fundamental operations of addition and multiplication replaced by logical OR and AND.

To simplify the notation and without loss of generality we assume all arrays have square dimensions. With [Graphics:../Images/index_gr_146.gif] as an [Graphics:../Images/index_gr_147.gif] binary-valued image, [Graphics:../Images/index_gr_148.gif] as the typically small structuring element of dimensions [Graphics:../Images/index_gr_149.gif], and [Graphics:../Images/index_gr_150.gif] as the dilation result, the matrix formulation is as follows:

[Graphics:../Images/index_gr_151.gif]

with [Graphics:../Images/index_gr_152.gif], and where [Graphics:../Images/index_gr_153.gif] and [Graphics:../Images/index_gr_154.gif] are the logical OR (union) and logical AND (intersection) operators, respectively. For the special case of a [Graphics:../Images/index_gr_155.gif] structuring element ([Graphics:../Images/index_gr_156.gif]) we can write Equation (4.1) explicitly as

[Graphics:../Images/index_gr_157.gif]

Equations (4.1) and (4.2) resemble the familiar convolution sum formulation with OR replacing addition and AND replacing multiplication. Thus the structuring element plays an analogous role in morphological signal processing to the FIR filter in LSI signal processing. This realization leads quickly to an implementation of erosion using ListConvolve.

Here we define an example array A.

[Graphics:../Images/index_gr_158.gif]

The matrix formulation in Equation (4.1) assumes an odd-sized structuring element with the origin centered in the array. Therefore, we define a [Graphics:../Images/index_gr_159.gif] array B with an L-shaped arrangement of 1s as follows.

[Graphics:../Images/index_gr_160.gif]

The binary dilation of image A by structuring element B, namely [Graphics:../Images/index_gr_161.gif], is given by the following.

[Graphics:../Images/index_gr_162.gif]
[Graphics:../Images/index_gr_163.gif]

Erosion is a morphological dual to dilation. The structuring element may again be viewed as a morphologic filter that is scanned across an image. As in the case of dilation, erosion may be defined by the following correlation-like formulation. The erosion of image [Graphics:../Images/index_gr_164.gif] with structuring element [Graphics:../Images/index_gr_165.gif], denoted [Graphics:../Images/index_gr_166.gif], has the following matrix formulation:

[Graphics:../Images/index_gr_167.gif]

with [Graphics:../Images/index_gr_168.gif]. Operators [Graphics:../Images/index_gr_169.gif] and [Graphics:../Images/index_gr_170.gif] are the logical OR (union) and logical AND (intersection) operators, respectively, and [Graphics:../Images/index_gr_171.gif] is the point-wise complement of structuring element [Graphics:../Images/index_gr_172.gif]. In effect, erosion results in a value of 1 at position [Graphics:../Images/index_gr_173.gif] in [Graphics:../Images/index_gr_174.gif] if the spatial arrangement of 1s in [Graphics:../Images/index_gr_175.gif] is a subset of the arrangement of 1s in [Graphics:../Images/index_gr_176.gif]. In particular, for the special case of a [Graphics:../Images/index_gr_177.gif] structuring element ([Graphics:../Images/index_gr_178.gif]) of all 1s, we can write Equation (4.3) explicitly as

[Graphics:../Images/index_gr_179.gif]

Here is the binary erosion of array A by structuring element B, namely [Graphics:../Images/index_gr_180.gif].

[Graphics:../Images/index_gr_181.gif]
[Graphics:../Images/index_gr_182.gif]

Here we demonstrate the operations of binary erosion and dilation. First we threshold the example books image using a threshold value of [Graphics:../Images/index_gr_183.gif] to obtain a binary array.

[Graphics:../Images/index_gr_184.gif]

This shows the original and the binary images.

[Graphics:../Images/index_gr_185.gif]

[Graphics:../Images/index_gr_186.gif]

This defines a square structuring element.

[Graphics:../Images/index_gr_187.gif]

Here we show the results of dilation and erosion.

[Graphics:../Images/index_gr_188.gif]

[Graphics:../Images/index_gr_189.gif]

Note how dilation increases the white regions in the image, hence the use of the word dilation for this operator. The operation of erosion, on the other hand, decreases or shrinks the area occupied by white pixels.

Binary morphological concepts may be extended to grayscale images. The common approach is to use a grayscale extremum operation over a small neighborhood defined by the structuring element. A typically small structuring element is scanned over an image and, at each position, the maximum of point-by-point sums of the image and the structuring element is computed. This may again be implemented as a convolution-like operation. For notational convenience we assume arrays with square dimensions. Then, given a [Graphics:../Images/index_gr_190.gif] structuring element [Graphics:../Images/index_gr_191.gif] and an [Graphics:../Images/index_gr_192.gif] image array [Graphics:../Images/index_gr_193.gif], the dilation of [Graphics:../Images/index_gr_194.gif] by [Graphics:../Images/index_gr_195.gif] may be defined as

[Graphics:../Images/index_gr_196.gif].

for all [Graphics:../Images/index_gr_197.gif] such that [Graphics:../Images/index_gr_198.gif], with [Graphics:../Images/index_gr_199.gif]. For example, with [Graphics:../Images/index_gr_200.gif] and [Graphics:../Images/index_gr_201.gif] for all i, j, we get

[Graphics:../Images/index_gr_202.gif]

Dilation tends to grow the white regions of an image. If the structuring element has positive values, the resulting image tends to be brighter. Grayscale erosion is the dual of grayscale dilation; the structuring element values are subtracted from the image during the scanning process and a minimum of each set of values is returned. This may be implemented as a correlation-like operation where the extremum operator Min and subtraction replace multiplication and addition, respectively. Given a [Graphics:../Images/index_gr_203.gif] structuring element [Graphics:../Images/index_gr_204.gif] and an [Graphics:../Images/index_gr_205.gif] image array [Graphics:../Images/index_gr_206.gif], the dilation of [Graphics:../Images/index_gr_207.gif] by [Graphics:../Images/index_gr_208.gif] may be defined as

[Graphics:../Images/index_gr_209.gif]

for all [Graphics:../Images/index_gr_210.gif] such that [Graphics:../Images/index_gr_211.gif], with [Graphics:../Images/index_gr_212.gif]. Erosion tends to shrink the white regions of an image. If the structuring element has positive values, the resulting image tends to be darker.

Here we show an example of a morphological gradient operator. The morphological boundary [Graphics:../Images/index_gr_213.gif] of image [Graphics:../Images/index_gr_214.gif] (i.e., the edges) is defined as

[Graphics:../Images/index_gr_215.gif]

In Equation (4.8) symbols [Graphics:../Images/index_gr_216.gif] and [Graphics:../Images/index_gr_217.gif] are used to represent grayscale erosion and grayscale dilation, respectively.

This defines a uniform 3 × 3 structuring element.

[Graphics:../Images/index_gr_218.gif]

Here is the result of a morphological gradient operation on the example image using a uniform structuring element of 1s. We use ListConvolve and ListCorrelate to implement grayscale dilation and erosion, respectively.

[Graphics:../Images/index_gr_219.gif]

This shows the original image and its morphological gradient.

[Graphics:../Images/index_gr_220.gif]

[Graphics:../Images/index_gr_221.gif]


Converted by Mathematica     

[Article Index] [Prev Page][Next Page]