HALCON Reference Manual 10.0.2
Table of Contents / Filters / Color ClassesClassesClasses | | | Operators

cfa_to_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb (Operator)

Name

cfa_to_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb — Convert a single-channel color filter array image into an RGB image.

Signature

cfa_to_rgb(CFAImage : RGBImage : CFAType, Interpolation : )

Herror cfa_to_rgb(const Hobject CFAImage, Hobject* RGBImage, const char* CFAType, const char* Interpolation)

Herror T_cfa_to_rgb(const Hobject CFAImage, Hobject* RGBImage, const Htuple CFAType, const Htuple Interpolation)

Herror cfa_to_rgb(Hobject CFAImage, Hobject* RGBImage, const HTuple& CFAType, const HTuple& Interpolation)

HImage HImage::CfaToRgb(const HTuple& CFAType, const HTuple& Interpolation) const

HImageArray HImageArray::CfaToRgb(const HTuple& CFAType, const HTuple& Interpolation) const

void HOperatorSetX.CfaToRgb(
[in] IHUntypedObjectX* CFAImage, [out] IHUntypedObjectX*RGBImage, [in] VARIANT CFAType, [in] VARIANT Interpolation)

IHImageX* HImageX.CfaToRgb(
[in] BSTR CFAType, [in] BSTR Interpolation)

static void HOperatorSet.CfaToRgb(HObject CFAImage, out HObject RGBImage, HTuple CFAType, HTuple interpolation)

HImage HImage.CfaToRgb(string CFAType, string interpolation)

Description

cfa_to_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb converts a single-channel color filter array image CFAImageCFAImageCFAImageCFAImageCFAImage into an RGB image RGBImageRGBImageRGBImageRGBImageRGBImage. 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_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb is normally used if the images are not being grabbed using the HALCON frame grabber interface (grab_imagegrab_imagegrab_imageGrabImageGrabImage or grab_image_asyncgrab_image_asyncgrab_image_asyncGrabImageAsyncGrabImageAsync), but are grabbed using function calls from the frame grabber SDK, and are passed to HALCON using gen_image1gen_image1gen_image1GenImage1GenImage1 or gen_image1_externgen_image1_externgen_image1_externGenImage1ExternGenImage1Extern.

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:

     +---+---+---+---+---+---+----
     | G | B | G | B | G | B | ...
     +---+---+---+---+---+---+----
     | R | G | R | G | R | G | ...
     +---+---+---+---+---+---+----
     | G | B | G | B | G | B | ...
     +---+---+---+---+---+---+----
     | R | G | R | G | R | G | ...
     +---+---+---+---+---+---+----
     | . | . | . | . | . | . | .
     | . | . | . | . | . | . |  .
     | . | . | . | . | . | . |   .

Each gray value of the input image CFAImageCFAImageCFAImageCFAImageCFAImage corresponds to the brightness of the pixel behind the corresponding color filter. Hence, in the above layout, the pixel (0,0) corresponds to a green color value, while the pixel (0,1) corresponds to a blue color value. The layout of the Bayer filter is completely determined by the first two elements of the first row of the image, and can be chosen with the parameter CFATypeCFATypeCFATypeCFATypeCFAType. In particular, this enables the correct conversion of color filter array images that have been cropped out of a larger image (e.g., using crop_partcrop_partcrop_partCropPartCropPart or crop_rectangle1crop_rectangle1crop_rectangle1CropRectangle1CropRectangle1).

The algorithm that is used to interpolate the RGB values is determined by the parameter InterpolationInterpolationInterpolationInterpolationinterpolation. For InterpolationInterpolationInterpolationInterpolationinterpolation = 'bilinear'"bilinear""bilinear""bilinear""bilinear", a bilinear interpolation is performed. For InterpolationInterpolationInterpolationInterpolationinterpolation = 'bilinear_dir'"bilinear_dir""bilinear_dir""bilinear_dir""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.

If 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to 'true'"true""true""true""true" (and the SIMD instruction set is available), the internal calculations for byte images are performed using SIMD technology.

cfa_to_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb 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.

Parallelization

Parameters

CFAImageCFAImageCFAImageCFAImageCFAImage (input_object)  image(-array) objectHImageHImageHImageXHobject (byte* / uint2*) *allowed for compute devices

Input image.

RGBImageRGBImageRGBImageRGBImageRGBImage (output_object)  multichannel-image(-array) objectHImageHImageHImageXHobject * (byte / uint2)

Output image.

CFATypeCFATypeCFATypeCFATypeCFAType (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Color filter array type.

Default value: 'bayer_gb' "bayer_gb" "bayer_gb" "bayer_gb" "bayer_gb"

List of values: 'bayer_gb'"bayer_gb""bayer_gb""bayer_gb""bayer_gb", 'bayer_gr'"bayer_gr""bayer_gr""bayer_gr""bayer_gr", 'bayer_bg'"bayer_bg""bayer_bg""bayer_bg""bayer_bg", 'bayer_rg'"bayer_rg""bayer_rg""bayer_rg""bayer_rg"

InterpolationInterpolationInterpolationInterpolationinterpolation (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Interpolation type.

Default value: 'bilinear' "bilinear" "bilinear" "bilinear" "bilinear"

List of values: 'bilinear'"bilinear""bilinear""bilinear""bilinear", 'bilinear_dir'"bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir"

Result

cfa_to_rgbcfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgb 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>:)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). If necessary, an exception is raised.

Possible Predecessors

gen_image1_externgen_image1_externgen_image1_externGenImage1ExternGenImage1Extern, gen_image1gen_image1gen_image1GenImage1GenImage1, grab_imagegrab_imagegrab_imageGrabImageGrabImage

Possible Successors

decompose3decompose3decompose3Decompose3Decompose3

See also

trans_from_rgbtrans_from_rgbtrans_from_rgbTransFromRgbTransFromRgb

Module

Foundation


Table of Contents / Filters / Color ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH