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

Description Usage Arguments Details Value References Examples

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**)

Example output

Loading required package: abind
Loading required package: fields
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.2-2 (2019-03-07) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following objects are masked from 'package:base':

    backsolve, forwardsolve

Loading required package: maps
See https://github.com/NCAR/Fields for
 an extensive vignette, other supplements and source code 

spatialfil documentation built on May 2, 2019, 8:53 a.m.