[R-pkgs] New package for morphology and smoothing in any number of dimensions: mmand

Jon Clayden jon.clayden at gmail.com
Mon Apr 30 18:17:50 CEST 2012

Dear all,

I'm pleased to announce the release on CRAN of the "mmand" package
(for Mathematical Morphology in Any Number of Dimensions). It provides
functions for performing mathematical morphology (erode, dilate,
etc.), smoothing, and other kernel-based operations on array-like
objects of any dimensionality. The package is centred around a
flexible function called morph(), which can apply any kernel to array
elements, optionally conditioned on their value or number of nonzero

Operations such as erode and dilate are provided for 2D data by the
EBImage Bioconductor package, but mmand can be used for higher (and
lower!) dimensional data, can produce and apply anisotropic kernels,
and does not have external dependencies--except for the small, pure R
package "reportr" (also on CRAN), which is used for message reporting.

Owing to its more general, dimensionality-independent implementation,
mmand is a little slower than EBImage; but due to various performance
optimisations, run time is still very reasonable. For example:

> x <- EBImage::readImage(system.file("images", "shapes.png", package="EBImage"))
> k <- matrix(1,3,3)
> y1 <- EBImage::erode(x,k)
> y2 <- mmand::erode(x,k)
> identical(EBImage::imageData(y1),y2)
[1] TRUE
> system.time(for(i in 1:100) EBImage::closing(x,k))
  user  system elapsed
 1.791   0.047   1.837
> system.time(for(i in 1:100) mmand::closing(x,k))
  user  system elapsed
 3.267   0.018   3.287

A single closing (dilate followed by erode) operation therefore takes
around 1/30th of a second in this case.

I hope that this contribution will be useful.

All the best,

More information about the R-packages mailing list