<a id="white-balance"></a>

# White Balance

This code snippet shows how to perform white balance.

## C++

```cpp
#include <eVision/EasyColor/EColorLookup.h>
#include <eVision/EasyImage/EImageStatisticsC24.h>
```

```cpp
using namespace eVision;
// Images constructor
EImageC24 srcImage, dstImage;
EImageC24 whiteRef;
// ...
// Create a lookup table
EColorLookup lut;
// Measure the calibration values from a white reference image
EImageStatisticsC24 stats;
stats.SetImage(&whiteRef);
std::vector<float> rgb = stats.GetPixelAverage();
// Prepare the lookup table for
// a white balance operation
lut.WhiteBalance(1.00f, EasyColor::GetCompensateNtscGamma(), rgb[0], rgb[1], rgb[2]);
// Source and destination images must have the same size
dstImage.SetSize(&srcImage);
// Perform the white balance operation
lut.Transform(&srcImage, &dstImage);
```

#### SEE ALSO
[`EImageStatisticsC24::GetPixelAverage`](../../../../doxygen_cpp/classeVision_1_1EImageStatisticsC24.html#aed2ea60588b14d82de0fb9bb3a6e18cd) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EImageStatisticsC24.html#a5fd65773badf830f3175999e43cf8024) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EImageStatisticsC24.html#aa113115d2b44666a26d3a8d7e387f534), [`EColorLookup::WhiteBalance`](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a9213e20183c85ed5ca424bba010633f2) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac83a475139511222037d72a9d8ff7698) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EColorLookup.html#ad0b8f8201504f69c18de48d45f698a16), [`EColorLookup::Transform`](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a7c7b269b92e47a2f9ea104f82f597a28) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac637fc0f06f6da5c84f337bc83bb7362) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EColorLookup.html#aa1710acfb821cbfae908e2003d37318c)

## C#

```cs
using eVision;
```

```cs
// Images constructor
EImageC24 srcImage = new EImageC24();
EImageC24 dstImage = new EImageC24();
EImageC24 whiteRef = new EImageC24();
// ...
// Create a lookup table
EColorLookup lut = new EColorLookup();
// Measure the calibration values from a white reference image
EImageStatisticsC24 stats = new EImageStatisticsC24();
stats.SetImage(whiteRef);
float[] rgb = stats.PixelAverage;
// Prepare the lookup table for
// a white balance operation
lut.WhiteBalance(1.00f, EasyColor.CompensateNtscGamma, rgb[0], rgb[1], rgb[2]);
// Source and destination images must have the same size
dstImage.SetSize(srcImage);
// Perform the white balance operation
lut.Transform(srcImage, dstImage);
```

#### SEE ALSO
[`EImageStatisticsC24.PixelAverage`](../../../../doxygen_cs/classeVision_1_1EImageStatisticsC24.html#a5fd65773badf830f3175999e43cf8024) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EImageStatisticsC24.html#aed2ea60588b14d82de0fb9bb3a6e18cd) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EImageStatisticsC24.html#aa113115d2b44666a26d3a8d7e387f534), [`EColorLookup.WhiteBalance`](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac83a475139511222037d72a9d8ff7698) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a9213e20183c85ed5ca424bba010633f2) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EColorLookup.html#ad0b8f8201504f69c18de48d45f698a16), [`EColorLookup.Transform`](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac637fc0f06f6da5c84f337bc83bb7362) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a7c7b269b92e47a2f9ea104f82f597a28) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EColorLookup.html#aa1710acfb821cbfae908e2003d37318c)

## Python

```py
import eVision
# Images constructor
src_image = eVision.EImageC24()
dst_image = eVision.EImageC24()
white_ref = eVision.EImageC24()
# ...
# Create a lookup table
lut = eVision.EColorLookup()
# Measure the calibration values from a white reference image
stats = eVision.EImageStatisticsC24()
stats.SetImage(white_ref)
rgb = stats.PixelAverage
# Prepare the lookup table for
# a white balance operation
lut.WhiteBalance(1.00, eVision.EasyColor.GetCompensateNtscGamma(), rgb[0], rgb[1], rgb[2])
# Source and destination images must have the same size
dst_image.SetSize(src_image)
# Perform the white balance operation
lut.Transform(src_image, dst_image)
```

#### SEE ALSO
[`EImageStatisticsC24.PixelAverage`](../../../../doxygen_python/classeVision_1_1EImageStatisticsC24.html#aa113115d2b44666a26d3a8d7e387f534) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EImageStatisticsC24.html#aed2ea60588b14d82de0fb9bb3a6e18cd) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EImageStatisticsC24.html#a5fd65773badf830f3175999e43cf8024), [`EColorLookup.WhiteBalance`](../../../../doxygen_python/classeVision_1_1EColorLookup.html#ad0b8f8201504f69c18de48d45f698a16) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a9213e20183c85ed5ca424bba010633f2) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac83a475139511222037d72a9d8ff7698), [`EColorLookup.Transform`](../../../../doxygen_python/classeVision_1_1EColorLookup.html#aa1710acfb821cbfae908e2003d37318c) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EColorLookup.html#a7c7b269b92e47a2f9ea104f82f597a28) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EColorLookup.html#ac637fc0f06f6da5c84f337bc83bb7362)
