I have a 2D array of RGBA values (Ex: [30, 60, 90, 255]) and I want to replace all white [255 255 255 255] with [0 0 0 0]. What is the simplest way to do this?
Using for loops I have tried assigning a new array to an index but the index does not change:
data = np.array(img)
for y in range(img.size[0]):
for x in range(img.size[1]):
if (data[x][y] == [255, 255, 255, 255]).all():
data[x][y] == [0, 0, 0, 0] # Doesn't change value at index?
np.arrayconversion may convert values to floats in the [0,1] range and not [0,255]. Not to mention only data may be modified and not img if it is a deep copy.