How to find f given that f(some_image) = processed_image I have a before/after image pair with pixel transformations only (for example, grayscale, or a hue shift. No blur, border, sharpen, etc.). I'm trying to find a function such that for every pixel (r, g, b) in the original image, f(r, g, b) = (r', g', b'), (r', g', b') being the pixel in the "after" image.

I was thinking about a polyfit function, but I couldn't find one that works in 3D.

I'd appreciate any help with this, or another method of achieving what I need.
Fit 3 polynoms (or any other model) using the individual channels of the output image: r' as a function of (r, g, b), g' as a function of (r, g, b), b' as a function of (r, g, b). I would also suggest not including in the data set all pixels with a 0 or 255 value (if your image is 8-bit) - these values might have been clipped.