White Balance¶
This code snippet shows how to perform white balance.
C++¶
#include <eVision/EasyColor/EColorLookup.h>
#include <eVision/EasyImage/EImageStatisticsC24.h>
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);
C#¶
using eVision;
// 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);
Python¶
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)