找回密码
 注册
查看: 450|回复: 0

R语言 SpatialVx包 kernel2dsmooth()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 12:56:56 | 显示全部楼层 |阅读模式
kernel2dsmooth(SpatialVx)
kernel2dsmooth()所属R语言包:SpatialVx

                                        Perform a onvolution smooth on a 2-d field.
                                         执行onvolution光滑的2-D领域。

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Perform a onvolution smooth on a 2-d field.  Default is to take an average over all neighbors within (n-1)/2 grid points from each grid point.  Uses FFT with the convolution theorem for computational efficiency.
执行onvolution光滑的2-D领域。默认是采取平均范围内的所有邻居,(N-1)/ 2个网格点,每个网格点。使用FFT计算效率的卷积定理。


用法----------Usage----------


kernel2dsmooth(x, kernel.type=NULL, K = NULL, W = NULL, X = NULL, xdim = NULL, Nxy = NULL, setup = FALSE, verbose = FALSE, ...)



参数----------Arguments----------

参数:x
matrix to be smoothed.
矩阵来进行平滑处理。


参数:kernel.type
(optional) character naming the kernel type accepted by kernel2dmeitsjer.  One and only one of this argument, K or W must be supplied.
(可选)字符命名的内核类型,接受kernel2dmeitsjer。有且只有一个这种说法,K或W必须提供。


参数:K
(optional) matrix defining a kernel to be applied.  this function will expand, and flip the kernel about its center, so ideally it will have odd dimensions.
(可选)矩阵限定以施加一个内核。此功能将扩大,翻转围绕其中心的内核,所以理想情况下,这将有奇数维。


参数:W
(optional) possibly complex matrix of scaled Fourier transformed kernel weights.  If NULL, these will be computed, but if passed, it will save one FFT in computation time.  This should not be given if setup is TRUE, or you will not get what you expect.  The dimensions are determined by this function, so it is probably best to supply this matrix only from a previous call with setup=TRUE.  The dimensions are chosen to optimize the FFT calculations (see Details section).
(可选)可能是复杂的矩阵规模傅立叶变换内核的权重。如果为NULL,这些都将被计算,但如获通过,这将节省一个FFT的计算时间。这不应该,如果设置为TRUE,否则你就不会得到你所期望。的尺寸是由这个函数,所以它可能是最好的只提供这个矩阵,从以前的检测设置= TRUE。的尺寸被选择以优化的FFT计算(详细部分)。


参数:X
(optional) matrix giving the Fourier transformed 'x'.  Can be used to save an FFT in computation, if this has already been calculated.
(可选)矩阵得到的傅里叶变换的“x”。可以用来保存一个FFT计算,如果这已经被计算。


参数:xdim
(optional) numeric vector of length 2 giving the dimensions of x.  Not really necessary, but as it will have already been calculated, seems silly to have to keep re-calculating it.  If NULL, it will be calculated here.
(可选)数字矢量的长度为2给尺寸的x。不是必需的,但因为它会已计算出,似乎是愚蠢的,必须重新计算。如果为NULL,它会在这里计算。


参数:Nxy
(optional) total number of grid points of x.  Similar to xdim argument, not really necessary, and will be calculated if not passed.
(可选)的总数量的网格点的x。类似xdim参数,而不是真的有必要,将计算,如果不通过。


参数:setup
logical, should just the Fourier transformed kernel weights, W, be returned for subsequent calls to this function?
逻辑,应该的傅里叶变换内核的权重,W,随后调用这个函数返回?


参数:verbose
logical, should progress information be printed to the screen?
逻辑的发展,应以信息打印到屏幕上?


参数:...
optional arguments to kernel2dmeitsjer as required by the specific kernel given to kernel.type
可选参数kernel2dmeitsjer所要求的特定的内核给kernel.type


Details

详细信息----------Details----------

This 2-d spatial kernel smoother applies a kernel smoother to a spatial field (see Hastie and Tibshirani, 1990 sec. 2.6; Ritter and Wilson, 2001, chapter 8; Barrett and Myers, 2004 for details about this type of convolution smoothing).  Specifically, if X is a matrix of grid points, then the returned field, denoted by Ebert (2008) as <X>s, is a smoothed field such that the value at each grid point '<X>s[i,j]' is given by: <X>s[i,j] = sum_k sum_l X[i + k - 1, j + l - 1]*K[i, j], where k,l = 1, ..., n, and K[i, j] is the kernel matrix.  In order to be fast, loops are avoided.  Instead, the convolution theorem is applied with a Fast Fourier Transform (FFT).  If the weights 'W' are supplied, then you will save one FFT in computation time.
这个二维空间的内核平滑适用的内核平滑的空间领域(Hastie和Tibshirani,1990秒。2.6; Ritter和威尔逊,2001年,第8章,巴雷特和迈尔斯,2004年这种类型的卷积平滑的详细信息)。具体而言,如果X是一个矩阵的网格点,然后返回的字段,表示由埃伯特(2008)作为<X> s,是一个平滑的字段的值,使得在每个网格点的<X> s〔i, J]由下式给出:<X> [I,J] = sum_k sum_l X [我+ K  -  1,J + L  -  1] * K [I,J,K,L = 1。 ..,n和用K [i,j]是内核矩阵。为了要快,环路是可以避免的。相反,施加的快速傅立叶变换(FFT)的卷积定理。如果提供的权重W,那么你将节省一个FFT计算时间。

The convolution theorem says that the Fourier transform of a convolution between two functions f and g is equal to the product of the Fourier transformed functions.  That is, if F denotes the Fourier transform, and * the convolution operator, F( f*g ) = k F(f)F(g), where 'k' is a scaling factor.  The neighborhood smooth is given by a convolution between the field and a boxcar kernel (i.e., a square around a point with constant value 1/n^2).  Because of the FFT, this enables a fast way to compute this convolution.
卷积定理说,两个函数之间的卷积的傅立叶变换的傅立叶变换函数的产品在f和g是等于。也就是说,如果F表示傅里叶变换,*卷积运算符,F(六*克)= K F(六)F(g)中,其中“k”是一个比例因子。附近光滑的卷积之间的领域和棚车内核(即一个点,一个广场周围恒定值的1 / n ^ 2)。由于FFT的,这使得一个快速的方法来计算这个卷积。

In order to zero-pad the field, and perform a cyclic convolution, it is necessary to expand the field, 'x', and re-arrange the kernel (or else it will not be centered on the points).  If zero padding is not desired, then a field that has been extrapolated to an appropriate size in another way should be used, and a subset going back to the original size could be used.  Alternatively, a subset of an appropriate size could be taken from the resulting smoothed field in order to avoid edge effects.  The latter is probably a wise move.  The image is expanded to the nearest power of two above the dimension of N=x + dimension of K - 1 in each direction, if N <= 1024, and N is rounded up to the nearest multiple of 512 otherwise.  This is to ensure that the FFT is fast.
在以零填充的字段,并执行循环卷积,这是必要的扩展字段的“x”,并重新安排的内核(否则它不会被中心上的点)。如果不希望零填充,然后以另一种方式已被外推到适当的大小的字段应该被使用,并且可用于返回到原来的大小的一个子集。可选地,一个适当大小的一个子集可以采取从所得的平滑的字段,以避免边缘效应。后者可能是一个明智的举动。的图像扩大到最近的电源的两个以上的维数N = +尺寸K  -  1在每个方向上,如果N <= 1024,和N的是向上舍入到最接近的倍数为512,否则。这是为了确保FFT是快速的。

In order to get the neighborhood type of smoothing of Roberts and Lean (2008) and Ebert (2008), use the boxcar kernel with the argument n giving the neighborhood length.  The resulting kernel is n X n with elements 1/n^2 at each point.  The result is that each grid point of the returned field is an average of the n^2 nearest neighbors.  Alternatively, one might prefer to use a disk kernel, which takes the radius, r, as an argument.  This gives a similar type of kernel, but ensures an average over a uniform distance from the center point.  The disk kernel is also that which is used in the smoothing step of Davis et al (2006a,2006b).  See the help file for kernel2dmeitsjer for other smoothing options.
为了让附近的平滑罗伯茨和精益生产(2008年)和艾伯特(2008),使用的棚车内核参数n给附近的长度。由此产生的内核是N×n的元素的1 / n ^ 2,在每一个点。其结果是,每个网格点的返回的字段是一个平均的n ^ 2近邻。另外,可能更倾向于使用磁盘的内核,它的半径,R,作为一个参数。这给出了一个类似的类型的内核,但能够确保在一个均匀的距离,从中心点平均。 Davis等人(2006年a,2006年b)的平滑化步骤中所用的盘的内核也是。 kernel2dmeitsjer其他的平滑选项,请参阅帮助文件。


值----------Value----------

If setup is FALSE, then a k X m matrix giving the neighborhood smoothed field is returned.  Otherwise, a 2k X 2m possibly complex matrix giving the Fourier transformed kernel weights are returned, which can be used to save an FFT in computation time for subsequent calls to this function by supplying the W argument with this result.
如果设置为FALSE,然后AK×m矩阵给邻里平滑字段的返回。否则,一个2k x 2米可能复杂的矩阵给出的傅里叶变换内核权值被返回,这可以用来保存一个FFT随后调用该函数,由供给与此结果的W参数在计算时间。


注意----------Note----------

If n is 1, then the field is returned without applying any smoothing.
如果n为1,则该字段返回而不施加任何平滑。


(作者)----------Author(s)----------


Eric Gilleland



参考文献----------References----------









参见----------See Also----------

fft, image.smooth, hoods2d, Fourier2d, kernel2dmeitsjer
fft,image.smooth,hoods2d,Fourier2d,kernel2dmeitsjer


实例----------Examples----------


look <- matrix( 0, 10, 12)
look[4,7] <- 1
kernel2dsmooth( look, kernel.type="boxcar", n=3)
# The above returns the shape of the kernel applied, which[上述返回应用的内核的形状,这]
# is a square of length 3 centered on the grid point in look[居中的长度为3的正方形的网格点上的外观]
# that has a value of 1.[具有1的值。]

# What happens if the 1 is on the edge?  the effect is zero padding:[如果是的边缘会发生什么呢?零填充效果:]
look <- look*0
look[1,1] <- 1
kernel2dsmooth( look, kernel.type="boxcar", n=3)

# Suppose we want to do the above for several, say l, neighborhood lengths.[假设我们想要做上述几个,说L,邻里长。]
# We can save an FFT for l-1 of the convolutions.[我们可以节省一个FFT为l-1的卷积。]
look <- look*0
look[4,7] <- 1
lookFFT <- Fourier2d( look, kdim=c(3,3))
dim( lookFFT) # Note the dimension is twice that of look.[注意维度是两倍,看看。]
kernel2dsmooth( look, kernel.type="boxcar", n=3, X=lookFFT)

# Now, suppose we want to apply the same kernel smooth to different fields.[现在,假设我们希望将相同的内核平滑不同的领域。]
# We can save an FFT for each subsequent calculation as follows.[我们可以节省以后的每一个FFT计算如下。]
wg <- kernel2dsmooth( look, kernel.type="boxcar", n=3, setup=TRUE)
dim( wg) # Note the dimension is twice that of look.[注意维度是两倍,看看。]
kernel2dsmooth( look, kernel.type="boxcar", n=3, W=wg)
look <- look*0
look[8,5] <- 1
kernel2dsmooth( look, kernel.type="boxcar", n=3, W=wg)
look[5, 10] <- 1
kernel2dsmooth( look, kernel.type="boxcar", n=3, W=wg)


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-11 06:33 , Processed in 0.079433 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表