I have RGB images as numpy arrays and I want to replace to certain pixel value:
import numpy as np
import random
def rgb():
L = [1]*3
return [random.randrange(0, 256,1)for l in L]
def makeDummyData():
#creates list of lists with 3 rgb, which contains values to replace (x)
L = [1]*10000
L = [rgb() for l in L]
x = L[0]
for i in range(500):
L[i] = x
return L, x
L, x = makeDummyData()
a = np.array(L).reshape(-1, 3)
a = np.array(a).reshape(100, 100, 3)
b = np.where(a == (np.array(x), [255,255,255], a))
print(b)
Instead of returning an array, where the target values are replaced, the output is (array([], dtype=int64),)