The Process


Overview


Programming Notes


Step 1 - Converting from RGB to LMS Colorspace

For both images, apply this matrix to each pixel

0.3811 0.5783 0.0402
0.1967 0.7244 0.0782
0.0241 0.1288 0.8444

Then, for each pixel, and each channel L, M, S, let L=logL, M=logM, and S=logS


Step 2 - Converting from LMS to lαβ Colorspace

For both images, apply this matrix to each pixel

1.0 1.0 1.0
1.0 1.0 -2.0
1.0 -1.0 0.0
And then apply this matrix to the pixels of both images
1.0 / √3 0.0 0.0
0.0 1.0 / √6 0.0
0.0 0.0 1.0 / √2

Step 3 - Transferring image1's colors to image2

First, do these steps:

After finding these variables, complete the following mathematical steps on image2's lαβ data:


Step 4 - Converting from lαβ to LMS Colorspace

Only for image2, apply this matrix to each pixel

√3 / 3 0.0 0.0
0.0 √6 / 6 0.0
0.0 0.0 √2 / 2
And then apply this matrix to the pixels
1.0 1.0 1.0
1.0 1.0 -1.0
1.0 -2.0 0.0


Step 5 - Converting from LMS to RGB Colorspace

Then, for each pixel in image2, and each channel L, M, S, let L=L^10, M=M^10, and S=S^10. Then apply this matrix

4.4679 -3.5873 0.1193
-1.2186 2.3809 -0.1624
0.0497 -0.2439 1.2045