subsetget.im {spatstat} | R Documentation |
Reset the values in a subset of a pixel image.
## S3 method for class 'im': x[i] <- value
x |
A two-dimensional pixel image.
An object of class "im" .
|
i |
Object defining the subregion or subset to be extracted.
Either a spatial window (an object of class "owin" )
or a point pattern (an object of class "ppp" )
or something that can be converted into a point pattern
by as.ppp .
|
value |
Vector of replacement values (short vectors will be recycled). |
This function changes some of the pixel values in a
pixel image. The image X
must be an object of class
"im"
representing a pixel image defined inside a
rectangle in two-dimensional space (see im.object
).
The subset to be changed is determined by the argument i
.
If i
is a spatial window (an object of class "owin"
),
the values of the image inside this window are changed.
If i
is a point pattern (an object of class
"ppp"
, or something that can be converted into a point pattern
by as.ppp
), then the values of the pixel image at the points of
this pattern are changed.
The image x
with the values replaced.
Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf
im.object
,
[.im
,
ppp.object
,
as.ppp
,
owin.object
# make up an image X <- setcov(unit.square()) plot(X) # a rectangular subset W <- owin(c(0,0.5),c(0.2,0.8)) X[W] <- 2 plot(X) # a polygonal subset data(letterR) R <- affine(letterR, diag(c(1,1)/2), c(-2,-0.7)) X[R] <- 3 plot(X) # a point pattern P <- rpoispp(20) X[P] <- 10 plot(X) # change pixel value at a specific location X[list(x=0.1,y=0.2)] <- 7