| focal_special | R Documentation | 
For each band and for each cell, function calculates value using specific matrix of square window. Focal operation of map algebra.
focal_special(x, type = c("custom", "gaussian", "laplacian", "osisaf",
                          "hires", "correl", "LoG", "sobel", "sobelG"),
             fmask = NULL, size = 3, alpha = 0.5, sigma = (size-1)/4,
             cover = 1 - 1e-06, fillNA = FALSE, saveMargin = FALSE, verbose = 0L)
| x | Object of class  | 
| type | Character, which is checked by  | 
| fmask | Numeric square matrix. Filter mask. If  | 
| size | Numeric. Diameter of circuled filter mask. Coerced to the nearest odd value not less than original value. | 
| alpha | Nimeric. Parameter  | 
| sigma | Numeric. Parameter  | 
| cover | Numeric.  | 
| fillNA | Logical. If  | 
| saveMargin | Logical. If  | 
| verbose | Integer of  | 
Developed under impression from Matlab's "fspecial".
type="custom"
Filter mask (argument fmask) should be specified manually.
type="gaussian"
Gaussian filter. For cascade filtering (sequence of increasing or decreasing window size) sigma=(size-1)/4 produces the same distribution density relative to window size. If sigma is high but not Inf then it is low-pass filter with diameter=size of circular focal window.
type="laplacian"
Laplacian filter. Only size=3 makes sence. Any size is coerced to size=3.
type="osisaf"
Filter for edge detection. Only size=5 makes sence. Any size is coerced to size=5. TODO (pl): reference 
       -0.0625 -0.0625 -0.0625 -0.0625 -0.0625
       -0.0625  0.1250  0.1250  0.1250 -0.0625
       -0.0625  0.1250  0.0000  0.1250 -0.0625
       -0.0625  0.1250  0.1250  0.1250 -0.0625
       -0.0625 -0.0625 -0.0625 -0.0625 -0.0625
type="hires"
Filter for unsharping. Only size=3 makes sence. Any size is coerced to size=3.
      -alpha   alpha-1 -alpha
       alpha-1 alpha+5  alpha-1
      -alpha   alpha-1 -alpha
type="correl"
Filter for contrast increasing. Only size=3 makes sence. Any size is coerced to size=3.
                 alpha^2    -alpha*(1+alpha^2)               alpha^2
      -alpha*(1+alpha^2)         (1+alpha^2)^2    -alpha*(1+alpha^2)
                 alpha^2    -alpha*(1+alpha^2)               alpha^2
type="LoG"
Laplacian of Gaussian. Filter for edge detection. sigma is used, alpha is ignored.
type="sobel"
Two-directional Sobel filtering. Only size=3 makes sence. Any size is coerced to size=3.
type="sobelG"
Sobel gradient. Only size=3 makes sence. Any size is coerced to size=3.
Object of class ursaRaster with the same number of bands as in input raster.
Laplacian of Gaussian filter (type="LoG") is not implemented clearly due to applying continuous-valued formula to discrete matrix.
Nikita Platonov platonov@sev-in.ru
TODO(pl): at least reference to 'osisaf'.
Other focal operations: focal_mean, focal_median, focal_extrem.
session_grid(NULL)
v <- round(runif(8,min=-1,max=1),3)
customFilter <- matrix(c(v[1:4],-sum(v),v[5:8]),ncol=3)
a <- ursa_dummy(1,mul=4/8,elements=32)
tpList <- eval(formals("focal_special")$type)
res <- c(src=a,as.ursa(bandname=tpList))
for (tp in tpList) {
   message(tp)
   res[tp] <- focal_special(a,tp,fmask=customFilter,size=11,sigma=1,alpha=0.8
                           ,saveMargin=0,verbose=2L)
}
print(res)
display(res,decor=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.