Please enable JavaScript to view this site.

IDS peak 2.8.0 / uEye+ firmware 3.33

hint_info

For a general introduction to color correction, see the "Color Correction" chapter.

Querying the color correction matrix of the camera

The camera provides its color correction values via the XML tree. The correction can be done either by the camera itself or in IDS peak. This depends on where color calculation (debayering) is done, because color correction has to be done after color calculation.

The values (double) of the 3x3 matrix are named as follows:

gain_0_0

gain_0_1

gain_0_2

gain_1_0

gain_1_1

gain_1_2

gain_2_0

gain_2_1

gain_2_2

You can choose a predefined matrix or a user-defined matrix via ColorCorrectionMatrixValueSelector.

hint_info

You must stop image acquisition if you want to change the enumeration nodes.

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
status = peak_ColorCorrection_Mode_Set(hCam, PEAK_COLOR_CORRECTION_MODE_HQ);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
peak_matrix colorCorrectionMatrix;
status = peak_ColorCorrection_Matrix_Get(hCam, &colorCorrectionMatrix);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

genericC++

// Set the color correction matrix selector to the predefined HQ matrix
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrix")->SetCurrentEntry("HQ");
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain00");
auto gain_0_0 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain01");
auto gain_0_1 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain02");
auto gain_0_2 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain10");
auto gain_1_0 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain11");
auto gain_1_1 = nodemapRemoteDevice->FindNode<peak::peak::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain12");
auto gain_1_2 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain20");
auto gain_2_0 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain21");
auto gain_2_1 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain22");
auto gain_2_2 = nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->Value();

Setting any color correction matrix in the camera

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
status = peak_ColorCorrection_Mode_Set(hCam, PEAK_COLOR_CORRECTION_MODE_USER_1);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
peak_matrix m;
m.elementArray[0][0] = 2; m.elementArray[0][1] = 1; m.elementArray[0][2] = 1;
m.elementArray[1][0] = 1; m.elementArray[1][1] = 2; m.elementArray[1][2] = 1;
m.elementArray[2][0] = 1; m.elementArray[2][1] = 1; m.elementArray[2][2] = 2;
 
status = peak_ColorCorrection_Matrix_Set(hCam, m);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

genericC++

// Set the color correction matrix selector to Custom0
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrix")->SetCurrentEntry("Custom0");
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain00");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(1);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain01");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain02");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain10");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain11");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(1);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain12");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain20");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain21");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(0);
 
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMatrixValueSelector")->SetCurrentEntry("Gain22");
nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ColorCorrectionMatrixValue")->SetValue(1);

Activating or deactivating color correction in the camera

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
status = peak_ColorCorrection_Enable(hCam, PEAK_TRUE);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
status = peak_ColorCorrection_Enable(hCam, PEAK_FALSE);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

genericC++

// Disable color correction
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMode")->SetCurrentEntry("Off");
 
// Enable color correction if matching pixel format is set
nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("ColorCorrectionMode")->SetCurrentEntry("Auto");

Color correction in IDS peak IPL

When using a Bayer format with color calculation in IDS peak IPL (host software), the color correction must be performed afterwards in IDS peak IPL as well. You can read out the HQ matrix as described above and then pass it to the ColorCorrector in IDS peak IPL. For correction, pass the image to be corrected to the ColorCorrector.

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
peak_matrix m;
status = peak_IPL_ColorCorrection_Matrix_Get(hCam, &m);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
status = peak_IPL_ColorCorrection_Matrix_Set(hCam, m);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
status = peak_IPL_ColorCorrection_Enable(hCam, PEAK_TRUE);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
status = peak_IPL_ColorCorrection_Enable(hCam, PEAK_FALSE);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

genericC++

peak::ipl::ColorCorrector m_colorCorrectorIPL;
 
auto colorCorrectionFactors = peak::ipl::ColorCorrectionFactors(gain_0_0, gain_0_1, gain_0_2,
                                                              gain_1_0, gain_1_1, gain_1_2,
                                                              gain_2_0, gain_2_1, gain_2_2);
                                   
m_colorCorrectorIPL.SetColorCorrectionFactors(colorCorrectionFactors);

genericC++

// Correct original image
m_colorCorrectorIPL.ProcessInPlace(image);
 
// Correct and return new image
auto image2 = m_colorCorrectorIPL.Process(image);

Complete example

© 2024 IDS Imaging Development Systems GmbH