I'm looking for an efficient way to replace certain values within a numpy image. So far this is where I got :
def observation(self, img):
# 45 50 184
background = np.array([45, 50, 184])
# 80 0 132
border = np.array([80, 0, 132])
img = self.crop(img)
for line_index, line in enumerate(img):
for pixel_index, pixel in enumerate(line):
if not np.array_equal(pixel, background) and not np.array_equal(pixel, border):
img[line_index][pixel_index] = [254, 254, 254]
The idea is to replace all the colors that are not background or border to white. I'm quite new to this, so I'm fairly sure that there is a more efficient way to do this.
Thanks all.