Measure scene illuminant using test chart
This example shows how to measure the illuminant of an eSFR chart using the gray patch ROIs. The example then white balances the image of the eSFR chart.
Read an image of an eSFR chart into the workspace.
I = imread('eSFRTestImage.jpg');
esfrChart object. Display the chart, highlighting the 20 gray patches.
chart = esfrChart(I); displayChart(chart,'displayEdgeROIs',false, ... 'displayColorROIs',false,'displayRegistrationPoints',false)
Estimate the illuminant using the gray patch ROIs. The illuminant has a stronger blue component than the red and green. This result is consistent with the image of the test chart, which has a blue tint.
illum = measureIlluminant(chart)
illum = 1×3 110.9147 116.0008 123.2339
White balance the chart image and display the result. The white balanced image has less of a blue tint, especially in the middle gray patches and over the background of the image.
J = chromadapt(I,illum); imshow(J) title('White Balanced Test Chart Image')
You can use the estimated illuminant to white balance other images acquired under similar lighting conditions.
illuminant— Scene illuminant
Scene illuminant, returned as a 3-element row vector.
 Imatest. "Esfr". https://www.imatest.com/mathworks/esfr/.
 X-Rite Photo and Video. "ColorChecker Classic". https://xritephoto.com/colorchecker-classic