• No results found

5. MORPHOLOGICAL AND OTHER AREA OPERATIONS

5.2 Basic Morphological Operations

5.2.2 Binary Erosion

=

This gives a clue concerning a possible implementation for the dilation operator. Think of the structuring element as a template, and move it over the image. When the origin of the structuring element aligns with a black pixel in the image, all of the image pixels that correspond to black pixels in the structuring element are marked, and will later be changed to black. After the entire image has been swept by the structuring element, the dilation calculation is complete. Normally the dilation is not computed in place. A third image, initially all white, is used to store the dilation while it is being computed.

5.2.2 Binary Erosion

If dilation can be said to add pixels to an object, or to make it bigger, then erosion will make an image smaller. In the simplest case, a binary erosion will remove the outer layer of pixels from an object. For example, Figure 5.1b is the result of such a simple erosion process applied to Figure 5.1c. This can be implemented by marking all black pixels having at least one white neighbor, and then setting to white all of the marked pixels. The structuring element implicit in this implementation is the same 3 x 3 array of black pixels that defined the simple binary dilation.

Figure 5.4 Dilating an image using a structuring element. (a) The origin of the structuring element is placed over the first black pixel in the image, and the pixels in the structuring

element are copied into their corresponding positions in the result image. (b) Then the structuring element is placed over the next black pixel in the image and the process is

repeated. (c) This is done for every black pixel in the image.

In general, the erosion of image A by structuring element B can be defined as:

{

c( )B A

}

B

AΘ = c

In other words, it is the set of all pixels c such that the structuring element B translated by c corresponds to a set of black pixels in A. That the result of an erosion is a subset of the

Introduction to Image Processing and Computer Vision by LUONG CHI MAI http://www.netnam.vn/unescocourse/computervision/computer.htm

original image seems clear enough, any pixels that do not match the pattern defined by the black pixels in the structuring element will not belong to the result. However, the manner in which the erosion removes pixels is not clear (at least at first), so a few examples are in order, and the statement above that the eroded image is a subset of the original is not necessarily true if the structuring element does not contain the origin.

Simple example

Consider the structuring element B = {(0,0)(1,0)} and the object image A = {(3,3)(3,4)(4,3)(4,4)}

The set AΘ B is the set of translations of B that align B over a set of black pixels in A. This means that not all translations need to be considered, but only those that initially place the origin of B at one of the members of A. There are four such translations:

B(3,3) = {(3,3)(4,3)}

B(3,4) = {(3,4)(4,4)}

B(4,3) = {(4,3)(5,3)}

B(4,4) = {(4,4)(5,4)}

In two cases, B(3,3) and B(3,4), the resulting (translated) set consists of pixels that are all members of A, and so those pixels will appear in the erosion of A by B. This example is illustrated in Figure 5.5.

(a) (b)

Introduction to Image Processing and Computer Vision by LUONG CHI MAI http://www.netnam.vn/unescocourse/computervision/computer.htm

(c) (d)

Figure 5.5 Binary erosion using a simple structuring element.

(a) The structuring element is translated to the position of a black pixel in the image. In this case all members of the structuring element correspond to black image pixels so the result is a black pixel.

(b) Now the structuring element is translated to the next black pixel in the image, and there is one pixel that does not match. The result is a white pixel.

(c) At the next translation there is another match so, again the pixel in the output image that corresponds to the translated origin of the structuring element is set to black.

(d) The final translation is not a match, and the result is a white pixel. The remaining image pixels are white and could not match the origin of the structuring element; they need not be considered.

Now consider the structuring element B2= {(1,0)}; in this case the origin is not a member of B2. The erosion AΘ B can be computed as before, except that now the origin of the structuring element need not be correspond to a black pixel in the image. There are quite a few legal positions, but the only ones that result in a match are:

B(2,3) = {(3,3)}

B(2,4) = {(3,4)}

B(3,3) = {(4,3)}

B(3,4) = {(4,4)}

This means that the result of the erosion is {(2,3)(2,4)(3,3)(3,4)}, which is not a subset of the original.

Note

It is important to realize that erosion and dilation are not inverse operations. Although there are some situations where an erosion will undo the effect of a dilation exactly, this is not true in general. Indeed, as will be observed later, this fact can be used to perform useful operations

Introduction to Image Processing and Computer Vision by LUONG CHI MAI http://www.netnam.vn/unescocourse/computervision/computer.htm

on images. However, erosion and dilation are dual of each other in the following sense:

(AΘB)c=AcB^

This says that the complement of an erosion is the same as a dilation of the complement image by the reflected structuring element. If the structuring element is symmetrical then reflecting it does not change it, and the implication of the last equation is that the complement of an erosion of an image is the dilation of the background, in the case where simple is the structuring element.

The proof of the erosion-dilation duality is fairly simple, and may yield some insights into how morphological expressions are manipulated and validated. The definition of erosion is:

{

z( )B A

}

B

AΘ = z

so the complement of the erosion is:

(AΘB)c=

{

z( )BzA

}

c

If (B)z is a subset of A, then the intersection of (B) z with A is not empty:

(AΘB)c=

{

z(( )BzA)0

}

c

but the intersection with Ac will be empty:

(( ) )

{

z BzAc =0

}

c

=

and the set of pixels not having this property is the complement of the set that does:

(

( )

)

{

z BzAc 0

}

=

By the definition of translation, if (B)z, intersects Ac then

{

zb+zAc,bB

}

=

which is the same thing as

{

zb+z=a,aAc,bB

}

=

Now if a = b + z then z = a − b:

{

zb+z=a,aAc,bB

}

=

Finally, using the definition of reflection, if b is a member of B then A member of the reflection of B:

Introduction to Image Processing and Computer Vision by LUONG CHI MAI http://www.netnam.vn/unescocourse/computervision/computer.htm

{

zz=ab,aAc,bB

}

=

which is the definition of AcB^

The erosion operation also brings up an issue that was not a concern at dilation; the idea of a

"don't care" state in the structuring element. When using a strictly binary structuring element to perform an erosion, the member black pixels must correspond to black pixels in the image in order to set the pixel in the result, but the same is not true for a white (0) pixel in the structuring element. We don't care what the corresponding pixel in the image might be when the structuring element pixel is white.

5.2 Opening and Closing Operators