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就是最后一个通道
栏 目:Python代码
下一篇:python中利用h5py模块读取h5文件中的主键方法
本文标题:python 实现单通道转3通道
本文地址:http://www.codeinn.net/misctech/44103.html






