如何在python中从None通道转换为3通道图像?

时间:2017-10-17 17:43:40

标签: python image image-processing matplotlib python-imaging-library

我正在使用以下代码阅读灰度图像:

import pylab as plt
. . .
circle_image = plt.imread(image_gray) #this dimension is 120,120
print(circle_image.shape) # prints (120,120)
plt.imshow(circle_image)
plt.show()

Original Image of 120,120

我使用以下内容将其大小调整为256x256:

resized_circle_image = misc.imresize(circle_image, (256,256)) # i tried using (256,256,3) but that generates resized image of (256, 256) only
print(resized_circle_image.shape) # prints (256,256)
plt.imshow(resized_circle_image)
plt.show()

resized image of 256,256

我必须将此图像与形状为(256,256,3)的彩色图像连接起来。如何从无通道转换为3通道图像格式?

我尝试了什么:

a = np.resize(resized_circle_image, (256, 256, 3))

但是,通过重复相同的图像9次完全改变图像如下:     Now dimension is 256,256,3 but image is not as expected

0 个答案:

没有答案