Learn R Programming

adehabitat (version 1.1-1)

morphology: Morphology: Erosion or Dilatation of Features on a Raster Map

Description

morphology performs morphological operations on images of class asc.

Usage

morphology(x, operation = c("erode", "dilate"), nt = 5)

Arguments

x
a matrix of class asc
operation
a character string indicating the operation to be processed: either "erode" or "dilate"
nt
the number of times that the operation should be processed

Value

  • Returns a matrix of class asc, containing 1 when the pixel belong to one feature of the image and NA otherwise (see examples).

See Also

as.asc for further information on objects of class asc

Examples

Run this code
data(puechabon)
a <- getkasc(puechabon$kasc,"Elevation")

## dilatation
toto1 <- morphology(a, operation = "dilate", nt = 1)
toto2 <- morphology(a, operation = "dilate", nt = 2)
toto3 <- morphology(a, operation = "dilate", nt = 3)
toto5 <- morphology(a, operation = "dilate", nt = 5)
image(toto5, col = "red")
image(toto3, add = TRUE, col = "orange")
image(toto2, add = TRUE, col = "yellow")
image(toto1, add = TRUE, col = "green")
image(a, add = TRUE)

## erosion
image(a, col = 1)
for (i in 1:19) {
  toto <- morphology(a, operation = "erode", nt = i)
  image(toto, add = TRUE, col = palette()[(i+1)%%8])
}

Run the code above in your browser using DataLab