Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th October 2009, 20:22   #1  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
RGB to XYZ colorspace conversion

Hi folks!

I am trying to create content for D-cinema.
Therefor I need to do colorspace conversion to XYZ colorspace.
I found these RGB/XYZ Matrices but do not really know how to use the values...
Does anybody have a clue?

All the best!

SwK
elmarikon is offline   Reply With Quote
Old 15th October 2009, 02:29   #2  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
It's easy.. just do the calculations.

Code:
[X Y Z] = [R G B][a b c]
                 [d e f]
                 [g h i]

X = (R * a) + (G * d) + (B * g)
Y = (R * b) + (G * e) + (B * h)
Z = (R * c) + (G * f) + (B * i)
The matrix M, shown below, is the RGB -> XYZ matrix for a given working space. Scroll down on that page you were on and you'll see the matrix M you need to use

Code:
    [a b c]
M = [d e f]
    [g h i]

Adobe RGB -> XYZ matrix:

    [0.5767309 0.2973769 0.0270343]
M = [0.1855540 0.6273491 0.0706872]
    [0.1881852 0.0752741 0.9911085]

[X Y Z] = [R G B] M

X = (R * 0.5767309) + (G * 0.1855540) + (B * 0.1881852)
Y = (R * 0.2973769) + (G * 0.6273491) + (B * 0.0752741)
Z = (R * 0.0270343) + (G * 0.0706872) + (B * 0.9911085)
Understand now?
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 15th October 2009, 15:08   #3  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
Okay, thanx for this explanation!
I do understand this now, I guess...
Now I am to ty out which plugin to use for this case...

thank u!
elmarikon is offline   Reply With Quote
Old 15th October 2009, 15:25   #4  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Your input colorspace is probably sRGB and not Adobe RGB.

And you may need to linearize the sRGB, by applying a reverse gamma of 2.2, and some special cases for very small values:

http://en.wikipedia.org/wiki/SRGB

The linearized sRGB to XYZ is:

Code:
 0.4124564  0.2126729  0.0193339
 0.3575761  0.7151522  0.1191920
 0.1804375  0.0721750  0.9503041
(Moved to general development)
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 15th October 2009 at 15:27.
sh0dan is offline   Reply With Quote
Old 16th October 2009, 12:37   #5  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
ooookay...

so I was trying to get that all into a avisynth script, but with minor success..:-(

I could not figure out how to combine e.g. X = (R * 0.5767309) + (G * 0.1855540) + (B * 0.1881852) into one new channel...

this is my script right now:
Code:
vid = Mpeg2source("...").ConvertToRGB24

vidx = RGBAdjust(vid,0.4124564,0.3575761,0.1803475)
vidy = RGBAdjust(vid,0.2126729,0.7151522,0.0721750)
vidz = RGBAdjust(vid,0.0193339,0.1191920,0.9503041)

MergeRGB(vidx,vidy,vidz,"RGB24")

The result is just a little more bluish, then the source...
I guess, it's not that easy, right?!


I attached an image in RGB (the original) and one in xyz colorspace.
The xyz should of cause in the end look the same as the rgb, but since IrfanView or sth. can't deal with xyz it looks LSD-ish:-)
So, I will have to change the colors to make it look as freaky as the xyz image...

for your help!
Attached Images
  
elmarikon is offline   Reply With Quote
Old 16th October 2009, 20:49   #6  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Avisynth does not support XYZ as far as I know, and if you intend on doing anything serious involving that colorspace, you'll need to get someone (or do it yourself) to add support for XYZ output in avisynth.

Otherwise, your efforts will be (unfortunately) fruitless, since avisynth is limited to YVx and RGB color spaces.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 20th October 2009, 13:10   #7  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
Rite...
I know about that, but by simply recoloring the images, I guess it must be possible to achieve the goal of having some kind of 'fake xyz' or am I wrong?

Has no one got an idea?
elmarikon is offline   Reply With Quote
Old 22nd October 2009, 04:02   #8  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Sure, you can adjust it so it's

R = X
G = Y
B = Z

But I don't see how that would be useful at all for you, especially since you can't output XYZ from avisynth without writing a plugin.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 23rd October 2009, 13:32   #9  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
So, the idea was to recolor
R-->X
G-->Y
B-->Z

export as raw images or tiffs and interpret as xyz colorspace afterwards.
But I just can't figure out how to recolor properly...
what do u think??
elmarikon is offline   Reply With Quote
Reply

Tags
cinema, colormatrix, colorspace, d-cinema, xyz

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.