[SOLVED] Reading 3D numpy array

Issue

I have a dataset which comprises of the binary data of pixelated 50×50 images. The array shape is (50, 50, 90245). I want to reach 50×50 pixels of each of the 90245 images. How can I slice the array?

Solution

If data is the variable storing the image data, and i is the index of the image you want to access, then you can do:

data[:,:,i]

to get the desired image data.

Answered By – BrokenBenchmark

Answer Checked By – Mary Flores (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *