convKernel: Function for creating convolution kernel for different...

Description Usage Arguments Details Value References Examples

View source: R/convK.R

Description

This function creates the convolution kernel for applying a filter to an array/matrix

Usage

1
2
convKernel(sigma = 1.4, k = c("gaussian", "LoG", "sharpen", "laplacian",
  "emboss", "sobel"))

Arguments

sigma

The numeric value of standard deviation for the Gaussian or LoG filter

k

character value:

  • gaussian for Gaussian kernel

  • LoG for Laplacian of Gaussian kernel

  • sharpen for 3x3 convolution matrix for sharpening edges

  • laplacian for a 3x3 convolution matrix that enhances the edges

  • emboss for a 3x3 kernel that draws edges as embossed image

  • sobel gives one of the two 3x3 matrices needed to apply the Sobel filter

Details

The convolution kernel is a matrix that is used by spacialfil function over a matrix, or array, for filtering the data. Gaussian kernel is calculated starting from the 2 dimension, isotropic, Gaussian distribution:

G(x)=\frac{1}{2πσ^{2}}e^{-\frac{x^{2}+y^{2}}{2σ^{2}}}

Laplacian of Gaussian kernel applies a second derivative to enhance regions of rapid intensity changes:

LoG≤ft ( x,y \right )=\frac{-1}{πσ^{4}}≤ft ( 1-\frac{x^{2}+y^{2}}{2σ^{2}}\right ) e^{-\frac{x^{2}+y^{2}}{2σ^{2}}}

the use of the underlying Gaussian kernel (so the name Laplacian of Gaussian or LoG) is needed to reduce the effect of high frequency noise that can affect the signal distribution. Laplacian is a Sharpen enhance the detail. Emboss kernel is a 3x3 convolution kernel that embosses the edges. (but also the noise) in original dataset. Sobel convolution kernel returns the possibility to detect edges in a more sofisticated way, the convKernel function returns only one of the two matrices needed to apply the filter. The second one is calculated by transposing the returned matrix in the other needed one.

Value

An object of class convKern with the matrix of convolution kernel whose size varies according the value of sigma (in case of gaussian or LoG option selected), and k being the convolution kernel type label

References

Examples

1
2
3
4
5
## Not run:
# creates a convolution kernel with Gaussian function and sigma = 1.4
K <- convKernel(sigma = 1.4, k = 'gaussian')
plot(K)
## End(**Not run**)

nickwing/spatialfil documentation built on May 23, 2019, 5:08 p.m.