I am currently using Pillow to access every pixel of an image and to substitute the RGB values with the elements of a list.
I think however that this method is quite slow and I read that a much faster way of doing it is to use numpy arrays.
I convert the image to a numpy array with shape (x, y, 3), but I don't know how to 'merge' it with my list. For example I have a list with 20 elements, so I want to substitute the first 20 elements in my array with those in my list, without changing the shape of my array.
My array looks like this:
[[[121, 222, 222], [1, 1, 1],...]]
And I have a list such as:
[120, 99, 0, 88, 78, 32, 123,...]
The final array should look like this:
[[[120, 99, 0], [88, 78, 32], [123, ..., ...],...]]
The list is shorter that the array, so when the list ends the elements of the array that follow should remain unchanged.
I tried to explain as better as I could, is something is unclear please let me know.
Thank in advance.