cfa_to_rgb — Convert a single-channel color filter array image into an RGB image.
cfa_to_rgb converts a single-channel color filter array image CFAImage into an RGB image RGBImage. Color filter array images are typically generated by single-chip CCD cameras. The conversion from color filter array image to RGB image is typically done on the camera itself or is performed by the device driver of the frame grabber that is used to grab the image. In some cases, however, the device driver simply passes the color filter array image through unchanged. In this case, the corresponding HALCON frame grabber interface typically converts the image into an RGB image. Hence, the operator cfa_to_rgb is normally used if the images are not being grabbed using the HALCON frame grabber interface (grab_image or grab_image_async), but are grabbed using function calls from the frame grabber SDK, and are passed to HALCON using gen_image1 or gen_image1_extern.
In single-chip CCD cameras, a color filter array in front of the sensor provides (subsampled) color information. The most frequently used filter is the so-called Bayer filter. The color filter array has the following layout in this case:
The algorithm that is used to interpolate the RGB values is determined by the parameter Interpolation. For Interpolation = 'bilinear', a bilinear interpolation is performed. While this algorithm is very fast, it typically leads to “zipper-like” artifacts and color artifacts at strong edges. For Interpolation = 'bilinear_dir', a modified version of the bilinear interpolation is performed that may lead to fewer zipper-like artifacts, especially at horizontal or vertical edges in the image. The results may still exhibit color artifacts at strong edges, however. The runtime of this algorithm is only slightly longer than that of bilinear interpolation. For Interpolation = 'bilinear_enhanced', an enhanced version of the bilinear interpolation is performed that produces fewer zipper-like artifacts and color artifacts than the other two bilinear algorithms in most cases. The runtime of this algorithm is significantly longer than that of the other two algorithms.
If 'mmx_enable' is set to 'true' (and the SIMD instruction set is available), the internal calculations for byte images are performed using SIMD technology for Interpolation = 'bilinear' and Interpolation = 'bilinear_dir'.
For Interpolation = 'bilinear' and Interpolation = 'bilinear_dir', cfa_to_rgb can be executed on OpenCL devices. The width of the input image should be a multiple of four for byte images, or two for uint2 images, as the operation will be much slower otherwise.
Color filter array type.
Default value: 'bayer_gb'
List of values: 'bayer_bg', 'bayer_gb', 'bayer_gr', 'bayer_rg'
Default value: 'bilinear'
List of values: 'bilinear', 'bilinear_dir', 'bilinear_enhanced'
cfa_to_rgb returns 2 (H_MSG_TRUE) if all parameters are correct. If the input is empty the behavior can be set via set_system(::'no_object_result', <Result>:). If necessary, an exception is raised.
gen_image1_extern, gen_image1, grab_image