In this code (courtesy to this answer):
from PIL import Image
import numpy as np
def load_image(infilename):
img = Image.open(infilename)
img.load()
data = np.asarray(img, dtype="int32")
return data
def save_image(npdata, outfilename):
img = Image.fromarray(np.asarray(np.clip(npdata, 0, 255), dtype="uint8"), "L")
img.save(outfilename)
data = load_image('cat.0.jpg')
print(data.shape)
The value of print(data.shape)
is a tuple of three dim (374, 500, 3)
. Thus, I have these questions:
- What does this tuple represent?
- To be used for machine learning classification purpose, does it make sense to convert such a tuple data into one dimension vector? If so, how?
Thank you very much.