python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > python单通道转3通道

python 实现单通道转3通道

作者:ShellCollector

今天小编就为大家分享一篇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就是最后一个通道

以上这篇python 实现单通道转3通道就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文