planes, rows, cols, n = 3, num, num, 4
lut = np.random.randint(-2 ** 31, 2 ** 31 - 1, size=(planes * 256 * n // 4,)
    ).view('uint8')
lut = lut.reshape(planes, 256, n)
img = np.random.randint(-2 ** 31, 2 ** 31 - 1, size=(planes * rows * cols //
    4,)).view('uint8')
img = img.reshape(planes, rows, cols)
Using numpy.take for faster fancy indexing