Suppose I have some image located at img_path
. The code is then as follows:
from keras.preprocessing import image
import numpy as np
img = image.load_img(img_path, target_size=(150,150))
img_tensor = image.img_to_array(img)
When I print img_tensor
I get the following:
array([[[164., 174., 186.],
[161., 171., 183.],
[161., 170., 185.],
...,
[198., 214., 240.],
[200., 216., 242.],
[200., 216., 242.]],
[[160., 170., 182.],
[157., 167., 179.],
[158., 167., 182.],
...,
[199., 215., 241.],
[201., 217., 243.],
[201., 217., 243.]],
[[161., 171., 183.],
[159., 169., 181.],
[160., 169., 184.],
...,
[199., 215., 241.],
[199., 215., 241.],
[199., 215., 241.]],
The array obviously continues and at the end it says dtype=float32
.
I know that the dimensions are 150x150x3. So my guess is that each bracketed bit written as, for example, [50., 50., 50.]
is an individual pixel over the three channels for red green and blue. So R is at 50 (of the possible 255 being the maximum for red).
Then when it closes with the double brackets we've completed a row of pixels.
Is my intuition correct?