Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.75k stars 313 forks source link

Please add LogC export #3333

Open ghost opened 8 years ago

ghost commented 8 years ago

Feature request:

Please make RawTherapee capable of exporting LogC format. This is very useful for high quality color grading and retouching.

iliasg commented 8 years ago

Do you mean Cineon 10-bit log format ? Something else ?

ghost commented 8 years ago

I mean this:

http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf

Beep6581 commented 8 years ago

@anchev

  1. Log-C is not a format.
  2. As I understand it, the point of Log-C is to optimize data distribution with regard to the exposure in the encoded file so that more can be done afterwards in post-processing. It is used in intermediate files. As RawTherapee is where the post-processing is done, why does this belong in RT?
  3. Why Log-C, why not S-Log, S-Log2, S-Log3, C-Log or any other log encoding?
ghost commented 8 years ago
  1. Sorry. Perhaps I didn't use the right words. Yes - it is not a file format.
  2. RT is not necessarily where post processing is done. RT is a raw converter an one may want to do color grading in a different application while still using the good raw conversion capabilities of RT. The point of using LogC is to utilize and save the full dynamic range in the exported TIFF for further color grading.
  3. Because the formula for LogC is publicly available and many available LUTs are encoded to use LogC. Of course if you make the other encodings too it won't hurt :)
iliasg commented 8 years ago

Here is a first try with an icc profile .. rec2020 primaries and log TRC curves (instead of the normal gamma TRCs..) https://drive.google.com/file/d/0B0NqktTgc54sbnFuaHFSc05Ba0U/view?usp=sharing

One can inspect it with icc profile inspector .. double click on rTRC/gTRC/bTRC to see the curve or export the data to curve.txt

The curve consists of 1023 data points (may be a 4096 points curve will be useful as next step ..) i.e. a linear part (0-143 of 0-65535 range) and then log (each subsequent value comes from the previous*1.00698736). This on a 10bit file would give

To see the (assigned to log profiles) desaturated picture just save a tiff/jpeg using rec2020-log1023.icm then open with RT but instead of the embedded_if_possible use as "custom" the normal rec2020.icm ;) Please try with low bitdepth files ..

BTW .. I wonder if it is possible to tryck the tiff format to contain 10 or 12 bit data in 16bit container i.e leave empty intermediate values (1/16 will be used for 12-bit data) or maybe define the WhiteLevel lower than 65535 ;) ...This way we can have a big file-size gain by using compressed tiffs ;)

ghost commented 8 years ago

@iliasg

Thanks for sharing this! It's a nice start.

However the exported tiff doesn't quite look like a logc image although it has the log-look. A logc encoded image doesn't fill the histogram and this one even has clipped channels which is quite the opposite of the main idea - encoding the full DR into a tiff. Actually a logc file made from a 14-bit raw has its histogram centered with big gaps on left (blacks) and right (whites). I have been told that if it is a 16-bit file from Alexa it would fill the histogram better (although it is still logc).

As far as I understand you have made rec 2020 color space with encoded log curve. What would actually be good is to have a menu option for selecting logc encoding for the final file. Then a logc encoding could be used for any output profile, right?

TBH I am not fully familiar with the mathematics, programming and all the technical terms behind all this. I am just evaluating this from a viewpoint of a person who works with the resulting files :) I was basically looking for a way to have the full DR in the final file (without having to blend separate exposures in Photoshop and all the problems related to that). Then I found out that there is such a thing as logc which people use for video and I thought it would be great to have this for photo too.

There is a program called 3DLutCreator which is the only one I have seen so far capable of exporting real LogC tiff. It can generate a LUT file (3dl, cube) for decoding logc to normal + (if one wants) additional color grading features.

It uses libraw for processing raw files however its output is quite noisy and it doesn't give this level of control over the raw file which RT gives. So when I found RT recently I thought it would be great to have the power of RT to produce clean output + logc encoding. That would give the best possible output file for further retouching and advanced color grading.

I hope that clarifies what I am actually looking for :)

ghost commented 8 years ago

P.S. From a technical viewpoint, it might actually be a good idea to utilize the full histogram (and use the full 16-bits), without channel clipping of course. However this has to be addressed somehow in processing of the resulting image, i.e. by using a LUT/ICC which compresses the histogram and then another LUT layer on top to color grade it. I am not quite sure how this would work, just thinking aloud.

iliasg commented 8 years ago

@anchev I am not sure if I understand what you are after .. please provide samples with log (c or other ..) encoding .. it would be nice if you could show us a raw sample and a process which is better if exported in log encoding What I tried to achieve was a visually better distribution of codes (this is the main reason log encoding is proposed) to overcome posterization problems with low bit depth exports especially when combined with lossy (jpeg) compression .. my main motivation was RT's famous Black cat .. https://github.com/Beep6581/RawTherapee/issues/2735 http://rawtherapee.com/shared/test_images/blackcat.dng http://rawtherapee.com/shared/test_images/blackcat.dng.pp3 The following first saved as jpeg with rec2020log, then reopened and pushed at shadows blackcat-log-pushed_and_resized compare with the one exported using the normal (gamma encoded) rec2020.icm then reopened and pushed ,, blackcat-gamma-pushed_and_resized

ghost commented 8 years ago

Here is a LogC tiff-16 generated from your raw file:

https://goo.gl/zEbCIF

Please open it in Photoshop and look at the histogram. There are also 2 additional layers in it - a LUT which applies proper WB, exposure and converts logc to normal and a master curve.

As you will see - the background layer is quite noisy. What I am after is a clean logc background layer - free from noise and chromatic aberrations.

iliasg commented 8 years ago

Thanks, although I have no PS these days :(

ghost commented 8 years ago

I don't know which other application can open 16-bit tiff files with layers in Prophoto RGB.

Beep6581 commented 8 years ago

@anchev I don't have Photoshop either, could you install GIMP-2.9 and export that in a format which works well in GIMP? Even PSD might work - install GIMP and try it before uploading such a big file. http://nightly.darkrefraction.com/gimp/

"As you will see - the background layer is quite noisy." I only see one layer in GIMP: https://i.imgur.com/75hcHV8.png If this is the noise you are referring to, I think it has nothing to do with Log-C or with data distribution during saving. Noise and chromatic aberrations don't come from using or not using a logarithmic data distribution during saving. Using Log-C won't help with that.

ghost commented 8 years ago

@Beep6581

I have gimp but it neither supports 16 bit channels, nor Prophoto, nor LUT layers (or any adjustment layers whatsoever). So I really don't know how you are going to open and evaluate this properly without Photoshop. As I said (and as you asked) - my aim is to receive a clean 16-bit tiff in Prophoto logc-encoded. I can export 8-bit tiffs for you in sRGB (so you can open them in gimp) but that is not the output which I am aiming at and which we are discussing.

Anyway - yes, this is the noise I am referring to. 3dlutcreator which uses libraw is unable to clean noise and CA, I was hoping that RT which already can do this will be able to give the desired output if a logc functionality is added.

Beep6581 commented 8 years ago

GIMP-2.9 which I linked you to supports 16-bit/channel, even 64-bit/channel.

Not sure what you mean by "nor Prophoto". If you mean the working space, the situation with this in GIMP is a little funny, but without going into detail it supports a GIMP does have a gamut which encompasses ProPhoto.

As for 3D LUT, it doesn't directly support that yet, but it can probably be done using HaldCLUT. To generate a HaldCLUT from your 3D LUT get the Hald_CLUT_Identity.tif and apply your 3D LUT to it, then save it and upload it for us. http://rawpedia.rawtherapee.com/Film_Simulation

Anyway for our needs we don't need ProPhoto nor the LUT layer, we just need 16-bit or more, which GIMP 2.9 handles out of the box.

Back to the noise and CA. What is it that's lacking in Ilias's rec2020log image?

ghost commented 8 years ago

GIMP-2.9 which I linked you to supports 16-bit/channel, even 64-bit/channel.

I didn't know that. Thanks for the info. In openSUSE Leap 42.1 I have all software up to date and it is gimp 2.8.14. I guess 2.9 will make it to their repositories some day soon.

I have uploaded 2 more files - 16-bit flat tiff's - one with clean logc data, one with the lut applied on that and flattened. Please use the same link from above.

Back to the noise and CA. What is it that's lacking in Ilias's rec2020log image?

Proper histogram I guess. Looking at the logc tiff I am sending you will see how different it looks. BTW that tiff is using UniWB. WB is being fixed in the LUT.

iliasg commented 8 years ago

I cannot dig deep these days .. but it looks like it's not only the WB (uniWB) which is at fault for the green tint but a kind of Black Level/White Level we know from RAWs .. I remember from the first quick read that Arri's LogC has offsets at darks and highlights. This destroys linearity, RT's WB cannot be fully effective .. a tint remains visible ..
The 3DLUT corrects this ..

ghost commented 8 years ago

Please have a look a this:

https://vk.com/wall-59691344_9567

The author of 3DLC shares some DCP files he has made which generate logc output from ACR conversions, i.e. all other functions of ACR can still be used.

If you can make something like that for RT it would be great.

Beep6581 commented 8 years ago

@anchev "I have uploaded 2 more files - 16-bit flat tiff's (...) Looking at the logc tiff I am sending you" where do I find the link to those files? The only link I can see above is the black_cat one which downloads the same single file.

ghost commented 8 years ago

Sorry, my bad! I thought I had shared the link to the whole folder.

Here is the right one: https://goo.gl/UZ5hNc