cfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgbcfa_to_rgb颜色滤波阵列至红绿蓝(算子)

名称

cfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgbcfa_to_rgb — 将单通道颜色滤波阵列 CFA(Color Filter Array)图像转换为 RGB 图像。

签名

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)

void CfaToRgb(const HObject& CFAImage, HObject* RGBImage, const HTuple& CFAType, const HTuple& Interpolation)

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

HImage HImage::CfaToRgb(const char* CFAType, const char* Interpolation) const

HImage HImage::CfaToRgb(const wchar_t* CFAType, const wchar_t* Interpolation) const   ( Windows only)

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

HImage HImage.CfaToRgb(string CFAType, string interpolation)

def cfa_to_rgb(cfaimage: HObject, cfatype: str, interpolation: str) -> HObject

描述

cfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgbCfaToRgbcfa_to_rgb converts a single-channel color filter array image CFAImageCFAImageCFAImageCFAImageCFAImagecfaimage into an RGB image RGBImageRGBImageRGBImageRGBImageRGBImagergbimage. 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_rgbCfaToRgbCfaToRgbCfaToRgbcfa_to_rgb is normally used if the images are not being grabbed using the HALCON frame grabber interface (grab_imagegrab_imageGrabImageGrabImageGrabImagegrab_image or grab_image_asyncgrab_image_asyncGrabImageAsyncGrabImageAsyncGrabImageAsyncgrab_image_async), but are grabbed using function calls from the frame grabber SDK, and are passed to HALCON using gen_image1gen_image1GenImage1GenImage1GenImage1gen_image1 or gen_image1_externgen_image1_externGenImage1ExternGenImage1ExternGenImage1Externgen_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: Each gray value of the input image CFAImageCFAImageCFAImageCFAImageCFAImagecfaimage 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 CFATypeCFATypeCFATypeCFATypeCFATypecfatype. 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_partCropPartCropPartCropPartcrop_part or crop_rectangle1crop_rectangle1CropRectangle1CropRectangle1CropRectangle1crop_rectangle1).

The algorithm that is used to interpolate the RGB values is determined by the parameter InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation. For InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear'"bilinear""bilinear""bilinear""bilinear""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 InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear_dir'"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. 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 InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear_enhanced'"bilinear_enhanced""bilinear_enhanced""bilinear_enhanced""bilinear_enhanced""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'"mmx_enable""mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to 'true'"true""true""true""true""true" (and the SIMD instruction set is available), the internal calculations for byte images are performed using SIMD technology for InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear" and InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear_dir'"bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir".

For InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear" and InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation = 'bilinear_dir'"bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir", cfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgbCfaToRgbcfa_to_rgb 可在 OpenCL 设备上执行。输入图像的宽度对于 byte 图像应为 4 的倍数,对于 uint2 图像应为 2 的倍数,否则操作速度将大幅降低。

执行信息

参数

CFAImageCFAImageCFAImageCFAImageCFAImagecfaimage (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte* / uint2*) *允许用于计算设备

输入图像。

RGBImageRGBImageRGBImageRGBImageRGBImagergbimage (输出对象)  multichannel-image(-array) objectHImageHObjectHImageHobject * (byte / uint2)

输出图像。

CFATypeCFATypeCFATypeCFATypeCFATypecfatype (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Color filter array type.

默认值: 'bayer_gb' "bayer_gb" "bayer_gb" "bayer_gb" "bayer_gb" "bayer_gb"

值列表: 'bayer_bg'"bayer_bg""bayer_bg""bayer_bg""bayer_bg""bayer_bg", 'bayer_gb'"bayer_gb""bayer_gb""bayer_gb""bayer_gb""bayer_gb", 'bayer_gr'"bayer_gr""bayer_gr""bayer_gr""bayer_gr""bayer_gr", 'bayer_rg'"bayer_rg""bayer_rg""bayer_rg""bayer_rg""bayer_rg"

InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Interpolation type.

默认值: 'bilinear' "bilinear" "bilinear" "bilinear" "bilinear" "bilinear"

值列表: 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear", 'bilinear_dir'"bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir""bilinear_dir", 'bilinear_enhanced'"bilinear_enhanced""bilinear_enhanced""bilinear_enhanced""bilinear_enhanced""bilinear_enhanced"

结果

cfa_to_rgbcfa_to_rgbCfaToRgbCfaToRgbCfaToRgbcfa_to_rgb 在所有参数正确时返回 2 ( H_MSG_TRUE )。当输入为空时,可设置行为通过算子 set_system(::'no_object_result', <Result>:)set_system("no_object_result", <Result>)SetSystem("no_object_result", <Result>)SetSystem("no_object_result", <Result>)SetSystem("no_object_result", <Result>)set_system("no_object_result", <Result>)。如有必要,则抛出异常。

可能的前趋

gen_image1_externgen_image1_externGenImage1ExternGenImage1ExternGenImage1Externgen_image1_extern, gen_image1gen_image1GenImage1GenImage1GenImage1gen_image1, grab_imagegrab_imageGrabImageGrabImageGrabImagegrab_image

可能的后继

decompose3decompose3Decompose3Decompose3Decompose3decompose3

另见

trans_from_rgbtrans_from_rgbTransFromRgbTransFromRgbTransFromRgbtrans_from_rgb

模块

基础