Question: so I have this 3d array created by *pygame.surfarray.array3d(image)* and it gives me an indexed array as [width][height] and the 3rd dimension having the RGB values (R, G, B)

Something like this: array[x][y] = (0, 255, 167)

Now, I want to take each of the RGB columns into a new 2d array (for example, I want to make a new Red[x][y] array with just the R column values, a new Green[x][y] array with just the G column values and a new Blue[x][y] array with just the B column values). 

It would look like this then (in this example I am just showing a single value, but I want these Red Green and Blue to be arrays): 

Red[x][y] = 0

Green[x][y] = 255

Blue[x][y] = 167

I've tried using array[:, 0] for red, array[:,1] for green and array[:,2] for blue but it didn't work - my guess it is because this array is not a numpy array.

Any help is very welcome. Thank you!

Answer: 
`pygame.surfarray.array3d(image)` will return a numpy array of dimension *width x height x 3* (where *3* are the three color components RGB). You can use `:` to access all elements in a dimension and integers to access elements at a certain index.

For example, to access the colors in a image you write `array[:, :, 0]` for the red, `array[:, :, 1]` for the blue and `array[:, :, 2]` for the green. To access the blue colors on the 16th row you write `array[:, 16, 1]`.

If you exclude indexing a dimension it'll assume you want all the elements in that dimension. For example, `array[:, :]` is the same as `array[:, :, :]` and `array[4]` is the same as `array[4, :, :]`.

Here's a short example to answer your question.

```
import pygame
pygame.init()

image = pygame.Surface((4, 4))
image.fill((255, 128, 32))

array = pygame.surfarray.array3d(image)

red_array   = array[:, :, 0]  # These will now be a 2D-array since we're extracting
green_array = array[:, :, 1]  # only one value from the third dimension.
blue_array  = array[:, :, 2]

print('Red array: ')
print(red_array)
print('Green array: ')
print(green_array)
print('Blue Array: ')
print(blue_array)

```
You'll likely just want to use the regular approach of looping through the 2D array.

```
red,green,blue = ([[0]*len(array[0]) for i in range(len(array)),)*3
for i in range(len(array)):
    for j in range(len(array[i])):
        red[i][j],green[i][j],blue[i][j] = array[i][j] 

```