padding: Padding of matrices or n-dimensional arrays with a user...

Description Usage Arguments Details Value Examples

View source: R/superpixels.R

Description

Padding of matrices or n-dimensional arrays with a user specified value

Usage

1
padding(input_data, new_rows, new_cols, fill_value = 0)

Arguments

input_data

either a matrix or a 3-dimensional array

new_rows

an integer specifying the new rows of the output matrix or array

new_cols

an integer specifying the new columns of the output matrix or array

fill_value

a numeric value to fill the extended rows / columns of the initial input data

Details

The padding function returns a list, where data is the padded / extended matrix or array and padded_start, padded_end, padded_left and padded_right are integer values specifying how many rows or columsn in up-, down-, left- or right-direction the input matrix or array was padded / extended with the specified fill-value.

Value

a list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(OpenImageR)


#-------
# matrix
#-------

set.seed(1)
mt = matrix(runif(100), 10, 10)

res_mt = padding(mt, 15, 20, fill_value = -1)


#------
# array
#------

lst = list(matrix(1, 10, 10), matrix(2, 10, 10))

arr = List_2_Array(lst, verbose = FALSE)

res_arr = padding(arr, 15, 20, fill_value = mean(as.vector(mt)))

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