How our image data imported via PIL and converted to numpy array is stored

606 rows in img_2617. Each element in the big list is a column list. Each column list has 1810 columns. Each element in the column list is a 3-element list. This three element list contains the R,G,B raw image data.


In [12]:
import numpy as np
from PIL import Image

In [13]:
img = Image.open("IMG_2617.tif")
img_data = np.array(img)
img_data


Out[13]:
array([[[1, 0, 0],
        [1, 0, 1],
        [1, 0, 1],
        ..., 
        [1, 0, 0],
        [3, 2, 2],
        [0, 0, 0]],

       [[1, 0, 1],
        [0, 0, 0],
        [1, 1, 1],
        ..., 
        [1, 0, 1],
        [1, 1, 1],
        [0, 0, 0]],

       [[0, 0, 0],
        [1, 0, 0],
        [1, 0, 1],
        ..., 
        [1, 0, 0],
        [0, 0, 0],
        [1, 1, 1]],

       ..., 
       [[1, 0, 1],
        [0, 0, 0],
        [0, 0, 0],
        ..., 
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[2, 1, 2],
        [1, 1, 1],
        [0, 0, 0],
        ..., 
        [1, 0, 0],
        [1, 1, 1],
        [0, 0, 0]],

       [[1, 0, 0],
        [1, 0, 0],
        [1, 1, 1],
        ..., 
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]], dtype=uint8)

In [14]:
len(img_data)


Out[14]:
606

In [15]:
len(img_data[0])


Out[15]:
1810

In [16]:
len(img_data[0][1])


Out[16]:
3

In [ ]: