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]):
cv2.imshow('slice', P[:, :, k])
cv2.waitKey(20)
![](https://img-my.csdn.net/uploads/201211/29/1354201904_4617.jpg)