[solved] Colorspace YcbCr to RGB
Posted: 2013-05-12T04:18:34-07:00
I have some YCbCr raw binary pictures and the conversion to RGB is too dark.
I was able to isolate the bug:
http://en.wikipedia.org/wiki/YCbCr#JPEG_conversion
a sample with YCbCr(127,127,127)
a neutral gray tribel YCbCr(127,127,127) goes to RGB(127,128,125)
lets try it with current Windows Version
and here the output from my old convert on my Mac OS
you see, my old convert is correct, but the current version works wrong
--
in detail: with Chroma Cb=Cr=128 goes the color matrix parts to zero, meaning R=G=B=Y
YCbCr(127,128,128) goes to RGB(127,127,127)
YCbCr(200,128,128) goes to RGB(200,127,127)
...
-------------------------------------------------
I think there is also a bug in documentation:
http://www.imagemagick.org/script/comma ... colorspace
sRGB as function of RGB ( there is shown the wrong direction)
wrong: if R ≤ .04045 then Rs=R/12.92 else Rs=((R+.055)/1.055)^2.4
right: if R ≤ 0.0031308 then Rs=R*12.92 else Rs=1.055 R ^ (1.0 / 2.4) – 0.055
etc.
I was able to isolate the bug:
http://en.wikipedia.org/wiki/YCbCr#JPEG_conversion
a sample with YCbCr(127,127,127)
Code: Select all
Y Cb Cr
127 127 127 RGB 255
R 127 0 -1,402 125,6
G 127 0,34414 0,71414 128,1
B 127 -1,772 0 125,2
lets try it with current Windows Version
Code: Select all
>convert xc:rgb(127,127,127) -set colorspace ycbcr -colorspace rgb -format "rgb(%[fx:round(255*u.r,1)],%[fx:round(255*u.g)],%[fx:round(255*u.b)])" info:
rgb(53,55,53)
>convert -version
Version: ImageMagick 6.8.5-6 2013-05-10 Q16 http://www.imagemagick.org
Code: Select all
$ convert xc:rgb\(127,127,127\) -set colorspace YCbCr -colorspace rgb -format "rgb(%[fx:round(255*u.r,1)],%[fx:round(255*u.g)],%[fx:round(255*u.b)])" info:
rgb(126,128,126)
$ convert -version
Version: ImageMagick 6.7.8-8 2012-08-09 Q16 http://www.imagemagick.org
--
in detail: with Chroma Cb=Cr=128 goes the color matrix parts to zero, meaning R=G=B=Y
YCbCr(127,128,128) goes to RGB(127,127,127)
YCbCr(200,128,128) goes to RGB(200,127,127)
...
-------------------------------------------------
I think there is also a bug in documentation:
http://www.imagemagick.org/script/comma ... colorspace
sRGB as function of RGB ( there is shown the wrong direction)
wrong: if R ≤ .04045 then Rs=R/12.92 else Rs=((R+.055)/1.055)^2.4
right: if R ≤ 0.0031308 then Rs=R*12.92 else Rs=1.055 R ^ (1.0 / 2.4) – 0.055
etc.