Extract.im(spatstat)
Extract.im()所属R语言包:spatstat
Extract Subset of Image
提取的子集图片
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Extract a subset or subregion of a pixel image.
提取或分区域的像素图像的一个子集。
用法----------Usage----------
## S3 method for class 'im'
x[i, drop=TRUE, ..., raster=NULL]
参数----------Arguments----------
参数:x
A two-dimensional pixel image. An object of class "im".
一个二维的像素的图像。对象的类"im"。
参数:i
Object defining the subregion or subset to be extracted. Either a spatial window (an object of class "owin"), or a pixel image with logical values, or a point pattern (an object of class "ppp"), or something that can be converted to a point pattern by as.ppp, or any type of index that applies to a matrix.
对象定义的分区域或要提取的子集。无论是空间窗口(对象类"owin"),或一个像素的图像与逻辑值或阵列点(对象类"ppp"),或东西,可以转换为一个点模式由as.ppp,或任何类型的适用于一个矩阵的索引,。
参数:...
Ignored.
忽略。
参数:drop
Logical value. Locations in w that lie outside the spatial domain of the image x return a pixel value of NA if drop=FALSE, and are omitted if drop=TRUE.
逻辑值。地点w的谎言外的空间域的图像x返回像素值NA,如果drop=FALSE,并省略drop=TRUE。
参数:raster
Optional. An object of class "owin" or "im" determining a pixel grid.
可选。类的一个对象"owin"或"im"确定一个像素网格。
Details
详细信息----------Details----------
This function extracts a subset of the pixel values in a pixel image. (To reassign the pixel values, see [<-.im).
此函数提取的像素的图像中的像素值的一个子集。 (要重新分配的像素值,[<-.im“)。
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).
图像x必须是类的一个对象"im"代表定义在二维空间中的矩形内的像素的图像(参见im.object)。
The subset to be extracted 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 extracted (after first clipping the window to the spatial domain of the image if necessary). If i is a pixel image with logical values, it is interpreted as a spatial window (with TRUE values inside the window and FALSE outside). If i is a point pattern (an object of class "ppp"), then the values of the pixel image at the points of this pattern are extracted.
要提取的子集被确定的参数i。如果i是一个空间窗口(类的一个对象"owin"),在此窗口内的图像中提取第一裁剪后的图像,如果必要的空间域的窗口。如果i是一个像素的图像与逻辑值,它被解释空间窗口(TRUE窗口内的值和FALSE外)。如果i是类的一个对象"ppp"),然后在此模式的各点的值的像素的图像中提取的点图案(。
At locations outside the spatial domain of the image, the pixel value is undefined, and is taken to be NA. The logical argument drop determines whether such NA values will be returned or omitted. It also influences the format of the return value.
在图像的空间域以外的地方,像素值是不确定的,采取NA。的逻辑论证drop决定是否NA值将被退回或省略。它也影响返回值的格式。
If i is a point pattern (or something that can be converted to a point pattern by as.ppp such as a list of x,y coordinates), then X[i, drop=FALSE] is a numeric vector containing the pixel values at each of the points of the pattern. Its length is equal to the number of points in the pattern i. It may contain NAs corresponding to points which lie outside the spatial domain of the image x. By contrast, X[i] or X[i, drop=TRUE] contains only those pixel values which are not NA. It may be shorter.
如果i是一个点模式(或可以转换为一个点模式as.ppp如列表x,y坐标),然后X[i, drop=FALSE]是一个数值向量包含的像素值在每个点的图案。它的长度是相等的点的数量在图案i。它可能包含NA相应的点之外的空间域的图像x。相比之下,X[i]或X[i, drop=TRUE]只包含的像素值不NA。它可能会缩短。
If i is a spatial window then X[i, drop=FALSE] is another pixel image of the same dimensions as x obtained by setting all pixels outside the window i to have value NA. When the result is displayed by plot.im the effect is that the pixel image x is clipped to the window i.
如果i是一个空间窗口,然后X[i, drop=FALSE]是另一个像素的图像,相同的尺寸,x获得设置窗口外的所有像素i值NA 。当结果显示plot.im的效果是像素的图像x夹窗口i。
If i is a spatial window which is not a rectangle (i$type != "rectangle") then X[i, drop=TRUE] is a numeric vector containing the pixel values for all pixels that lie inside the window i.
如果i是一个空间的窗口,它不是一个矩形(i$type != "rectangle")然后X[i, drop=TRUE]含有位于内部的窗口i的所有像素的像素值是一个数值向量。
If i is a rectangle (a spatial window with i$type = "rectangle") then X[i, drop=TRUE] is a pixel image. The spatial domain of this image is the intersection of i with the spatial domain of x.
如果i是矩形(空间窗口,i$type = "rectangle")X[i, drop=TRUE]是一个像素的图像。这个图像的空间域的交集i的空间域x。
If the optional argument raster is given, then it should be a binary image mask or a pixel image. Then x will first be converted to an image defined on the pixel grid implied by raster, before the subset operation is carried out. In particular, x[i, raster=i, drop=FALSE] will return an image defined on the same pixel array as the object i.
如果可选参数raster是给定的,那么它应该是一个二进制图像屏蔽或像素图像。然后x将首先被转换成的图像的像素网格上定义隐含的raster,之前的子集进行操作。特别是,x[i, raster=i, drop=FALSE]将返回上定义相同的像素阵列中的图像作为对象i。
If i does not satisfy any of the conditions above, then it is assumed to be a valid index for the matrix as.matrix(x). The result is a vector or matrix of pixel values.
如果i不满足上述的任何条件,那么就假设它是一个有效的指数为矩阵as.matrix(x)。其结果是一个向量或矩阵的象素值。
值----------Value----------
Either a pixel image or a vector of pixel values. See Details.
的像素的图像或像素值的矢量。查看详细信息。
警告----------Warning----------
If W is a window or a pixel image, then x[W, drop=FALSE] will return an image defined on the same pixel array as the original image x. If you want to obtain an image whose pixel dimensions agree with those of W, use the raster argument, x[W, raster=W, drop=FALSE].
如果W是一个窗口或一个像素的图像,然后x[W, drop=FALSE]将返回一个图像作为原始图像x上定义相同的像素阵列。如果你想获得的图像,其像素尺寸同意W,使用raster参数,x[W, raster=W, drop=FALSE]。
(作者)----------Author(s)----------
Adrian Baddeley
<a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
and Rolf Turner
<a href="mailto:r.turner@auckland.ac.nz">r.turner@auckland.ac.nz</a>
参见----------See Also----------
im.object, [<-.im, ppp.object, as.ppp, owin.object, plot.im
im.object,[<-.im,ppp.object,as.ppp,owin.object,plot.im
实例----------Examples----------
# make up an image[图像]
X <- setcov(unit.square())
plot(X)
# a rectangular subset[矩形子集]
W <- owin(c(0,0.5),c(0.2,0.8))
Y <- X[W]
plot(Y)
# a polygonal subset[多边形的子集]
data(letterR)
R <- affine(letterR, diag(c(1,1)/2), c(-2,-0.7))
Y <- X[R, drop=FALSE]
plot(Y)
# a point pattern[点模式]
P <- rpoispp(20)
Y <- X[P]
# look up a specified location[查找一个指定的位置]
X[list(x=0.1,y=0.2)]
# 10 x 10 pixel array[10×10的像素阵列]
X <- as.im(function(x,y) { x + y }, owin(c(-1,1),c(-1,1)), dimyx=10)
# 100 x 100 [100×100]
W <- as.mask(disc(1, c(0,0)), dimyx=100)
# 10 x 10 raster[10×10的栅格]
X[W,drop=FALSE]
# 100 x 100 raster[100×100光栅]
X[W, raster=W, drop=FALSE]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|