Python中对ndarray进行填充
发布时间
阅读量:
阅读量
Python ndarray padding
With the bug about _ np.lib.pad_ reported here: https://github.com/numpy/numpy/issues/7353 and the corresponding update here: https://github.com/numpy/numpy/pull/7354#issuecomment-189551370
We can get the proper padding for ndarray.
Demo code:
import numpy as np
import cv2
T = np.ones([150, 100, 200], dtype='uint8')
T = T*200
P = np.lib.pad(T, ((50, 50),(50, 50),(50, 50)), 'constant', constant_values=np.array(((100, 100),(100, 100),(100, 100))))
dim = P.shape
print dim
for k in range(dim[2]):
全部评论 (0)
还没有任何评论哟~
