trans_from_rgb 转换图像RGB到任意颜色空间
- trans_from_rgb(ImageRed, ImageGreen, ImageBlue : ImageResult1, ImageResult2, ImageResult3 : ColorSpace : )
复制代码
支持图像类型:byte, uint2, int4, real(real类型下图像值只能是0和1,否则结果不可预料)
颜色空间:
'yiq'
取值范围:
'yuv'
取值范围:
'argyb'
取值范围:
'ciexyz'
所使用的原色sRGB分别对应于CIE Rec. 709以及用作白点D65。
使用的原色(x,y,z):
取值范围:
'hls'
- Min := min([R, G, B])
- Max := max([R, G, B])
- L := (Min + Max) / 2
- if (Max == Min)
- H := 0
- S := 0
- else
- if (L > 0.5)
- S := (Max - Min) / (2 - Max - Min)
- else
- S := (Max - Min) / (Max + Min)
- endif
- if (R == Max)
- H := ((G - B) / (Max - Min)) * rad(60)
- elseif (G == Max)
- H := (2 + (B - R) / (Max - Min)) * rad(60)
- elseif (B == Max)
- H := (4 + (R - G) / (Max - Min)) * rad(60)
- endif
- endif
复制代码
取值范围:
'hsi'
取值范围:
'hsv'
- Min := min([R, G, B])
- Max := max([R, G, B])
- V := Max
- if (Max == Min)
- S := 0
- H := 0
- else
- S := (Max - Min) / Max
- if (R == Max)
- H := ((G - B) / (Max - Min)) * rad(60)
- elseif (G == Max)
- H := (2 + (B - R) / (Max - Min)) * rad(60)
- elseif (B == Max)
- H := (4 + (R - G) / (Max - Min)) * rad(60)
- endif
- endif
复制代码
取值范围:
'ihs'
- Min := min([R, G, B])
- Max := max([R, G, B])
- I := (R + G + B) / 3
- if (I == 0)
- H := 0
- S := 1
- else
- S := 1 - Min / I
- if (S == 0)
- H := 0
- else
- X := (R + R - G - B) / 2
- Y := (R - G) * (R - G) + (R - B) * (G - B)
- Z := sqrt(Y)
- if (Z == 0)
- H := 0
- else
- H := acos(X / Z)
- endif
- if (B > G)
- H := rad(360) - H
- endif
- endif
- endif
复制代码
取值范围:
'cielab'
其中
- f(t) = t^(1/3), t > (24/116)^3
- f(t) = (841/108)*t + 16/116, otherwise.
- 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)
复制代码
取值范围:
'cielchab'
其中
- f(t) = t^(1/3), t > (24/116)^3
- f(t) = (841/108)*t + 16/116, otherwise.
- h_ab lies between 0° and 90° if a and b are both positive,
- between 90° and 180° if a is negative and b is positive,
- between 180° and 270° if a and b are both negative, and
- between 270° and 360° if a is positive and b is negative.
- 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)
复制代码
取值范围:
'cieluv'
其中
- f(t) = t^(1/3), t > (24/116)^3
- f(t) = (841/108)*t + 16/116, otherwise.
- 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)
复制代码
取值范围:
'cielchuv'
其中
- f(t) = t^(1/3), t > (24/116)^3
- f(t) = (841/108)*t + 16/116, otherwise.
- h_uv lies between 0° and 90° if u and v are both positive,
- between 90° and 180° if u is negative and v is positive,
- between 180° and 270° if u and v are both negative, and
- between 270° and 360° if u is positive and v is negative.
- 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)
复制代码
取值范围:
'i1i2i3'
取值范围:
'ciexyz2'
取值范围:
'ciexyz3'
取值范围:
'ciexyz4'
使用的原色(x, y, z)
取值范围:
'lms'
从概念上讲,这是从RGB到CIEXYZ的转换(见上面的"CIEXYZ"),然后是从CIEXYZ到LMS的转换。
取值范围:
参考例子:
- 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)
复制代码 |