Handling Missing Pixel Values Caused By Debayering#
In color cameras, the RGB values are calculated from the pixel data using a debayering (sometimes also called demosaicing) algorithm. Searching for "Bayer conversion" will show you a variety of ways to perform this. A simple conversion is shown below:
The example shows an "RG" Bayer array, where the full RGB information of each pixel is derived from the according Bayer array intensity values of the pixel and its neighboring pixels. The green intensities are averaged. As you can see, the process will run into some edge cases at the end of the frame where no more information from the neighboring pixels is available. There is no pixel on the right side and/or below the current pixel.
This happens with many complex Bayer conversions, since the information from the surrounding pixels is essential. Those situations can be treated differently in end-user solutions. For example, the application could copy the second to last pixel data into the last.
To provide full flexibility, images will be delivered with zero (0) values in borders and corners. That generates black pixels in the last row and column.
These pixels can be clipped using the following pylon C++ API converter function:
CImageFormatConverter converter; converter.OutputPixelFormat = PixelType_BGR8packed; converter.InconvertibleEdgeHandling = InconvertibleEdgeHandling_Clip;
Or using the pylon .NET API:
private PixelDataConverter converter = new PixelDataConverter(); converter.OutputPixelFormat = PixelType.BGRA8packed; converter.Parameters\[PLPixelDataConverter.InconvertibleEdgeHandling\].TrySetValue(PLPixelDataConverter.InconvertibleEdgeHandling.Clip);
The following code demonstrates the function in pylon C.NET:
PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hImageCon = Pylon.ImageFormatConverterCreate(); NODEMAP_HANDLE nodemap = Pylon.ImageFormatConverterGetNodeMap(hImageCon); NODE_HANDLE node = GenApi.NodeMapGetNode(nodemap,"InconvertibleEdgeHandling"); GenApi.NodeFromString(node,"Clip");