# How to Linearise an Input Image before applying Color Correction?

I'm doing color correction on Raw images taken from Camera directly. I want to make my Camera reproduce same colors as my Target camera.

Here are the steps I'm following:

1. Take Target Color values by Capturing a Macbeth Color chart by using Target Camera & Take set of 24 Color Palette's.
2. Take the Input Color Values by Capturing the same Macbeth Color chart by using Reference Camera & Take set of 24 Color Palette's.

Now if i Compute Color correction directly at this stage, all the White colors are appearing Rose or Not correct.

So I'm applying Gamma correction as follows:

1. Split the Three channels. For each Color find the Gamma for that color palette by using this formula.

float Gamma_R = log10(Target_R/255.0))/(log10(Input_R/255.0);

Error Cases:1

If the Input_Channel Value == 255 make it as 254

If the Input_Channel Value == 0 make it as 1

If gamma_Channel > 3 or gamma_Channel < 0.2 make gamma_Channel as 1.

• Average the Values of Gamma_R for all 24 colors & make this as a gamma of that channel.

• Apply Gamma for Each channel using the Gamma computed for Each channel using the formula.

Corrected_R = 255 * (Input_R/255)^(1/Gamma_R)

My Problem:

• How to make sure the Gamma Values that I've computed are correct at this stage? Also correct me if I'm doing it wrong.

• What to do when the Following Error case: 1 happens?

• After applying Gamma correction & Color Correction using 3x3 Matrix (Assume I'm doing that correctly) still the colors are not reproduced correctly.

• If i encode the gamma by using same Gamma Values from Previous stage using this formula, again the Colors are not reproduced correctly.

Corrected_R = 255 * (Input_R/255)^(Gamma_R)

• So do i need to compute the Gamma again from the Color corrected output?

Any suggestion or References is greatly appreciated!