spatstat (version 1.45-2)

MinkowskiSum: Minkowski Sum of Windows

Description

Compute the Minkowski sum of two spatial windows.

Usage

MinkowskiSum(A, B)

A %(+)% B

dilationAny(A, B)

Arguments

A,B
Windows (objects of class "owin").

Value

  • Another window (object of class "owin").

Details

The operator A %(+)% B and function MinkowskiSum(A,B) are synonymous: they both compute the Minkowski sum of the windows A and B. The function dilationAny computes the Minkowski dilation A %(+)% reflect(B). The Minkowski sum of two spatial regions $A$ and $B$ is another region, formed by taking all possible pairs of points, one in $A$ and one in $B$, and adding them as vectors. The Minkowski Sum $A \oplus B$ is the set of all points $a+b$ where $a$ is in $A$ and $b$ is in $B$. A few common facts about the Minkowski sum are:
  • The sum is symmetric:$A \oplus B = B \oplus A$.
  • If$B$is a single point, then$A \oplus B$is a shifted copy of$A$.
  • If$A$is a square of side length$a$, and$B$is a square of side length$b$, with sides that are parallel to the coordinate axes, then$A \oplus B$is a square of side length$a+b$.
  • If$A$and$B$are discs of radius$r$and$s$respectively, then$A \oplus B$is a disc of redius$r+s$.
  • If$B$is a disc of radius$r$centred at the origin, then$A \oplus B$is equivalent to themorphological dilationof$A$by distance$r$. Seedilation.

The Minkowski dilation is the closely-related region $A \oplus (-B)$ where $(-B)$ is the reflection of $B$ through the origin. The Minkowski dilation is the set of all vectors $z$ such that, if $B$ is shifted by $z$, the resulting set $B+z$ has nonempty intersection with $A$. The algorithm currently computes the result as a polygonal window using the polyclip library. It will be quite slow if applied to binary mask windows.

See Also

dilation, erosionAny

Examples

Run this code
B <- square(0.2)
  RplusB <- letterR %(+)% B

  opa <- par(mfrow=c(1,2))
  FR <- grow.rectangle(Frame(letterR), 0.3)
  plot(FR, main="")
  plot(letterR, add=TRUE, lwd=2, hatch=TRUE, hatchargs=list(texture=5))
  plot(shift(B, vec=c(3.675, 3)),
       add=TRUE, border="red", lwd=2)
  plot(FR, main="")
  plot(letterR, add=TRUE, lwd=2, hatch=TRUE, hatchargs=list(texture=5))
  plot(RplusB, add=TRUE, border="blue", lwd=2,
         hatch=TRUE, hatchargs=list(col="blue"))
  par(opa)

Run the code above in your browser using DataCamp Workspace