网络编程
位置:首页>> 网络编程>> Python编程>> python 实现单通道转3通道

python 实现单通道转3通道

作者:ShellCollector  发布时间:2021-09-12 22:03:25 

标签:python,单通道,3通道

下面有两种方法都可以:


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就是最后一个通道

来源:https://blog.csdn.net/jacke121/article/details/80086866

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com