numpy按行按列添加

1
2
3
4
5
6
7
8
9
10
11
12
import numpy as np
from skimage import io

#拼图片(28,28)*25 -> (25,28,28)
imgs = np.empty(shape=(0,28,28))
img = io.imread("data.png")#(28,28)

imgs = np.append(imgs, [img] , axis=0)#(1,28,28)
imgs = np.append(imgs, [img] , axis=0)#(2,28,28)
imgs = np.append(imgs, [img] , axis=0)#(3,28,28)
imgs = np.append(imgs, [img] , axis=0)#(4,28,28)
imgs = np.append(imgs, [img] , axis=0)#(5,28,28)

转载请注明来源 https://tianweiye.github.io