## Example 1 - dilation of a signal
data(reference)
dref <- dilation(reference, 150)
plot(reference, log = "y", type = "l")
lines(dref, col = 2)
## Example 2 - dilation of an image
BIN <- (volcano > 177)
dBIN <- t(apply(BIN, 1, dilation, span = 5))
dBIN <- apply(dBIN, 2, dilation, span = 5)
oldpar <- par(no.readonly = TRUE)
par(mfrow=c(2, 2))
image(volcano)
image(BIN)
image(dBIN)
par(oldpar)
Run the code above in your browser using DataLab