Why image is read as a 3D arrays?


(Manish Kumar) #1

In lesson 1
img = plt.imread(f’{PATH}valid/cats/{files[0]}’)
This line of code returns a 3D array having shape (198, 178, 3) . What does this practically signifies ? What properties of image does those dimensions represents?


#2

The 3rd dimension represents different channels of the image. In this case, it might represent ‘RGB’, or ‘red/green/blue’.

The 1st dimension, R, gives the intensity of the red channel and so forth.


(Manish Kumar) #3

Alright. Thank you. So that means img.shape outputs a result (192,179,3). i.e. 3 planes of sheet having 192 x 179 blocks , each sheet for colors Red, Green and Blue.


#4

Exactly!
It should looks like the image below. Each Red, Green and Blue channel (yes, they call it ‘channel’) values are 8 bit and between 0 to 255.

image