from collections import namedtuple import numpy as np # RGB-hodnoty jednoho pixelu Pixel = namedtuple('Pixel_RGB', 'r g b') # data obrázku pixely = [ Pixel(255, 0, 0), Pixel( 0, 255, 0), Pixel(0, 0, 255), Pixel(255, 255, 0), Pixel(255, 0, 255), Pixel(0, 255, 255), Pixel(255, 255, 255), Pixel(128, 128, 128), Pixel(0, 0, 0), ] # data obrázku jako pole 3x3x3 (výška x šířka x vrstvy RGB) image = np.array(pixely).reshape(3, 3, 3) xb = bytes(image) print(xb) print(len(xb)) print() print(image.tolist()) print() print(image.shape) print(image.ndim) print(image.size) print(image.dtype)