trans_to_rgbtrans_to_rgbTransToRgbTransToRgbtrans_to_rgb (算子)

名称

trans_to_rgbtrans_to_rgbTransToRgbTransToRgbtrans_to_rgb — 将图像从任意色彩空间变换到 RGB 色彩空间。

签名

trans_to_rgb(ImageInput1, ImageInput2, ImageInput3 : ImageRed, ImageGreen, ImageBlue : ColorSpace : )

Herror trans_to_rgb(const Hobject ImageInput1, const Hobject ImageInput2, const Hobject ImageInput3, Hobject* ImageRed, Hobject* ImageGreen, Hobject* ImageBlue, const char* ColorSpace)

Herror T_trans_to_rgb(const Hobject ImageInput1, const Hobject ImageInput2, const Hobject ImageInput3, Hobject* ImageRed, Hobject* ImageGreen, Hobject* ImageBlue, const Htuple ColorSpace)

void TransToRgb(const HObject& ImageInput1, const HObject& ImageInput2, const HObject& ImageInput3, HObject* ImageRed, HObject* ImageGreen, HObject* ImageBlue, const HTuple& ColorSpace)

HImage HImage::TransToRgb(const HImage& ImageInput2, const HImage& ImageInput3, HImage* ImageGreen, HImage* ImageBlue, const HString& ColorSpace) const

HImage HImage::TransToRgb(const HImage& ImageInput2, const HImage& ImageInput3, HImage* ImageGreen, HImage* ImageBlue, const char* ColorSpace) const

HImage HImage::TransToRgb(const HImage& ImageInput2, const HImage& ImageInput3, HImage* ImageGreen, HImage* ImageBlue, const wchar_t* ColorSpace) const   ( Windows only)

static void HOperatorSet.TransToRgb(HObject imageInput1, HObject imageInput2, HObject imageInput3, out HObject imageRed, out HObject imageGreen, out HObject imageBlue, HTuple colorSpace)

HImage HImage.TransToRgb(HImage imageInput2, HImage imageInput3, out HImage imageGreen, out HImage imageBlue, string colorSpace)

def trans_to_rgb(image_input_1: HObject, image_input_2: HObject, image_input_3: HObject, color_space: str) -> Tuple[HObject, HObject, HObject]

描述

trans_to_rgbtrans_to_rgbTransToRgbTransToRgbTransToRgbtrans_to_rgb transforms an image from an arbitrary color space (ColorSpaceColorSpaceColorSpaceColorSpacecolorSpacecolor_space) to the RGB color space. The three channels of the image are passed as three separate images on input and output.

算子 trans_to_rgbtrans_to_rgbTransToRgbTransToRgbTransToRgbtrans_to_rgb supports the image types byte, uint2, int4, and real. The domain of the input images must match the domain provided by a corresponding transformation with trans_from_rgbtrans_from_rgbTransFromRgbTransFromRgbTransFromRgbtrans_from_rgb。If not, the results of the transformation may not be reasonable.

This includes some scalings in the case of certain image types and transformations:

Supported are the transformations listed below. Note, all domains are based on RGB values scaled to [0; 1]. To obtain the domain of a certain image type, they must be scaled accordingly with the value range. Due to different precision the values obtained using the given equations may slightly differ from the values returned by the operator.

'yiq'

Domain:

'yuv'

Note, this implies that , , and are not independent of each other.

Domain:

'argyb'

Domain:

'ciexyz'

Domain:

'cielab'

Black point B: (Rb, Gb, Bb) = (0, 0, 0) White point W = (Rw, Gw, Bw), according to image type: byte:=(255, 255, 255), uint2:=(2^16-1, 2^16-1, 2^16-1), int4:=(2^31-1, 2^31-1, 2^31-1), real:=(1.0, 1.0, 1.0)

Domain:

(Scaled to the maximum gray value in the case of byte and uint2. In the case of int4 L and a are scaled to the maximum gray value, b is scaled to the minimum gray value, such that the origin stays at 0.)

'cielchab'

Black point B: (Rb, Gb, Bb) = (0, 0, 0) White point W = (Rw, Gw, Bw), according to image type: byte:=(255, 255, 255), uint2:=(2^16-1, 2^16-1, 2^16-1), int4:=(2^31-1, 2^31-1, 2^31-1), real:=(1.0, 1.0, 1.0)

Domain:

(Scaled to the maximum gray value in the case of byte and uint2. In the case of int4, L and C are scaled to the maximum gray value, while h is given in seconds of arc.)

'cieluv'

Black point B: (Rb, Gb, Bb) = (0, 0, 0) White point W = (Rw, Gw, Bw), according to image type: byte:=(255, 255, 255), uint2:=(2^16-1, 2^16-1, 2^16-1), int4:=(2^31-1, 2^31-1, 2^31-1), real:=(1.0, 1.0, 1.0)

Domain:

(Scaled to the maximum gray value in the case of byte and uint2. In the case of int4 L and u are scaled to the maximum gray value, v is scaled to the minimum gray value, such that the origin stays at 0.)

'cielchuv'

Black point B: (Rb, Gb, Bb) = (0, 0, 0) White point W = (Rw, Gw, Bw), according to image type: byte:=(255, 255, 255), uint2:=(2^16-1, 2^16-1, 2^16-1), int4:=(2^31-1, 2^31-1, 2^31-1), real:=(1.0, 1.0, 1.0)

Domain:

(Scaled to the maximum gray value in the case of byte and uint2. In the case of int4, L and C are scaled to the maximum gray value, while h is given in seconds of arc.)

'hls'

Hi := floor(H/rad(60)) Hf := H/rad(60) - Hi if (L <= 0.5) Max := L * (S + 1) else Max := L + S - (L * S) endif Min := 2 * L - Max if (S == 0) R := L G := L B := L else if (Hi == 0) R := Max G := Min + Hf * (Max - Min) B := Min elseif (Hi == 1) R := Min + (1 - Hf) * (Max - Min) G := Max B := Min elseif (Hi == 2) R := Min G := Max B := Min + Hf * (Max - Min) elseif (Hi == 3) R := Min G := Min + (1 - Hf) * (Max - Min) B := Max elseif (Hi == 4) R := Min + Hf * (Max - Min) G := Min B := Max elseif (Hi == 5) R := Max G := Min B := Min + (1 - Hf) * (Max - Min) endif endif

Domain:

'hsi'

Range of values:

'hsv'

if (S == 0) R := V G := V B := V else Hi := floor(H/rad(60)) Hf := H/rad(60) - Hi if (Hi == 0) R := V G := V * (1 - (S * (1 - Hf))) B := V * (1 - S) elseif (Hi == 1) R := V * (1 - (S * Hf)) G := V B := V * (1 - S) elseif (Hi == 2) R := V * (1 - S) G := V B := V * (1 - (S * (1 - Hf))) elseif (Hi == 3) R := V * (1 - S) G := V * (1 - (S * Hf)) B := V elseif (Hi == 4) R := V * (1 - (S * (1 - Hf))) G := V * (1 - S) B := V elseif (Hi == 5) R := V G := V * (1 - S) B := V * (1 - (S * Hf)) endif endif

Domain:

'ciexyz4'

Domain:

'lms'

Domain:

注意

As the calculations are made with a different numerical precision, the OpenCL implementation of the cielab transformation for images of type int4 is slightly less accurate than the pure C version.

执行信息

参数

ImageInput1ImageInput1ImageInput1ImageInput1imageInput1image_input_1 (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / uint2 / int4 / real)

输入图像(通道 1 )。

ImageInput2ImageInput2ImageInput2ImageInput2imageInput2image_input_2 (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / uint2 / int4 / real)

输入图像(通道 2 )。

ImageInput3ImageInput3ImageInput3ImageInput3imageInput3image_input_3 (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / uint2 / int4 / real)

输入图像(通道 3 )。

ImageRedImageRedImageRedImageRedimageRedimage_red (输出对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject * (byte / uint2 / int4 / real)

Red channel.

ImageGreenImageGreenImageGreenImageGreenimageGreenimage_green (输出对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject * (byte / uint2 / int4 / real)

Green channel.

ImageBlueImageBlueImageBlueImageBlueimageBlueimage_blue (输出对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject * (byte / uint2 / int4 / real)

Blue channel.

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

Color space of the input image.

默认值: 'hsv' "hsv" "hsv" "hsv" "hsv" "hsv"

值列表: 'argyb'"argyb""argyb""argyb""argyb""argyb", 'cielab'"cielab""cielab""cielab""cielab""cielab", 'cielchab'"cielchab""cielchab""cielchab""cielchab""cielchab", 'cielchuv'"cielchuv""cielchuv""cielchuv""cielchuv""cielchuv", 'cieluv'"cieluv""cieluv""cieluv""cieluv""cieluv", 'ciexyz'"ciexyz""ciexyz""ciexyz""ciexyz""ciexyz", 'ciexyz4'"ciexyz4""ciexyz4""ciexyz4""ciexyz4""ciexyz4", 'hls'"hls""hls""hls""hls""hls", 'hsi'"hsi""hsi""hsi""hsi""hsi", 'hsv'"hsv""hsv""hsv""hsv""hsv", 'lms'"lms""lms""lms""lms""lms", 'yiq'"yiq""yiq""yiq""yiq""yiq", 'yuv'"yuv""yuv""yuv""yuv""yuv"

List of values (for compute devices): 'cielab'"cielab""cielab""cielab""cielab""cielab", 'cielchab'"cielchab""cielchab""cielchab""cielchab""cielchab", 'cieluv'"cieluv""cieluv""cieluv""cieluv""cieluv", 'cielchuv'"cielchuv""cielchuv""cielchuv""cielchuv""cielchuv", 'hsv'"hsv""hsv""hsv""hsv""hsv", 'hsi'"hsi""hsi""hsi""hsi""hsi"

示例(HDevelop)

* Transformation from rgb to hsv and conversely
read_image(Image,'patras')
dev_display(Image)
decompose3(Image, Image1, Image2, Image3)
trans_from_rgb(Image1,Image2,Image3,ImageH,ImageS,ImageV,'hsv')
trans_to_rgb(ImageH,ImageS,ImageV,ImageR,ImageG,ImageB,'hsv')
compose3(ImageR,ImageG,ImageB,Multichannel)
dev_display(Multichannel)

示例(C)

/* Transformation from rgb to hsv and conversely */
read_image(Image,"patras");
disp_color(Image,WindowHandle);
decompose3(Image,&Rimage,&Gimage,&Bimage);
trans_from_rgb(Rimage,Gimage,Bimage,&Image1,&Image2,&Image3,"hsv");
trans_to_rgb(Image1,Image2,Image3,&ImageRed,&ImageGreen,&ImageBlue,"hsv");
compose3(ImageRed,ImageGreen,ImageBlue,&Multichannel);
disp_color(Multichannel,WindowHandle);

示例(HDevelop)

* Transformation from rgb to hsv and conversely
read_image(Image,'patras')
dev_display(Image)
decompose3(Image, Image1, Image2, Image3)
trans_from_rgb(Image1,Image2,Image3,ImageH,ImageS,ImageV,'hsv')
trans_to_rgb(ImageH,ImageS,ImageV,ImageR,ImageG,ImageB,'hsv')
compose3(ImageR,ImageG,ImageB,Multichannel)
dev_display(Multichannel)

示例(HDevelop)

* Transformation from rgb to hsv and conversely
read_image(Image,'patras')
dev_display(Image)
decompose3(Image, Image1, Image2, Image3)
trans_from_rgb(Image1,Image2,Image3,ImageH,ImageS,ImageV,'hsv')
trans_to_rgb(ImageH,ImageS,ImageV,ImageR,ImageG,ImageB,'hsv')
compose3(ImageR,ImageG,ImageB,Multichannel)
dev_display(Multichannel)

示例(HDevelop)

* Transformation from rgb to hsv and conversely
read_image(Image,'patras')
dev_display(Image)
decompose3(Image, Image1, Image2, Image3)
trans_from_rgb(Image1,Image2,Image3,ImageH,ImageS,ImageV,'hsv')
trans_to_rgb(ImageH,ImageS,ImageV,ImageR,ImageG,ImageB,'hsv')
compose3(ImageR,ImageG,ImageB,Multichannel)
dev_display(Multichannel)

结果

trans_to_rgbtrans_to_rgbTransToRgbTransToRgbTransToRgbtrans_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>)。如有必要,则抛出异常。

可能的前趋

decompose3decompose3Decompose3Decompose3Decompose3decompose3

可能的后继

compose3compose3Compose3Compose3Compose3compose3, disp_colordisp_colorDispColorDispColorDispColordisp_color

替代

linear_trans_colorlinear_trans_colorLinearTransColorLinearTransColorLinearTransColorlinear_trans_color

另见

decompose3decompose3Decompose3Decompose3Decompose3decompose3

参考文献

ITU-R BT.470-6: “Conventional Television Systems”, 1998.
ISO 11664-4:2008: “Colorimetry --- Part 4: CIE 1976 L*a*b* Colour space”, 2008.
ISO 11664-5:2009: “Colorimetry --- Part 5: CIE 1976 L*u*v* Colour space and u',v' uniform chromaticity scale diagram”, 2009.

模块

基础