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.

 Doom9's Forum Apply two 3x3 matrices to each pixel?
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 21st January 2015, 04:54 #1  |  Link MrPete Registered User     Join Date: Dec 2014 Location: @2100m in Colorado USA Posts: 55 Apply two 3x3 matrices to each pixel? What I want: For each pixel of each frame { // Transform the (R, G, B) values by doing two matrix // transformatoins: A = (R * ConstRa) + (G * ConstGa) + (B * ConstBa) B = (R * ConstRb) + (G * ConstGb) + (B * ConstBb) C = (R * ConstRc) + (G * ConstGc) + (B * ConstBc) pxR' = (A * ConstAr) + (B * ConstBr) + (C * ConstCr) pxG' = (A * ConstAg) + (B * ConstBg) + (C * ConstCg) pxB' = (A * ConstAb) + (B * ConstBb) + (C * ConstCb) pxRGB = (pxR', pxG', pxB') } I have not found such a plugin/function... seems like it MUST already exist... Any ideas? PS: Why... for arbitrary colorspace conversion using known (rgb)->xyz, xyz -> (r'g'b') matrices In my case, I've captured video on my wive's Nikon DSLR in Adobe RGB, and want to convert back to normal sRGB... Thanks! Pete
 21st January 2015, 05:56 #2  |  Link poisondeathray Registered User   Join Date: Sep 2007 Posts: 3,586 Maybe ManualColorMatrix ? http://forum.doom9.org/showthread.php?t=161777 Or one of the 3DLut functions like t3dlut, with a custom LUT EDIT: It looks like yCMS supports AdobeRGB , sRGB, R'G'B' and the regular 709/601 YUV, so you could generate a LUT with yCMS Last edited by poisondeathray; 21st January 2015 at 07:17.
 25th February 2015, 13:45 #3  |  Link MrPete Registered User     Join Date: Dec 2014 Location: @2100m in Colorado USA Posts: 55 Got waylaid by the ice (2 broken ribs, ouch!) then a trip to the Netherlands (yay!) So... First idea -- ManualColorMatrix() would work except it truncates the intermediate results. Now I'm thinking about eliminating the intermediate. It's been too long since I did matrix math at school... Anybody remember off the top of their head how to combine two matrix operations into one? So I have the following: Cxyz = Crgb * (3 x 3 matrix RGBxyz) Crgb' = Cxyz * (3 x 3 matrix XYZrgb') (All matrices nicely provided at http://www.brucelindbloom.com/index....YZ_Matrix.html) Bottom Line Question for solution #1: How do I calculate the direct (3x3?) matrix for Crgb -> Crgb' conversion? Idea #2 - yCMS. Interesting! (For future readers, look here: http://yesgrey.com/ycms.html) I've got some playing to do on that one... will return with what it takes to make it work in a bit... THANKS MUCHLY!!!!
 26th February 2015, 03:33 #4  |  Link colours Registered User     Join Date: Mar 2014 Posts: 312 See: https://en.wikipedia.org/wiki/Matrix...quare_matrices. (I could explain it in words, but I guess it's easier to see a concrete example.) If you want, you can also feed your matrices to WolframAlpha and let WA multiply the matrices for you. Also, you have to be careful about whether you're left-multiplying or right-multiplying the matrices, and the order you're multiplying the two transition matrices. Your equations seem to suggest that you're working with row vectors, so you have to take the transpose of the matrices given in that RGB/XYZ Matrices page. __________________ Say no to AviSynth 2.5.8 and DirectShowSource!
 27th February 2015, 05:33 #5  |  Link MrPete Registered User     Join Date: Dec 2014 Location: @2100m in Colorado USA Posts: 55 Thanks, colours! Good reminder. Well, yCMS turned out to be a quick and relatively painless solution. a) Install tritical's t3dlut plugin, and go get yCMS (standalone exe package) b) Define the following control file for yCMS: # Example input file for yCMS v1.0 and up # # Convert 8 bit Adobe RGB to sRGB (HD resolutions) # Set input format Input_Format HD RGB_PC 8 # Set output format Output_Format HD RGB_PC 8 # define input Adobe RGB Input_Primaries 4 Input_Transfer_Function 5 #define output sRGB Output_Primaries 0 Output_Transfer_Function 0 c) Run yCMS "mycontrolfile.txt" my3dlutfile d) Include this plugin call in avs: c.t3dlut("my3dlutfile.3dlut") Done.