I am working with images and I want to pad numpy array with zeros. I looked at np.pad
For padding single array it works fine
x = np.array([[1,2],[3,4]])
y = np.pad(x,(1,1), 'constant')
x
=> array([[1, 2],
[3, 4]])
y
=> array([[0, 0, 0, 0],
[0, 1, 2, 0],
[0, 3, 4, 0],
[0, 0, 0, 0]])
How to implement if we have x type arrays in a list/array , like
c_x=np.array([[[2,2],[2,3]],[[3,2],[2,3]],[[4,4],[2,3]]])
c_y=np.pad(c_x,((0,0),(1,1),(0,0)),'constant') #padding is present only on top and bottom
As such arrays contains R,G,B channel, Can that too be accounted when padding?
edit:
Say c_x stores list of 10 images on 28x28 pixels with RGB channel
Now I want to pad all 10 images , So after modifying 10 images are of 30x30 with pixels on border as [0,0,0]
c_yis not what you want. Could you show what the desired result is? Just enter it by hand for the small example.