Ask Your Question
0

How to Linearise an Input Image before applying Color Correction?

asked 2015-04-16 04:43:27 -0600

updated 2015-04-16 05:20:30 -0600

Hi Guys!

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.

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

  2. 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:

  1. 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.

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

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

  4. 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)

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

Any suggestion or References is greatly appreciated!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-16 05:49:39 -0600

kbarni gravatar image

I don't think the gamma value is important. If you do the color matching correctly, the gray patches (last row) will set correctly the image gamma.

Try to make simply a histogram matching between the two photos of the Macbeth chart, then apply this to all the images. Maybe it will work in RGB, but it might be better to work in HSV, Lab or YUV color spaces.

See description of the method, a simple implementation and a more complex implementation.

I know there is a histogram comparison function in OpenCV (compareHist), but I don't know if there is a function for histogram matching too.

edit flag offensive delete link more

Comments

Hi @kbarni

First Thank your for your answer & Time!

But your assumption on "I don't think the gamma value is important. If you do the color matching correctly" is wrong. Please refer this & Here.

Your idea of Applying global 1)& 2) Histogram matching may work for similar images & not for all possible colors. For 3) I'm not substituting 1 single color but i have to map this to new set of colors. May be you got my point.

Please correct me if I'm wrong!

Balaji R gravatar imageBalaji R ( 2015-04-16 06:51:57 -0600 )edit

Concerning the gamma correction, I was referring that you can estimate the gamma of a photo directly from the gray patches.

In other words, by mapping the luminosity of a photo using the correspondences between the luminosity values of the gray patches, you make the gamma correction.

kbarni gravatar imagekbarni ( 2015-04-16 09:15:33 -0600 )edit

Ya i've already tried to estimate that gamma from the Grey patches. But there are lot of deviation in that. Could you please tell me how exactly you can find gamma of a input image?

Balaji R gravatar imageBalaji R ( 2015-04-16 09:23:47 -0600 )edit

I did a similar thing a few years ago without OpenCV. The luminosity mapping was like this: Let the gray patches on the Camera have the mean values of L1,L2...L6; on the Target camera: LT1,LT2...LT6.

You want to map the luminance of a pixel from a photo of the Camera Lx, let's consider L1>Lx>L2. Then the mapped luminosity is LTx=(Lx-L2)x(LT1-LT2)/(L1-L2)+LT2.

Of course, this won't be as precise as the estimation of an exponential function, but it's fast, robust and it wiill give you a good approximation.

kbarni gravatar imagekbarni ( 2015-04-17 10:12:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-04-16 04:43:27 -0600

Seen: 1,900 times

Last updated: Apr 16 '15