Skip to contents

getStructuringElement is a convenience function to create structuring elements with defined shapes that can be used to filter images with filter2D.

Usage

getStructuringElement(
  k_shape = "rectangle",
  k_height = 5,
  k_width = 5,
  anchor = c(-1, -1)
)

Arguments

k_shape

A string corresponding to the shape of the structuring element. Valid kernel shapes are:

  • "rectangle" (the default)

  • "cross"

  • "ellipse"

k_height

The half-height in pixels of the structuring element.

k_width

The half-width in pixels of the structuring element.

anchor

A 2-element numeric vector defining the anchor position within the cross-shaped structuring element. The default value (−1,−1) means that the anchor is at the center. Note that only the shape of a cross-shaped kernel depends on the anchor position.

Value

A matrix of 0s and 1s.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

getStructuringElement()
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#>  [1,]    1    1    1    1    1    1    1    1    1     1     1
#>  [2,]    1    1    1    1    1    1    1    1    1     1     1
#>  [3,]    1    1    1    1    1    1    1    1    1     1     1
#>  [4,]    1    1    1    1    1    1    1    1    1     1     1
#>  [5,]    1    1    1    1    1    1    1    1    1     1     1
#>  [6,]    1    1    1    1    1    1    1    1    1     1     1
#>  [7,]    1    1    1    1    1    1    1    1    1     1     1
#>  [8,]    1    1    1    1    1    1    1    1    1     1     1
#>  [9,]    1    1    1    1    1    1    1    1    1     1     1
#> [10,]    1    1    1    1    1    1    1    1    1     1     1
#> [11,]    1    1    1    1    1    1    1    1    1     1     1