Skip to contents

Dilation of the erosion with a flat structuring element; positions outside the image are ignored (+Inf for erosion, -Inf for dilation). Binary 0/1 images give the binary opening; the result is anti-extensive and idempotent.

Usage

MorphologicalOpening(image, structure = matrix(1, 3, 3), origin = NULL)

Arguments

image

Numeric matrix.

structure

0/1 matrix (default 3 x 3 square).

origin

c(row, col), 1-based (default the centre).

Value

list(opened, eroded).

References

Serra, J. (1982). Image Analysis and Mathematical Morphology. Academic Press. Soille, P. (2003). Morphological Image Analysis, 2nd ed. Springer.

Examples

img <- matrix(0, 5, 5)
img[2:3, 2:3] <- 1
img[4, 4] <- 1
MorphologicalOpening(img, matrix(1, 2, 2), c(1, 1))$opened
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    0    0    0    0
#> [2,]    0    1    1    0    0
#> [3,]    0    1    1    0    0
#> [4,]    0    0    0    0    0
#> [5,]    0    0    0    0    0