Description Usage Arguments Value Author(s) See Also Examples
Methods for calculating the spatial neighbors (pixels within a certain distance) or spatial weights for all pixels in a dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #### Methods for Cardinal >= 2.x classes ####
## S4 method for signature 'ImagingExperiment'
findNeighbors(x, r, groups = run(x), ...)
## S4 method for signature 'PositionDataFrame'
findNeighbors(x, r, groups = run(x), dist = "chebyshev",
offsets = FALSE, matrix = FALSE, ...)
## S4 method for signature 'ImagingExperiment'
spatialWeights(x, r, method = c("gaussian", "adaptive"),
dist = "chebyshev", matrix = FALSE, BPPARAM = getCardinalBPPARAM(), ...)
## S4 method for signature 'PositionDataFrame'
spatialWeights(x, r, matrix = FALSE, ...)
#### Methods for Cardinal 1.x classes ####
## S4 method for signature 'iSet'
findNeighbors(x, r, groups = x$sample, ...)
## S4 method for signature 'IAnnotatedDataFrame'
findNeighbors(x, r, groups = x$sample, dist = "chebyshev",
offsets = FALSE, matrix = FALSE, ...)
## S4 method for signature 'iSet'
spatialWeights(x, r, method = c("gaussian", "adaptive"),
matrix = FALSE, ...)
## S4 method for signature 'IAnnotatedDataFrame'
spatialWeights(x, r, matrix = FALSE, ...)
|
x |
An imaging dataset or data frame with spatial dimensions. |
r |
The spatial radius or distance. |
groups |
A |
dist |
The type of distance metric to use. The options are ‘radial’, ‘manhattan’, ‘minkowski’, and ‘chebyshev’ (the default). |
offsets |
Should the coordinate offsets from the center of each neighborhood be returned? |
matrix |
Should the result be returned as a sparse matrix instead of a list? |
method |
The method to use to calculate the spatial weights. The 'gaussian' method refers to Gaussian-distributed distance-based weights ( |
... |
Addtional arguments to be passed to next method. |
BPPARAM |
An optional instance of |
Either a list of neighbors/weights or a sparse matrix (sparse_mat
) giving the neighbors and weights for each pixel.
For spatialWeights
, two types of weights are calculated and returned as a list:
The alpha
weights are distance-based, following a Gaussian distributed that produces smaller weights for larger distances. The beta
weights are adaptive weights used for bilateral filtering, which are based on the difference in the feature-vectors between pixels.
If method="gaussian"
only the alpha
weights are calcualated and the beta
weights are all set to 1. If matrix=TRUE
, the alpha
and beta
weights are multiplied together to produce the weights for the matrix; otherwise, both are returned separately.
Kylie A. Bemis
1 2 3 4 5 6 7 8 9 10 11 12 13 | coord <- expand.grid(x=1:9, y=1:9)
values <- rnorm(nrow(coord))
pdata <- PositionDataFrame(coord=coord, values=values)
# find spatial neighbors
findNeighbors(pdata, r=1)
# calculate distance-based weights
spatialWeights(pdata, r=1)
# visualize weight matrix
W <- spatialWeights(pdata, r=1, matrix=TRUE)
image(as.matrix(W), col=bw.colors(100))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.