Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add padding to 2d matrix p

import numpy as np
# https://numpy.org/doc/stable/reference/generated/numpy.pad.html
image = np.ones((2,2), dtype=int)

padded_image = np.pad(image, 1, dtype=int, mode='constant')

print(padded_image)
# [[0 0 0 0]
#  [0 1 1 0]
#  [0 1 1 0]
#  [0 0 0 0]]
Source by numpy.org #
 
PREVIOUS NEXT
Tagged: #add #padding #matrix
ADD COMMENT
Topic
Name
4+1 =