I haven't been able to figure out why the following doesn't work:
img = Image[ExampleData[{"TestImage", "Tree"}], "Real"]
img /. {r_, g_, b_} :> 1 - {r, g, b} (* Image left unchanged *)
Looking at the full form of img, I see that the pixels are stored as lists of three real numbers each, so I don't get why the pattern won't match.
This works though, giving me the "negative" image that I expected from the previous code also:
Image[ImageData[img] /. {r_, g_, b_} :> 1 - {r, g, b}]
So what's the problem with the first code?
(Kindly note that the image processing problem that the above code happens to perform is of no interest to me here; I just chose it as an example, so don't misdirect your effort showing how it could be done using library functions. Here, I'm only interested in understanding why the rule application didn't work)
img // Dimensions
toImageData[img] // Dimensions
? $\endgroup$ExampleData
returns here -- in anotherImage
change anything? $\endgroup$