# Import the NumPy library
import numpy as np

w, h = 16, 16
I = np.random.randint(0, 2, (w, h, 3)).astype(np.ubyte)

# Reshape I to a 2D array of shape (w*h, 3)
I_flat = I.reshape(-1, 3)

# Use numpy.unique on the flattened I array
n = len(np.unique(I_flat, axis=0))

print(n)