Change color in rgb images

Hi everyone,

I have a image and I want to change where rgb values are [0.4, 0.4, 0.4] to [0.54, 0.27, 0.07].
By doing this I want to change road color from gray to brown. Would you please help me with this?

image

If im is your torch.tensor of shape (L, W, 3), then it would be the same as in numpy:

im[:, :, 0][im[:, :, 0] == 0.4] = 0.54
im[:, :, 1][im[:, :, 1] == 0.4] = 0.27
im[:, :, 2][im[:, :, 2] == 0.4] = 0.07

There is probably a nicer way to do it in one line, but this will work and is more clear than the one line solution I am thinking of.