I am trying to add the red pixel values into a vector, but when I print out the vector its empty. The color value prints correctly as the loop goes so its getting the values from the pixels. Also this is extremely slow would there be a better way to do this? I am still a student so any help would be greatly appreciated.
vector <Uint8> pixelValues;
x = myImage.getSize().x;
y = myImage.getSize().y;
for (Uint8 i = 0; i < x; i++){
for (Uint8 j = 0; j < y; j++){
const Color color = myImage.getPixel(i, j);
pixelValues.push_back((Uint8)color.r);
cout << (int)color.r << endl;
cout << (int)color.b << endl;
cout << (int)color.g << endl;
cout <<"these are red pixels in array " << pixelValues[z++] << endl;
}