Slicing a 3-Dimensional ndarray in python
<p>I'm attempting to slice a 3-D instance of ndarray representing a color image, where each element (or pixel) in the 2-D array contains an array with 3 bytes corresponding to the values of Red, Green, and Blue respectively. I want to slice out a 2-D ndarray for each color individually so that I can flatten them and concatenate them end-to-end as per our implementation requirements. The code I'm currently trying is...</p>

<pre><code>red = image[:, :, 0]
green = image[:, :, 1]
blue = image[:, :, 2]
collapsed_image = numpy.concatenate((red.flatten('C'), green.flatten('C'), blue.flatten('C')), axis=0)
</code></pre>

<p>Where image is my numpy.ndarray object containing the 3-D array of bytes. Would this work to slice out each individual color's 2-D array and flatten/concatenate them together end-to-end?</p>