conv2: 2-D convolution

View source: R/conv2.R

conv2R Documentation

2-D convolution

Description

Compute the two-dimensional convolution of two matrices.

Usage

conv2(a, b, shape = c("full", "same", "valid"))

Arguments

a, b

Input matrices, coerced to numeric.

shape

Subsection of convolution, partially matched to:

"full"

Return the full convolution (default)

"same"

Return the central part of the convolution with the same size as A. The central part of the convolution begins at the indices floor(c(nrow(b), ncol(b)) / 2 + 1)

"valid"

Return only the parts which do not include zero-padded edges. The size of the result is max(nrow(a) - nrow(a) + 1, 0) by max(ncol(A) - ncol(B) + 1, 0)

Value

Convolution of input matrices, returned as a matrix.

Author(s)

Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

See Also

conv, convolve

Examples

a <- matrix(1:16, 4, 4)
b <- matrix(1:9, 3,3)
cnv <- conv2(a, b)
cnv <- conv2(a, b, "same")
cnv <- conv2(a, b, "valid")


gsignal documentation built on Sept. 12, 2024, 6:27 a.m.