Closed masc4ii closed 6 years ago
I think we should take a look at DreamWoks's OpenColorIO. If we implement it, there will be all possibilities to do all kind of fancy stuff with luts too.
I was playing around a bit and think I could need your help @bouncyball-git , because I think you are good in file reading! In the file lut.c there is now the file scanning of a cube file. But it now works only for the numbers in such a file:
0 0 0
0.0375219 0 0
0.140475 0 0
0.246708 0 0
0.355093 0 0
0.462974 0 0
...
Normaly such a file has a header like this:
TITLE "Generate by Resolve"
LUT_3D_SIZE 33
0 0 0
0.0375219 0 0
0.140475 0 0
0.246708 0 0
0.355093 0 0
0.462974 0 0
0.568292 0 0
...
Could you please help in scanning the dimension (LUT_3D_SIZE
) and ignoring all other lines?
If you want it to work, adapt the lines 507+ in raw_processing.c
. You also must delete the header of the selected cube file, else you gonna have a black image. 😄
Next, between the LUT points we need a interpolation. A LUT with a size of 33 brings without interpolation 33 colors per channel (very ugly) 😄
Ok I think @ the evening I will have some time. I'll take a look.
Maybe first we should try to implement just a simple 1D Lut support?
Hehe, we could do the as second... 3D is mostly working already 😄 I'll do another commit this evening. The only thing what does not work yet is parsing the lut header with its keywords (dimension has to be entered in the code and cube header has to be deleted in the cube file). And maybe my interpolation is not good enough - sometimes there are some nice rainbow artefacts on the pictures 😆 I did a 3x 1d linear interpolation - maybe that is to simple (or I am doing something wrong).
Edit: we'll need 3x triliniear interpolation 😝 https://spie.org/samples/PM159.pdf
Edit2: oh no... trilinear interpolation is more ugly than linear... and now I found in the CubeLUT spec: "The reader should use linear interpolation for one dimensional tables, and tetrahedral interpolation for three dimensional tables." 😛
Yeah I remember that tetrahedral interpolation thingy from 3DLut Creator :)
You know this tetrahedral interpolation? Do you know how that works, or better, do you have some code? I only found that this method is existing, but nothing more... 😢
I commited a version, where LUT is selectable via GUI now. You only must enter in lut3d.c; load_lut3d(), line uint16_t dimension = 33;
to the right size, delete the header from your test lut and have fun. In line 140 you can switch between linear interpolation and trilinear interpolation. First is not good enough, it is ugly. Second seems not to work right, it is very very ugly. 😄 (see the saw tooth in the histogram... ulàlà)
(Linear interpolation, FilmLUT)
(Trilinear interpolation, FilmLUT)
Yay... fixed my trilinear interpolation! Looks perfect now. But fps without LUT : with LUT = 2:1 😮 Seems to be very CPU consuming...
Haha that introduced banding was so nice :)
I'm not familiar with tetrahedral interpolation. I just remember that 3dlut creators once updated to support it :)
I've done some changes to 3dlut.c (header parsing) but it's not finished yet. Could we name the file cube.c/cube.h? because it will be just cube 1d/3d lut lib.
👍 Can't await your changes! I renamed it to cube_lut.c/.h (who knows what further kinds of cubes there are in image processing 😄 ).
Sorry, I'm out of the city, will try to finish it tomorrow at the evening.
Take your time and enjoy the weekend!
Added full spec cube parser according to the official PDF.
Here is a PDF and 3 cube samples to test Link
For now all debug messages are printed to the console.
Enjoy :-D
Wow, thanks! Will try! 😄
So cool! That works really good for me! 👍
Yay! I'm glad to hear that! :)
The func returns 0 on success and -1,-2,-3 on errors. You can make use of it.
@masc4ii BTW very good job with interpolation and applying the LUT!!! Thank you! 😃
Tetrahedral Interpolation is working now! I made a define into cube_lut.c where you can switch between the Tetrahedral and Trilinear Interpolation. At least on my Core2Duo the speed is the same (but I don't understand why, because Tetrahedral Interpolation has nearly around factor 10 less operations).
I am impressed by the Ektar100 LUTs from ML Forum! Look at this: 1st pic: No LUT, nearly all sliders were used to get the picture as it is.
2nd pic: Ektar100 LUT used, Curve was set to "Alexa Log-C", only WB sliders were used. Both pictures are very close... or not?!
Sky looks a little bit different.
You wrote the tetrahedral interpolation yourself?!!! Cool! You are good @ Math!
You wrote the tetrahedral interpolation yourself?!!! Cool! You are good @ Math!
Thanks for the flowers... but not really. I just typed what was written in this pdf document posted above... and I wondered myself that it was working out of the box 😄 So... more luck then knowledge 😄
Just a reminder: It woud be nice to have a 1D & 3D LUT support. How to read .cube files can be found in the Inet easily. But to apply the LUT there is some math to implement...