REC709 Look-up Tables
12599 14 2- JRoberts
- Member
- 7 posts
- Joined: Oct. 2008
- Offline
- Dennis Weil
- Member
- 150 posts
- Joined: May 2011
- Offline
It would generally be nice to have some kind of LUT library. I've been trying to create them by myself in various compositing packages and also in COPs, but could never get them to work. Always had strange results.
I would also be very happy if someone could lay out a workflow for creating LUTs (that work with Houdini and Mplay) in COPs or any other package.
-dennis
I would also be very happy if someone could lay out a workflow for creating LUTs (that work with Houdini and Mplay) in COPs or any other package.
-dennis
- JRoberts
- Member
- 7 posts
- Joined: Oct. 2008
- Offline
Hi Dennis,
I have been doing some research and with the help of a post from ODForce I have found a good way to create LUT's for Houdini.
If you bring in a linear image into COPS via a file node, then append a function COP you can use the power function (x^E) to adjust the color curve accordingly using the Exponent parameter.
The only problem I am having now is that I am struggling to find a good source which explains what the exponent should be for certain lookup's such as sRGB and REC709.
So far i think a exponent of 0.45 or 1/2.2 is pretty accurate for sRGB. Some sources on the internet seem to believe that REC709 is a expoenent of 1/2.35 or 1/2.4 but this provides more of a washed out render which is opposite to what Nuke outputs which seems to be more contrasty.
If anyone can give me some further advice on what REC709 is actually doing in Nuke I would really appreciate it.
Thanks for your help and I will keep this matter updated until it is resolved.
Kind Regards
J
I have been doing some research and with the help of a post from ODForce I have found a good way to create LUT's for Houdini.
If you bring in a linear image into COPS via a file node, then append a function COP you can use the power function (x^E) to adjust the color curve accordingly using the Exponent parameter.
The only problem I am having now is that I am struggling to find a good source which explains what the exponent should be for certain lookup's such as sRGB and REC709.
So far i think a exponent of 0.45 or 1/2.2 is pretty accurate for sRGB. Some sources on the internet seem to believe that REC709 is a expoenent of 1/2.35 or 1/2.4 but this provides more of a washed out render which is opposite to what Nuke outputs which seems to be more contrasty.
If anyone can give me some further advice on what REC709 is actually doing in Nuke I would really appreciate it.
Thanks for your help and I will keep this matter updated until it is resolved.
Kind Regards
J
- axebeak
- Member
- 51 posts
- Joined: Oct. 2006
- Offline
Rec709 encoding is this:
V = 1.099*(L^0.45) - 0.099
In addition there is a linear segment for very low values of linear light:
if L < 0.018: V = 4.5L
So Rec709 exponent is 0.45 but because of the scaling and offset in the formula above it is closer to 0.5, that is square root function.
I'm attaching a scene where all these functions are plotted via VOP SOPs (you can do the same via VOPCOP filter and then save the LUT).
For the same reason (scaling and bias in the encoding formula), actual sRGB exponent is closer to 0.45 than to 0.42 (1/2.4).
Actual sRGB formulas:
V = 1.055*(L^0.42) - 0.055
if L < 0.0031308: V = 12.92L
V = 1.099*(L^0.45) - 0.099
In addition there is a linear segment for very low values of linear light:
if L < 0.018: V = 4.5L
So Rec709 exponent is 0.45 but because of the scaling and offset in the formula above it is closer to 0.5, that is square root function.
I'm attaching a scene where all these functions are plotted via VOP SOPs (you can do the same via VOPCOP filter and then save the LUT).
For the same reason (scaling and bias in the encoding formula), actual sRGB exponent is closer to 0.45 than to 0.42 (1/2.4).
Actual sRGB formulas:
V = 1.055*(L^0.42) - 0.055
if L < 0.0031308: V = 12.92L
- JRoberts
- Member
- 7 posts
- Joined: Oct. 2008
- Offline
Hi Axebreak,
Thanks for such a detailed answer. This is what I have been looking for and thanks for providing the formula as well, it is really useful to see what is going on under the ‘hood’ of the look-up table.
I have just tried to implement this into a vopcop filter and I have a couple of questions, first of all would you be using the intensity channel as your input value and the RGB values as your output in the filter.
Also when I go to save the LUT, is says the I needs to be a pixelOP node (blue node) to create a LUT? Do you know of another way of implementing this other than the vopcop filter.
Thanks again for your help this has been immensely useful.
Many Thanks and Kind Regards
J
Thanks for such a detailed answer. This is what I have been looking for and thanks for providing the formula as well, it is really useful to see what is going on under the ‘hood’ of the look-up table.
I have just tried to implement this into a vopcop filter and I have a couple of questions, first of all would you be using the intensity channel as your input value and the RGB values as your output in the filter.
Also when I go to save the LUT, is says the I needs to be a pixelOP node (blue node) to create a LUT? Do you know of another way of implementing this other than the vopcop filter.
Thanks again for your help this has been immensely useful.
Many Thanks and Kind Regards
J
- axebeak
- Member
- 51 posts
- Joined: Oct. 2006
- Offline
Ah-hah, I swapped the wires in the initial example - re-uploaded correct graphs and the scene, sorry about that!
Nonetheless the text and the formulas are correct.
Assuming you're using 0-1 linear image as your input, simply use its R channel, that will represent the linear light.
Yes, that's correct.
I thought it should be possible to save LUT from an instance of Lookup COP (using VOPCOP filter as the input table), and indeed it allows to open the Save LUT dialog, but throws an exception upon saving. Well, Lookup is placed under PixelOp in the TAB menu, but the node is not blue, so…
Anyway, as a temporary solution I'm attaching a small hscript that simply calculates the table. You can execute it from textport using “source” command. The archive includes pre-generated LUT as well.
Nonetheless the text and the formulas are correct.
the intensity channel as your input value
Assuming you're using 0-1 linear image as your input, simply use its R channel, that will represent the linear light.
the RGB values as your output in the filter.
Yes, that's correct.
Also when I go to save the LUT, is says the I needs to be a pixelOP node (blue node)
I thought it should be possible to save LUT from an instance of Lookup COP (using VOPCOP filter as the input table), and indeed it allows to open the Save LUT dialog, but throws an exception upon saving. Well, Lookup is placed under PixelOp in the TAB menu, but the node is not blue, so…
Anyway, as a temporary solution I'm attaching a small hscript that simply calculates the table. You can execute it from textport using “source” command. The archive includes pre-generated LUT as well.
- JRoberts
- Member
- 7 posts
- Joined: Oct. 2008
- Offline
- TomRaynor
- Member
- 3 posts
- Joined: June 2012
- Offline
- axebeak
- Member
- 51 posts
- Joined: Oct. 2006
- Offline
The inverse transform is this (the linear breakpoint is at 0.018*4.5 = 0.081):
if V < 0.081: L = V/4.5
else: L = ((V + 0.099)/1.099)^(1/0.45)
The following hscript will generate the inverse LUT.
set outname=$arg1
set outname=`ifs(!strlen($outname), “Lin709.lut”, $outname)`
set len = 256
echo “Version 1” > $outname
echo “Format any” >> $outname
echo “Type C” >> $outname
echo “From 0 1” >> $outname
echo “To 0 1” >> $outname
echo “Black 0” >> $outname
echo “White 1” >> $outname
echo “Length ”$len >> $outname
echo “LUT:” >> $outname
echo “RGB {” >> $outname
for i = 0 to `$len-1` step 1
set V = `$i/($len-1)`
set L = `if($V < 0.081, $V/4.5, pow(($V + 0.099)/1.099, 1/0.45))`
echo “ ”$L >> $outname
end
echo “}” >> $outname
if V < 0.081: L = V/4.5
else: L = ((V + 0.099)/1.099)^(1/0.45)
The following hscript will generate the inverse LUT.
set outname=$arg1
set outname=`ifs(!strlen($outname), “Lin709.lut”, $outname)`
set len = 256
echo “Version 1” > $outname
echo “Format any” >> $outname
echo “Type C” >> $outname
echo “From 0 1” >> $outname
echo “To 0 1” >> $outname
echo “Black 0” >> $outname
echo “White 1” >> $outname
echo “Length ”$len >> $outname
echo “LUT:” >> $outname
echo “RGB {” >> $outname
for i = 0 to `$len-1` step 1
set V = `$i/($len-1)`
set L = `if($V < 0.081, $V/4.5, pow(($V + 0.099)/1.099, 1/0.45))`
echo “ ”$L >> $outname
end
echo “}” >> $outname
- TomRaynor
- Member
- 3 posts
- Joined: June 2012
- Offline
Sorry for the potentially silly question but how do I even run this hscript?
I have tried going to the houdini help but I cant seem to be able to follow what they are saying.
I have tried saving your code into a “.cmd” file.
Then (on windows) I open up a command prompt, and “cd” into the file's location. Then I try typing something like:
recToLin.cmd recToLin_v01.lut
my thinking was that the first part is running the cmd file and the second part (“recToLin_v01.lut”) is the arguement that I am trying to pass in. All it seems to do is create a file called $outname that is 1KB in size. It doesn't seem to behave correctly.
Am I doing something wrong? Could someone please give me a nudge to get me on the right track for how to make this “.lut” file? And maybe even just add it as an attachment to their reply as well
Thanks!
I have tried going to the houdini help but I cant seem to be able to follow what they are saying.
I have tried saving your code into a “.cmd” file.
Then (on windows) I open up a command prompt, and “cd” into the file's location. Then I try typing something like:
recToLin.cmd recToLin_v01.lut
my thinking was that the first part is running the cmd file and the second part (“recToLin_v01.lut”) is the arguement that I am trying to pass in. All it seems to do is create a file called $outname that is 1KB in size. It doesn't seem to behave correctly.
Am I doing something wrong? Could someone please give me a nudge to get me on the right track for how to make this “.lut” file? And maybe even just add it as an attachment to their reply as well
Thanks!
- axebeak
- Member
- 51 posts
- Joined: Oct. 2006
- Offline
This is Hscript so you need to run it from Houdini - open the Textport (Windows-> Hscript Textport, or press Alt+Shift+T), then type the following command:
source "full_path_to_hs_file" full_path_to_lut_file
If lut_path is omitted the file will be saved to your home directory.
(And, if the above method fails, I'm attaching the LUT file as requested.)
source "full_path_to_hs_file" full_path_to_lut_file
If lut_path is omitted the file will be saved to your home directory.
(And, if the above method fails, I'm attaching the LUT file as requested.)
- TomRaynor
- Member
- 3 posts
- Joined: June 2012
- Offline
- axebeak
- Member
- 51 posts
- Joined: Oct. 2006
- Offline
- protean
- Member
- 72 posts
- Joined: July 2006
- Offline
- protean
- Member
- 72 posts
- Joined: July 2006
- Offline
protean
Hi,
Sorry to dig up this old thread but does anyone know how to produce the LUT table (via script etc) with the log sampling used? I'd quite like to produce some LUTs with log sampling that I cannot because of the ‘use only blue nodes’ limitation.
J
Nevermind. As usual the act of writing down my question promoted the solution. I found the log sampling method in the HDK docs:
http://www.sidefx.com/docs/hdk12.1/hdk_io_lut.html [sidefx.com]
john @ hydrastudios
-
- Quick Links