Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个图像,我想对其进行一些计算,所以我需要它的矩阵形式。当我使用 读取图像时imread('image.png'),MATLAB 给出了一个M*N*3正确的矩阵,因为这三个维度用于颜色。但是,我需要一个M*N矩阵。
imread('image.png')
M*N*3
M*N
如何将此M*N*3矩阵转换为M*N具有真实颜色图的矩阵?
您可以使用[X,map] = rgb2ind(RGB,n) 其中 RGB 是您已读取的图像,n 是最大颜色数,X 是新图像,map 是颜色图。
[X,map] = rgb2ind(RGB,n)
你也可以使用[X,map] = imread('Image.png');
[X,map] = imread('Image.png');