use*_*033 3 python rgb matlab image matrix
我有一个像这样的rgb矩阵:
image=[[(12,14,15),(23,45,56),(,45,56,78),(93,45,67)],
[(r,g,b),(r,g,b),(r,g,b),(r,g,b)],
[(r,g,b),(r,g,b),(r,g,b),(r,g,b)],
..........,
[()()()()]
]
Run Code Online (Sandbox Code Playgroud)
我想显示包含上述矩阵的图像.
我用这个函数来显示灰度图像:
def displayImage(image):
displayList=numpy.array(image).T
im1 = Image.fromarray(displayList)
im1.show()
Run Code Online (Sandbox Code Playgroud)
参数(图像)具有矩阵
任何人都帮我如何显示rgb矩阵
impow在matplotlib库中将完成这项工作
重要的是你的NumPy数组具有正确的形状:
高x宽x 3
(或RGBA的高度x宽度x 4)
>>> import os
>>> # fetching a random png image from my home directory, which has size 258 x 384
>>> img_file = os.path.expanduser("test-1.png")
>>> from scipy import misc
>>> # read this image in as a NumPy array, using imread from scipy.misc
>>> M = misc.imread(img_file)
>>> M.shape # imread imports as RGBA, so the last dimension is the alpha channel
array([258, 384, 4])
>>> # now display the image from the raw NumPy array:
>>> from matplotlib import pyplot as PLT
>>> PLT.imshow(M)
>>> PLT.show()
Run Code Online (Sandbox Code Playgroud)