I am reading a .gif image using the imageio library in Python (which reads the .gif format as a list of frames, each are numpy arrays). I want to replace all the RGB colors in the .gif image with a certain fixed color (to possibly use an if statement later to change some parts of the image).
The data are on the form of something like [[23 234 23 24], [34, 46, 57 255]]...
This is my code:
gifimage = imageio.mimread(inputgif)
for x in range(len(gifimage)):
shape = gifimage[x].shape
for l in range(0, shape[0]):
for y in range(0, shape[1]):
gifimage[x][l][y] = [50, 205, 50, 255] #255 is just the alpha channel which I can ignore.
Also tried:
for x in range(len(gifimage)):
shape = gifimage[x].shape
for l in range(0, shape[0]):
for y in range(0, shape[1]):
gifimage[x][l][y][0] = 50
gifimage[x][l][y][1] = 205
gifimage[x][l][y][2] = 50
gifimage[x][l][y][2] = 255
But when I run it, it never ends. Why is that?