R/superpixels.R
padding.Rd
Padding of matrices or n-dimensional arrays with a user specified value
padding(input_data, new_rows, new_cols, fill_value = 0)
either a matrix or a 3-dimensional array where the third dimension is equal to 3
an integer specifying the new rows of the output matrix or array
an integer specifying the new columns of the output matrix or array
a numeric value to fill the extended rows / columns of the initial input data
a list
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.
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)))