Determining Structuring Element Shapes and Sizes

Determining the size and shape of a structuring element is largely an empirical process. However, the overall selection of a structuring element depends upon the geometric shapes you are attempting to extract from the image data. For example, if you are dealing with biological or medical images, which contain few straight lines or sharp angles, a circular structuring element is an appropriate choice. When extracting shapes from geographic aerial images of a city, a square or rectangular element will allow you to extract angular features from the image.

While most examples in this chapter use simple structuring elements, you may need to create several different elements or different rotations of a singular element in order to extract the desired shapes from your image. For example, if you wish to extract the rectangular roads from an aerial image, the initial rectangular element will need to be rotated a number of ways to account for multiple orientations of the roads within the image.

The size of the structuring element depends upon what features you wish to extract from the image. Larger structuring elements preserve larger features while smaller elements preserve the finer details of image features.

The following table shows how to easily create simple disk-shaped, square, rectangle, diagonal and custom structuring elements using IDL. The visual representations of the structures, shown in the right-hand column, indicate that the shape of each binary structuring element is defined by foreground pixels having a value of one.

Table 9-2: Creating Various Structuring Elements Shapes with IDL 

IDL Code For Structuring Element Shapes
Examples

Disk-Shaped Structuring Element

Use SHIFT in conjunction with DIST to create the disk shape.

radius = 3 
strucElem = SHIFT(DIST(2*radius+1), radius, $ 
     radius) LE radius 

Change radius to alter the size of the structuring element.

imgmorphstr1.gif

Square Structuring Element

Use DIST to define the square array.

side = 3 
strucElem = DIST(side) LE side 

Change side to alter the size of the structuring element.

imgmorphstr2.gif

Vertical Rectangular Structuring Element

Use BYTARR to define the initial array.

strucElem = BYTARR(3,3, /NOZERO) 
strucElem [0,*] = 1 

Create a 2 x 3 structure by adding strucElem[1,*] = 1.

imgmorphstr3.gif

Horizontal Rectangular Structuring Element

Use BYTARR to define the initial array.

strucElem = BYTARR(3,3, /NOZERO) 
strucElem [*,0] = 1 

Create a 3 x 2 structure by adding, strucElem[*,1] = 1.

imgmorphstr4.gif

Diagonal Structuring Element

Use IDENTITY to create the initial array.

strucElem = BYTE(IDENTITY(3)) 

Note - BYTE is used to create a byte array, consistent with the other structuring elements.

imgmorphstr5.gif

Irregular Structuring Elements

Define custom arrays to create irregular structuring elements or a series of rotations of a single structuring element.

strucElem = [[1,0,0,0,0,0,1], $ 
             [1,1,0,0,0,1,1], $ 
             [0,1,1,1,1,1,0], $ 
             [0,0,1,1,1,0,0], $ 
             [0,0,1,1,1,0,0], $ 
             [0,1,1,0,1,1,0], $ 
             [1,1,0,0,0,1,1], $ 
             [1,0,0,0,0,0,1]] 

Note - Creating a series of rotations of a single structuring element is covered in Thinning Image Objects.

imgmorphstr6.gif