This can help to optimize image quality.
This feature is available for Basler ace 2, boost R, and dart IMX cameras.
Basler ace U/L cameras also provide a
DemosaicingMode parameter but this only serves to enable the PGI Feature Set.
Using the Feature#
Why Use Demosaicing Mode#
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.
The following demosaicing methods are available:
|Demosaicing Method||Description||Suitable for Non-Bayer Pixel Formats||Suitable for Bayer Pixel Formats|
|Average Green||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.|
The following demosaicing modes are available:
- Auto: The demosaicing method is determined automatically based on the pixel format set.
- Manual: The demosaicing method can be set manually.
To change the method used for demosaicing:
- Set the
- Set the
BslDemosaicingMethodparameter to the desired demosaicing method, e.g.,
/* Macro to check for errors */ #define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc) GENAPIC_RESULT errRes = 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);
You can also use the pylon Viewer to easily set the parameters.