Demosaicing, also called debayering, is performed to generate RGB information from the color output of the image sensor.
Basler color cameras always perform demosaicing, even when the pixel format is set to a Bayer format. This is due to the camera's internal image processing.
Your camera provides different methods for demosaicing. By default, the method is determined automatically based on the pixel format set.
Manually adjusting the demosaicing mode can help if the results produced by the automatically chosen method aren't satisfactory for your application.
For example, the camera automatically chooses the Nearest Neighbor method for Bayer pixel formats. This is done to ensure compatibility with older firmware versions. However, the Unilinear method often achieves better results.
Uses information from one of the closest pixels or the arithmetic mean of surrounding green pixels. This is the default method for non-Bayer pixel formats if Basler PGI isn't available.
Basler PGI
If available, uses the Basler PGI algorithm for advanced demosaicing.
Nearest Neighbor
Uses information from one of the closest pixels. This is the default method for Bayer pixel formats and provides best compatibility with previous firmware versions.
Unilinear
Uses information from one of the closest pixels or the arithmetic mean of surrounding pixels. Compared to Nearest Neighbor demosaicing, less color artifacts occur at the edges.
// Enable manual adjustment of the demosaicing methodcamera.BslDemosaicingMode.SetValue(BslDemosaicingMode_Manual);// Set the demosaicing method to Unilinearcamera.BslDemosaicingMethod.SetValue(BslDemosaicingMethod_Unilinear);
INodeMap&nodemap=camera.GetNodeMap();// Enable manual adjustment of the demosaicing methodCEnumParameter(nodemap,"BslDemosaicingMode").SetValue("Manual");// Set the demosaicing method to UnilinearCEnumParameter(nodemap,"BslDemosaicingMethod").SetValue("Unilinear");
// Enable manual adjustment of the demosaicing methodcamera.Parameters[PLCamera.BslDemosaicingMode].SetValue(PLCamera.BslDemosaicingMode.Manual);// Set the demosaicing method to Unilinearcamera.Parameters[PLCamera.BslDemosaicingMethod].SetValue(PLCamera.BslDemosaicingMethod.Unilinear);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=GENAPI_E_OK;/* Return value of pylon methods *//* Enable manual adjustment of the demosaicing method */errRes=PylonDeviceFeatureFromString(hdev,"BslDemosaicingMode","Manual");CHECK(errRes);/* Set the demosaicing method to Unilinear */errRes=PylonDeviceFeatureFromString(hdev,"BslDemosaicingMethod","Unilinear");CHECK(errRes);
# Enable manual adjustment of the demosaicing methodcamera.BslDemosaicingMode.Value="Manual"# Set the demosaicing method to Unilinearcamera.BslDemosaicingMethod.Value="Unilinear"