Toolbox ia870 | List of Figures | Fig. 1.2 | Fig. 1.4

Figure 1.3 - Discrete image S, discrete structuring element E


The image S consists of five pixels, and it is represented within a matrix with origin at the center of the grid. The structuring element E represents a elementary diamond with the center pixel at coordinates.

The structuring element can be created by the function iasecross that creates a 3x3 diamond structuring element. The function iaseshow returns a matrix form of the structuring element useful for displaying in numeric format. iaseshow always returns an odd-size image, and by convention its center is the structuring element origin. To visualize small binary structuring elements, there is available the option ‘EXPAND’ in iaseshow. The following script generates the graphics of Fig. 1.3(b). Note that the origin is marked by a shaded square.

n most of this chapter there will be no distinction between images and structuring elements, so could be seen as a structuring element and as an image. Later on, we will see that for practical use, there will be a distinction between images and structuring elements.

There are several ways to build the image S using the Morphology Tool (MT). The one illustrated below creates by initializing directly a binary matrix. It is visualization, created by iaseshow, is shown in Fig. 1.3(a). Note that the redundant zeros around the imagem were eliminated, resulting in a 3 x 3 image that is equivalent to image S of Eqs. (1.1) and (1.2).

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 4 S = MT.iabinary([
 5     [0,0,0,0,0],
 6     [0,0,1,0,0],
 7     [0,0,1,1,0],
 8     [0,0,1,1,0],
 9     [0,0,0,0,0]])
11 adshow(MT.ianeg(MT.iaseshow(S,'EXPAND')),'(a) Discrete image S ')
13 E = MT.iabinary([
14     [0,1,0],
15     [1,1,1],
16     [0,1,0]])
18 adshow(MT.ianeg(MT.iaseshow(E,'EXPAND')),'(b) Discrete structuring element E')

(a) Discrete image S

(b) Discrete structuring element E