1 | initial version |
Maybe use stl::vector instead of array since different images will be different sizes. Also, data in grayscale images are normally unsigned char (uchar). Something lke:
Mat img = imread("C:/OpenCV4_0_1/sources/samples/data/lena.jpg");
Mat gimg;
cvtColor(img, gimg, COLOR_RGB2GRAY);
vector<unsigned short> pixelList(gimg.size().area());
pixelList.assign(gimg.begin<uchar>(), gimg.end<uchar>());