Reinhard et al. (2001) showed that a surprisingly broad class of image-recolouring effects can be produced by transferring just two statistics, the per-channel mean and the per-channel standard deviation, from a reference image to a target image, in the perceptually-uniform CIE-Lab colour space. The implementation here applies that algorithm to nine public-domain test images, using Lenna as the reference palette.
RGB is a device colour space: the three channels are correlated (R, G, B all rise together for "brighter"), so transferring statistics in RGB couples luminance to chromaticity in ways that hurt the result. CIE-Lab decorrelates: L* carries luminance, a* and b* carry chromaticity. Per-channel statistics in Lab move colour without dragging brightness, and move brightness without dragging colour.
For each Lab channel c ∈ {L*, a*, b*}, with reference image S and target image T, compute the recoloured target pixel:
c'_T(x, y) = (σ_S^c / σ_T^c) · ( c_T(x, y) − μ_T^c ) + μ_S^c
That is: subtract the target's per-channel mean, rescale by the ratio of standard deviations, then add the reference's per-channel mean. The result is converted back from Lab to BGR and clipped to [0, 255].
Two statistics per channel × three channels = six numbers carry the entire colour transfer. The whole pipeline is two colour-space conversions, six cv2.meanStdDev calls, and per-pixel arithmetic, which is why it runs in milliseconds on a CPU and why it sits inside compositing tools that need real-time recolour.
Reference palette is taken from Lenna throughout. Three of the nine targets are shown.
Target: Cameraman. The originally near-grayscale target picks up a warm, low-saturation cast from the reference.
Target: Sailboat. The blue-dominant target shifts toward the warmer reference distribution while preserving the structural luminance.
Target: Yacht. Per-channel statistics move chromaticity without crushing the high-contrast hull/sail/water structure.
Reinhard, E., Adhikhmin, M., Gooch, B., & Shirley, P. (2001). Color Transfer between Images. IEEE Computer Graphics and Applications, 21(5), 34–41.