单通道转三通到道

读取单通道图像为array数组,复制其余两通道,扩充为三通道:

import numpy as np
a=np.asarray([[10,20],[101,201]])
#a = skimage.io.imread("000001.bmp")  # 你想要测试的图片

# 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)

 

你可能感兴趣的:(工具)