How is the matrix/array arranged after stretching each image data into one column?

I have data of 209 images of dimension 64x64x3 stored in an array X, where height (horizontal-pixels=64), width(vertical-pixels=64), and depth(RGB value=3).

X.shape = (64,64,3)

I use the command “X_flatten = X.reshape(X.shape[0], -1).T”. Now I have new array X_flatten which is of dimension (12288, 209).

This means that in each column of X_flatten, I have 12288 values that make up each of the 209 images.

My question is that, how are these values arranged in each column?

Is it true that in each column we have, in the first 4096 rows, only the Red pixel values, and then in the next 4096 rows, we have the Green-Pixel values, and then in the final 4096 rows, we have the Blue-Pixel values?

To make it easier to understand I have attached 2 images. Can you identify for me which of the format is correct?

For reference this is from the lab:
2- Overview of the problem set
- Exercise 2

It’s a great question and it has come up before: Here’s a thread which goes through the flattening process in detail. Make sure to also read the later posts there that discuss the difference between the “C” ordering (the default) and the “F” ordering.

The short answer is that the “C” order (the default) gives you all 3 color values for each pixel location together. If you use the “F” order, then you get all the red pixel values, followed by all the green pixel values, followed by the blue. So that method gives you the equivalent of 3 monochrome images back to back. The other high level point is that the algorithm can learn to recognize the patterns in either order, as long as you are consistent and always use the same method. See the thread for concrete demonstrations of this.

Perfect, this is exactly what I was looking for. Thank you!