# erosion

##### Morphological Erosion by a Disc

Perform morphological erosion of a window, a line segment pattern or a point pattern by a disc.

##### Usage

```
erosion(w, r, …)
# S3 method for owin
erosion(w, r, shrink.frame=TRUE, …,
strict=FALSE, polygonal=NULL)
# S3 method for ppp
erosion(w, r,…)
# S3 method for psp
erosion(w, r,…)
```

##### Arguments

- w
A window (object of class

`"owin"`

or a line segment pattern (object of class`"psp"`

) or a point pattern (object of class`"ppp"`

).- r
positive number: the radius of erosion.

- shrink.frame
logical: if

`TRUE`

, erode the bounding rectangle as well.- …
extra arguments to

`as.mask`

controlling the pixel resolution, if pixel approximation is used.- strict
Logical flag determining the fate of boundary pixels, if pixel approximation is used. See details.

- polygonal
Logical flag indicating whether to compute a polygonal approximation to the erosion (

`polygonal=TRUE`

) or a pixel grid approximation (`polygonal=FALSE`

).

##### Details

The morphological erosion of a set \(W\) by a distance \(r > 0\) is the subset consisting of all points \(x \in W\) such that the distance from \(x\) to the boundary of \(W\) is greater than or equal to \(r\). In other words it is the result of trimming a margin of width \(r\) off the set \(W\).

If `polygonal=TRUE`

then a polygonal approximation
to the erosion is computed.
If `polygonal=FALSE`

then a pixel approximation
to the erosion is computed from the distance map of `w`

.
The arguments `"\dots"`

are passed to `as.mask`

to control the pixel resolution.
The erosion consists of all pixels whose distance
from the boundary of `w`

is strictly greater than `r`

(if
`strict=TRUE`

) or is greater than or equal to `r`

(if
`strict=FALSE`

).

When `w`

is a window, the default (when `polygonal=NULL`

)
is to compute a polygonal approximation if
`w`

is a rectangle or polygonal window, and to compute a
pixel approximation if `w`

is a window of type `"mask"`

.

If `shrink.frame`

is false, the resulting window is given the
same outer, bounding rectangle as the original window `w`

.
If `shrink.frame`

is true, the original bounding rectangle
is also eroded by the same distance `r`

.

To simply compute the area of the eroded window,
use `eroded.areas`

.

##### Value

If `r > 0`

, an object of class `"owin"`

representing the
eroded region (or `NULL`

if this region is empty).
If `r=0`

, the result is identical to `w`

.

##### See Also

`dilation`

for the opposite operation.

`erosionAny`

for morphological erosion using any shape.

##### Examples

```
# NOT RUN {
plot(letterR, main="erosion(letterR, 0.2)")
plot(erosion(letterR, 0.2), add=TRUE, col="red")
# }
```

*Documentation reproduced from package spatstat, version 1.49-0, License: GPL (>= 2)*