title: White balance/color temperature algorithm
body: <p>I have a picture(RGB) and i wanna adjust color temperature, like in Lightroom. I try converting RGB to LAB and adjust B channel, but it's wrong. May be someone can help with sample code or algorithm of color temperature implementation?
  Like this:</p>
  <pre><code>rgb temperature(int temp, rgb color);
  </code></pre>
  <p>where value - temperature, color - input color (from image), return value - output color (adjusted)</p>
  <p>Now, I use this algorithm. RGBtoLAB and LABtoRGB I took from: <a href="http://www.easyrgb.com/index.php?X=MATH&amp;H=01#text1" rel="nofollow noreferrer">http://www.easyrgb.com/index.php?X=MATH&amp;H=01#text1</a></p>
  <pre><code>for (int i = 0; i &lt; img.pixCount; i++)
  {
      lab32f lab = RGBtoLAB(img.getPixel(i));  
      lab.b += temp.value;  // -100..100
      img.setPixel(i, LABtoRGB(lab));
  }
  </code></pre>
  <p>Result images:</p>
  <p><img src="https://i.stack.imgur.com/osGR7.jpg" alt="Result images" /></p>