如何以 RGB 形式(二维矩阵)转换图像

How to convert image in form of RGB (2-D matrix)

我有一张尺寸为 128x128 的图片。我在上面应用了matlab的imread函数, A= imread(first.jpg); 但这返回了一个 3-D 数组 128x128x3 ,我如何将它转换为由 3 列 R、G、B(每种颜色一列)组成的 2-D 矩阵?

A = imread('first.jpg');
Npixels = size(A,1)*size(A,2);
newA = reshape(A,[Npixels,3]);