Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

padding

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


Description

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

Usage

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

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

An Image Processing Toolkit

v1.1.8
GPL-3
Authors
Lampros Mouselimis [aut, cre] (<https://orcid.org/0000-0002-8024-1546>), Sight Machine [cph] (findHOGFeatures function of the SimpleCV computer vision platform), Johannes Buchner [cph] (average_hash, dhash and phash functions of the ImageHash python library), Mohammad Haghighat [cph] (Gabor Feature Extraction), Radhakrishna Achanta [cph] (Author of the C++ code of the SLIC and SLICO algorithms (for commercial use please contact the author))
Initial release
2021-05-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.