View source: R/nhapply_master.R
Apply functions on neighbourhood of pixels
1 2 3 |
mat |
is an input matrix to apply a function on |
FUN |
is a function, that is applied on the neighbourhood of each point of a matrix. Optimised functions are: "mean", "sum", "max", "min", "maxCount", "maxCountValue" (which value occurs most often). It is possible to add a customised function like function(x) ... which must return a single value. |
restriction |
restricts the input matrix according to some condition as string. For example nhapply(mat, sum, restriction = "mat > 9"). |
weights |
is a vector of weights that is used when summing up a neighbourhood. Vector length must be the same as points in neighbourhood. |
density |
if True, weights vector is scale to 0 - 1 |
neighb_type |
specifies the type of surrounding: Type 1 is square-shaped ("Moore-Neighbourhood") Type 2 is cross-shaped ("Von-Neumann-Neighbourhood") Type 3 is diamond-shape |
width |
specifies how many neighbour pixels horizontally and vertically from center pixel should be included |
include.own |
tells, if the value of the center pixel should be included |
custom_neighb |
can be a matrix with 2 columns describing the x- and y-coordinates of the pixels to use or it can be a square matrix with odd number of rows and columns describing the neighbourhood and weights of each neighbour-pixel (0 means not using!) |
FUN_advanced |
can be used for more custom use-cases. The advanced function is applied on an open matrix where each column represents a point in a matrix and the rows its neighbourhood. Output should be a vector of same length as the number of pixels in the input matrix. |
transition |
if FALSE, matrix end at the sides, if TRUE, neighbourhood includes pixel from other side. |
force |
if your custom function outputs a different number of values than the number of points of the input matrix, force will force the program to apply the function. Do not use it, seriously, don't! |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.