| owin2mask {spatstat.geom} | R Documentation |
Convert Window to Binary Mask under Constraints
Description
Converts a window (object of class "owin")
to a binary pixel mask, with options to require
that the inside, outside, and/or boundary of the window
should be completely covered.
Usage
owin2mask(W,
op = c("sample", "notsample",
"cover", "inside",
"uncover", "outside",
"boundary",
"majority", "minority"),
...)
Arguments
W |
A window (object of class |
op |
Character string (partially matched) specifying how |
... |
Optional arguments passed to |
Details
This function is similar to, but more flexible than, as.mask.
It converts the interior, exterior, or boundary of the window W
to a binary pixel mask.
-
If
op="sample"(the default), the mask consists of all pixels whose centres lie inside the windowW. This is the same as usingas.mask. -
If
op="notsample", the mask consists of all pixels whose centres lie outside the windowW. This is the same as usingas.maskfollowed bycomplement.owin. -
If
op="cover", the mask consists of all pixels which overlap the windowW, wholly or partially. -
If
op="inside", the mask consists of all pixels which lie entirely inside the windowW. -
If
op="uncover", the mask consists of all pixels which overlap the outside of the windowW, wholly or partially. -
If
op="outside", the mask consists of all pixels which lie entirely outside the windowW. -
If
op="boundary", the mask consists of all pixels which overlap the boundary of the windowW. -
If
op="majority", the mask consists of all pixels in which at least half of the pixel area is covered by the windowW. -
If
op="minority", the mask consists of all pixels in which less than half of the pixel area is covered by the windowW.
These operations are complementary pairs as follows:
"notsample" | is the complement of | "sample" |
"uncover" | is the complement of | "inside" |
"outside" | is the complement of | "cover" |
"minority" | is the complement of | "majority"
|
They also satisfy the following set relations:
"inside" | is a subset of | "cover" |
"outside" | is a subset of | "uncover" |
"boundary" | is a subset of | "cover" |
"boundary" | is a subset of | "uncover"
|
The results of "inside", "boundary" and "outside"
are disjoint and their union is the entire frame.
Theoretically "sample" should be a subset of "cover",
"notsample" should be a subset of "uncover",
"inside" should be a subset of "majority"
and "outside" should be a subset of "minority",
but these could be false due to numerical error in computational geometry.
Value
A mask (object of class "owin" of type "mask"
representing a binary pixel mask).
Author(s)
Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
See Also
Examples
W <- Window(chorley)
opa <- par(mfrow=c(2,5))
plot(as.mask(W, dimyx=10), col="grey", main="sample")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "ma", dimyx=10), col="grey", main="majority")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "i", dimyx=10), col="grey", main="inside")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "c", dimyx=10), col="grey", main="cover")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "b", dimyx=10), col="grey", main="boundary")
plot(W, add=TRUE, lwd=3, border="red")
plot(as.mask(complement.owin(W), dimyx=10), col="grey",
main="notsample")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "mi", dimyx=10), col="grey", main="minority")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "o", dimyx=10), col="grey", main="outside")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "u", dimyx=10), col="grey", main="uncover")
plot(W, add=TRUE, lwd=3, border="red")
plot(owin2mask(W, "b", dimyx=10), col="grey", main="boundary")
plot(W, add=TRUE, lwd=3, border="red")
par(opa)