I have two colors, A and B. I want to swap A and B with eachother in the image.
So far what I have written is:
path_to_folders = "/path/to/images"
tifs = [f for f in listdir(path_to_folders) if isfile(join(path_to_folders, f))]
for tif in tifs:
img = imageio.imread(path_to_folders+"/"+tif)
colors_to_swap = itertools.permutations(np.unique(img.reshape(-1, img.shape[2]), axis=0), 2)
for colors in colors_to_swap:
new_img = img.copy()
new_img[np.where((new_img==colors[0]).all(axis=2))] = colors[1]
im = Image.fromarray(new_img)
im.save(path_to_folders+"/"+tif+"-"+str(colors[0])+"-for-"+str(colors[1])+".tif")
However nothing is changed in the images saved to disk. What am I doing wrong?

