convolution: convolution

Description Usage Arguments Details Value Author(s) Examples

View source: R/open_image_rscript.R

Description

convolution

Usage

1

Arguments

image

either a matrix, data frame or array

kernel

a kernel in form of a matrix

mode

the convolution mode (one of 'same', 'full')

Details

This function performs convolution using a kernel matrix. When mode 'same' the output object has the same dimensions with the input, whereas when mode 'full' the rows and columns of the output object equals : ROWS = nrow(image) + nrow(kernel) - 1 and COLUMNS = ncol(image) + ncol(kernel) - 1

Value

either a matrix or an array, depending on the input data

Author(s)

Lampros Mouselimis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# kernel
x = matrix(1, nrow = 4, ncol = 4) / 16   # uniform


# matrix
image_matrix = matrix(runif(100), 10, 10)

res = convolution(image_matrix, x, "same")


# array
image_array = array(runif(300), dim = c(10, 10, 3))

res = convolution(image_array, x, "same")

OpenImageR documentation built on Sept. 10, 2021, 5:08 p.m.