I didn't want to ask a question if I can find myself and I thought I was doing something wrong but I'm not...for an RGB/full color image. So code like this will work:
from PIL import Image
import numpy as np
im = Image.open('myimg.png')
indexed = np.array(im)
pixels = im.load()
for i in range(im.size[0]):
for j in range(im.size[1]):
if pixels[i,j] == (93, 53, 8):
pixels[i,j] = (255, 0, 255)
im.save(im.filename)
But not if the image is indexed.. why it doesnt work for indexed if both colors are present in the color map? And how to make it work? I need to replace the mentioned color in the image with Magenta, in the image, not the palette, I have both colors in the palette.