private void buttonReCalibrate_Click( object sender, EventArgs e )
{
// Re-Calibrate every available probe
bool ProbesHaveSaturatedValues = false;
bool ProbesMissMeasurementDisc = false;
foreach ( CameraCalibration.Probe P in m_Calibration.m_Reflectances )
if ( P.m_MeasurementDiscIsAvailable )
{
ImageUtility.float3 MinXYZ, MaxXYZ;
float BlackValues, SaturatedValues;
ImageUtility.float3 AverageXYZ = IntegrateLuminance( P.m_MeasurementCenterX, P.m_MeasurementCenterY, P.m_MeasurementRadius, out MinXYZ, out MaxXYZ, out BlackValues, out SaturatedValues );
if ( BlackValues > BLACK_VALUES_TOLERANCE || SaturatedValues > SATURATED_VALUES_TOLERANCE )
{ // Disable that probe as too many values are black or saturated
P.m_IsAvailable = false;
P.m_LuminanceMeasured = 0.0f;
ProbesHaveSaturatedValues = true;
continue;
}
// We have a valid measurement!
P.m_IsAvailable = true;
P.m_LuminanceMeasured = AverageXYZ.y;
}
else
{ // Disable probe as it has no measurement info
P.m_IsAvailable = false;
P.m_LuminanceMeasured = 0.0f;
ProbesMissMeasurementDisc = true;
}
// We now used the current image as reference for this calibration so commit its data
CommitImageToCurrentCalibration();
if ( ProbesHaveSaturatedValues )
MessageBox( "Some probes have been disabled because the luminance measurement returned too many saturated or black values!", MessageBoxButtons.OK, MessageBoxIcon.Warning );
if ( ProbesMissMeasurementDisc )
MessageBox( "Some probes can't be measured because they're missing the sampling disc information!\r\nClick the \"Calibrate\" button to place the disk and calibrate manually.", MessageBoxButtons.OK, MessageBoxIcon.Warning );
}