当前位置:主页 > 软件编程 > Python代码 >

python 实现单通道转3通道

时间:2021-01-12 13:18:29 | 栏目:Python代码 | 点击:

下面有两种方法都可以:

import numpy as np
a=np.asarray([[10,20],[101,201]])

# a=a[:,:,np.newaxis]
# print(a.shape)
# b= a.repeat([3],axis=2)
# print(b.shape,b)

image = np.expand_dims(a, axis=2)
image = np.concatenate((image, image, image), axis=-1)

print(image)
axis=-1就是最后一个通道

您可能感兴趣的文章:

相关文章