Beep6581 / RawTherapee

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

Working profile has big impact on tone curve result #2795

Closed Beep6581 closed 6 years ago

Beep6581 commented 9 years ago

Originally reported on Google Code with ID 2815

This is not really a bug, but ust the way it is and I'm wondering if perhaps there is
a better way;

The following picture as high saturation red colors in it:
http://torger.dyndns.org/rt-bugs/_MG_0725.CR2
open it, apply a neutral profile to start clean, the apply a good amount of contrast
using the contrast slider. The try changing working profile between Prophoto and sRGB.

There is a huge difference in result, the reason being that the S-shaped contrast curve
when applied in Prophoto will push green to clip at 0, while for sRGB it's kept within
range. In the sRGB case the hue is kept truer to the original too.

As an example Lightroom also always apply tone curve in prophoto space, but does some
sort of gamut mapping so the effect is not as dramatic, but it still has the issue.

I'm all for having prophoto as the default working profile like we have now, and it's
generally good having a big space that doesn't clip things, but I think this tone curve
issue problematic. In this case having a large working space actually provokes clipping
rather than the other way around.

Comments, ideas?

Reported by torger@ludd.ltu.se on 2015-06-17 20:52:47

Beep6581 commented 9 years ago
It is one of most important element of my processing technique: the tone curves (contrast/lightness
sliders which are the implicit tone curves) should be applied to some data being held
within "real" colour space which is fully enclosed inside representable colours space
- for the reasons which you mentioned. If the working space is not real, the parts
of exported image won't be reproducible even with best reproduction hardware after
manipulation of contrast.

I am using BestRGB as my working space since I began my research of problematique of
digital imaging.

I'd like to say following.

1) Tonal Contrast implies redistribution of saturation - part of gamut becomes less
saturated and another part becomes more saturated and it is the property of tonal (transfer)
curves. It is inevitable that if your working space is wider than your output space
you will loose certain parts of gamut.

2) It may desirable to make it possible to select the working colour space for tonal
curves. However, I do not use any transformations which cannot be tuned to specific
working space in my workflow and it is perfectly possible that there are zero tools
which are significantly affected by working space selection. Working space is significant
only for the certain part of the image exporting in RT, there is RGB2LAB conversion
at the end of improcfun.cc:rgbProc() and working space does not matter after that point
at all. Everything which is done before this point may be sensitive to working space
selection and nothing else.

3) Isn't the saturation slider the sufficient ready-to-go solution? It may be repositioned
in processing pipe to service the discussed issue better.

4) May the adjustable saturation blending be useful? The related feature of tonal curves
is "Saturation and value blending" and related feature of RGB curves is "luminousity
mode", however there is no analog for contrast/lightness sliders which are tone curves
inside and, in terms of tone curves, operate in "Standard" mode.

And might be not related:
5) I am interested in how user of digital camera is expected to avoid colour clipping
in general. My experience with digital technology shows that almost any digital camera
profile clips saturated colours - by making the gamut perfectly irrepoducible with
any trichromatic reproduction system.

6) I have zero clue about why having wide colour space is important - it could be if
there were any reproduction systems which used more than 3 primaries but I cannot name
any besides some VERY expensive TV displays (I cannot recall the name of technology,
it is probably Toshiba's one). Affordable wide gamut monitors are still not covering
100% even of AdobeRGB. I cannot remember any practical ways of making prints with AdobeRGB
gamut, too.       I have learned that more saturated colours transform to brighter
colour of colour space with smaller gamut recently. Like, if triplet (0,7, 0,25, 0,25)
of one colour space matrix-transforms to (0,8, 0, 0) of another colour space, the triplet
(0,7, 0, 0) will transform to (1, 0, 0). Is this the point of having large gamut colour
space?

Reported by pinhuer on 2015-06-17 21:45:44

Beep6581 commented 9 years ago
This question has arised now when I work with the camera profiling software DCamProf.

I perfectly know why this happens and that it's logical, but I humbly question if this
is a design we like.

A large working space is good in many other situations, for example when the real scene
has really saturated colors (they can indeed be outside sRGB and even AdobeRGB in the
real world) it's nice to be able to use saturation slider, hsv equalizer and other
tools to globally or individually bring them in accordingly to your taste rather than
having colors clipped away first thing with no way to recover them.

In other words - I want the raw converter + profile be able to capture and represent
the "colorimetric truth", which indeed is possible with a large working space, and
then the user can map this gamut to the output using the various color tools. It's
the "scientific" aspect of rawtherapee. Clipping real colors because screens can't
represent them is not a good idea I think. By having the colorimetric data in the pipeline
you can later apply perceptual models to best handle extreme colors, but if you clip
away the data the models doesn't have anything to work on.

(Using CIECAM02 I've noted one can apply contrast in less destructive ways even with
large working profile.)

I have currently not the full view of where clipping takes place though. Possibly its
possible to use a smaller space without causing clipping these days when internals
are floating point. If it works like the old school way a smaller space means that
we would clip away the colorimetric truth from start and not be able to recover.

Anyway, applying RGB curves in prophoto space does not seem to work that great when
there are high saturation colors. We're not alone in doing this though, Lightroom does
the same (but they seem to gamut map the result rather than clip).

Reported by torger@ludd.ltu.se on 2015-06-18 07:20:47

Beep6581 commented 9 years ago
The oldschool way of applying a RGB S-shaped tonecurve to compensate dullness is really
a nostalgic connection to film photography. Researchers has since produced a zillion
of better ways to apply contrast, CIECAM02 being one.

The problem with RGB curves is that they distort color, and even more so when applied
in a huge color space. With RawTherapee where profiles are generally designed the colorimetric
accurate way (that is you shoot a color checker and make a profile to accurately match
that with no subjective tunings) this is a problem. Profiles bundled with Lightroom
have subjective tunings, such as desaturating saturated reds to somewhat compensate
the wrongdoings of a prophoto RGB tonecurve.

I don't think that is a good way to go as it is less well-defined and makes it much
harder to make and get profiles for RT, we would then probably get some profiles with
subjective tunings and some without and we would not get good uniform color. We need
to have a pipeline that is designed to work with profiles that provide colorimetric
accuracy.

Reported by torger@ludd.ltu.se on 2015-06-18 07:28:54

Beep6581 commented 9 years ago
Is it fine that I want to talk about colour issues here or should I move my comments
to forum as unrelated to original topic? If it is not fine, this will be my last of
this kind in this issue.

I found out that I may abuse the expressional style which makes me to sound to self
assured and fixing this expression style (so that I sound more gentle) makes my posts
twice as long. I wrote 5000-digit comment and it was quite scary and I took some effort
to make it more organized than an array of "quote&comment" pairs. Feel free to comment
on whether my comments are appropriate.

>I have currently not the full view of where clipping takes place though.

sRGB's (or any other's) boundary triangle denotes colours which will be clipped with
any increase of tonal (transfer) contrast performed inside wider colour space - to
the extent dependent on their luminance of course.

>Possibly its possible to use a smaller space without causing clipping these days when
internals are floating point. If it works like the old school way a smaller space means
that we would clip away the colorimetric truth from start and not be able to recover.

I suggest that you try to match an export from image with wide working colour space
using the smaller colour space. I think that it is perfectly possible for the reasons
which I mentioned - big part of processing occurs in LAB space which contains all reproducible
colours and other part happens inside signed colour space.  ................ However,
I checked one thing: selecting colour space (sRGB) as working colour space which is
smaller than input and output profiles caps the gamut. So, it is not rady to use yet.

You may use the rainbow.tif with according input profile to stress the processing algorithms:
http://filebin.net/nof7hiscyo .

>The oldschool way of applying a RGB S-shaped tonecurve to compensate dullness is really
a nostalgic connection to film photography. Researchers has since produced a zillion
of better ways to apply contrast, CIECAM02 being one.

Do you mean some sort of satval blending? Or do you rather mean "local contrast"?

CIECAM02 is the formalization of human vision fenomenas which can be used to make processing
more expectable. I cannot see direct connection of contrast and this formalization.
Quick googling does not enlighten.

You say that S-shaped tonal curve is applied due to film nostalgia. But there are so
many kinds of film and each one has it's own set of characteristic curves which have
their form and slope, there are even ones which have flat (logarithmic) curves. I cannot
see direct connection of S-shaped curve to film. I suppose that S-shape and the fact
that it is tonal (transfer) curve (rather than LUT) is a consequence of process simplification
- same as ignoring the gamma of colour space in image editors (same tonal curve produces
different results dependent on the gamma of colour space in most raster editors). S-shape
is the simpliest shape for end user. Cameras were not always able to quickly apply
the LUT profile because of their CPU/microcontroller.

I prefer logarithmic curves with straight parts to the S-shape of gamma scaled curves.

>The problem with RGB curves is that they distort color

First of all I want to say that both satval blending and local contrast manipulation
both may result in more neutral (I do not want to say "accurate") image ( I assume
that those are the things which you are talking about).

However, my thoughts are that any image processing which is aimed at reproducing the
image with non-perfect capturing and reproduction technology distorts colour. You said
that researcher found out better ways to apply contrast - the perfect capturing and
recording technology would not need any contrast increase at all.

____________________________________________
I wanted this part to be the first but let it be the last because it is slightly off-topic
and might be not exactly corresponding to what you want to discuss:

>the colorimetric accurate way (that is you shoot a color checker and make a profile
to accurately match that with no subjective tunings)
>In other words - I want the raw converter + profile be able to capture and represent
the "colorimetric truth", which indeed is possible with a large working space, and
then the user can map this gamut to the output using the various color tools.

Only that recording technology can be accurate in colorimetric sense if it satisfies
Luther-Ives conditions.

There is no colorimetric accuracy with currently available image recording technology.
One may make LUT profile for exact conversion of given set of SPDs (spectral power
distributions) to their exact XYZ - it does not make the image "accurate". The visible
world posesses uncountable number of SPDs. Current sensors and profiles which are available
from mfg, Adobe, profiling software etc. inevitably oversaturate colours which correspond
to certain SPDs with not extreme (x, y)  values past currently reproducible gamut and
even more - past visible gamut. The same profiles shift the colour of all SPDs which
do not make up the colour chart which was used to make the profile.

The only fix which may be acceptable for current digital content consumers is substitution
of matrix conversion with complex LUT profile - it won't bring colorimetric accuracy
but it will help to avoid oversaturated colours along with preserving chroma details
of saturated areas. You mentioned it as "Lightroom subjective tunings", they are also
known as "hue twists".

My own fix of this oversaturation problem is based on avoiding cameras which require
strong profile (which, when combined with failure to satisfy the Luther-Ives conditions
gives oversaturation of certain SPDs (spectral power distribution) if saturation of
important colours is normalised) - most of available cameras do.

Colour film does not satisfy Luther-Ives conditions as well, but it does not require
any saturation boost and thus it does not push colours out of visible gamut.

:::::::: Why do I say all of this: I cannot ssee the sense in talking about tonal curves
as "distorting colour" while ignoring the colour distortion which is introduced by
recording technology.

Reported by pinhuer on 2015-06-18 17:51:45

Beep6581 commented 9 years ago
P.S.
>>Current sensors and profiles which are available from mfg, Adobe, profiling software
etc. inevitably oversaturate colours which correspond to certain SPDs with not extreme
(x, y)  values past currently reproducible gamut and even more - past visible gamut.
The same profiles shift the colour of all SPDs which do not make up the colour chart
which was used to make the profile.

The colour defects are not limited to saturation, they include hue shifts as well.

Reported by pinhuer on 2015-06-18 18:02:18

Beep6581 commented 9 years ago
Hi Anders, thanks for pointing out this issue. A usable desired behavior would be contrast
curve is PhotoPhoto working space would work as in sRGB working space. 

Do you have a solution to what you pointed out?
> "There is a huge difference in result, the reason being that the S-shaped contrast
curve when applied in Prophoto will push green to clip at 0, while for sRGB it's kept
within range. In the sRGB case the hue is kept truer to the original too."

It is certainly silly to have more clipping in a larger working space!:)

Reported by michaelezra000 on 2015-06-19 15:37:25

Beep6581 commented 9 years ago
>It is certainly silly to have more clipping in a larger working space!:)

Tone curves do not cause clipping in the space in which they are applied.

Reported by pinhuer on 2015-06-19 17:15:46

Beep6581 commented 9 years ago
I'm not sure if we should do anything really, it's going to be painful as it would change
rendering results.

RT has a long history dating back to the integer math days and old school ways to work
with color, when you cared about things as working space and did RGB tone curves. Maybe
it's not wise to change that legacy. All the big name raw converters have that type
of legacy too, even Lightroom which is supposed to be modern.

The core thing here is that an RGB tone curve really suck as a "tone reproduction operator"
as you call it in scientific papers, that is a way to compress tones from a bright
real scene into the smaller dynamic range of a screen. We've added custom ones though,
and the "weighted standard" is pretty good in maintaining color, but still has issues
with color space changing.

How I would like a "modern" raw converter to work is that 1) profiles are colorimetric,
ie use a linear curve and what you get color good for reproduction photography, and
indeed this is how we design profiles for RT. 2) have a tone curve that can subjectively
increase contrast but without distorting color.

It's at 2) it becomes complicated. If you know about the Stevens and Hunt effects you
know that if you shoot a sunny outdoor scene and display it on screen you need to increase
contrast *and* saturation to make it look realistic, as the reduction of luminance
reduces the sense of contrast and saturation even if the colors are reproduced with
the right colorimetry. That's why RGB curves historically was sort of right, they increase
both contrast and saturation, but overdo it with a wide margin and have hue shift and
color space issues.

Now many have had the idea that if we just apply a curve in the "luminance channel"
the result will be neutral and realistic without the oversaturation and color shift
of RGB curves. In RT we have Lab L curve, and we have the saturation and value blending.
The problem is that we then disregard from the Hunt effect which means that increased
contrast with same saturation will actually look slightly desaturated.

The "perfect" tone curve is still missing from RawTherapee, one that does work on some
sort of luminance channel (CIECAM02 lightness perhaps) but automatically and suitably
increases saturation depending on how big the contrast is, with the goal that colors
of objects in the image would appear the same even though the contrast of the image
is different. If you're a color scientist you would object and say "impossible" as
we need to take local contrast phenomena into account to make the perfect model, and
yes that is true, but we don't need the perfect, there is a middle way which gives
the familiar curve concept to the photographer but is much more color neutral than
any of the currently available approaches.

Big ones like Capture One and Lightroom are still using RGB curves, but I've studied
their profiles and indeed they have designed their profiles to "cancel out" some of
the wrongdoings of the RGB curves. Lightroom also have a hidden gamut mapping from
its internal Prophoto to the output space which makes curve clipping issues less evident.

RT does not have profiles adapted for curves, and does not do any gamut mapping for
them which means that RGB curves work worse than for the others. You won't notice it
that much for low saturation colors, but the difference is quite remarkable for high
saturation colors like in the example picture.

Reported by torger@ludd.ltu.se on 2015-06-19 20:53:13

Beep6581 commented 9 years ago
In RT we introduced a second RGB curve with intent to avoid the S curves but use separate
curves for brightening and darkening. This improves usability of curves greatly and
allows to avoid contrasts leading to hue shifts. This is illustrated in issue 1513.
Good results can be obtained with brightening Film-like curve and darkening Weighted
Standard.

Reported by michaelezra000 on 2015-06-19 21:10:37

Beep6581 commented 9 years ago
Here is the illustration of the S-curve problem:
https://rawtherapee.googlecode.com/issues/attachment?aid=15290090000&name=RT_tonecurve_analysis_11.jpg&token=ABZ6GAfraWqdlJ60MRG49qnnpu399SUTxw%3A1434748067249&id=1529&mod_ts_token=ABZ6GAcALqCLOrYbrI-S5R741bpfqtQ8Fg%3A1434748067249&inline=1

Reported by michaelezra000 on 2015-06-19 21:15:16

Beep6581 commented 9 years ago
Yes I think the RGB issues become worse for S-curves (sigmoid), as there's more hue
shift issues then. A straight segment is equal to just simple multiplication, ie exposure
adjustment, so those works well, but to get a contrast change one needs a bend of course,
both brightening and darkening.

Maybe the only thing we should do now is make sure that the documentation clearly states
that Working Profile can have a strong effect on the result of the curves, especially
for saturated colors.

It's a mess to work with negative and >1.0 values internally, many color algorithms
go haywire so using a small working space and just not clip I don't think is a great
idea in terms of internal architecture, but I think RT is actually quite close to clipless
as-is. So one idea is to use a small working profile and not clip until output, but
that creates all sorts of messiness... you'd want to have the HSV equalizer applied
before curves to avoid having negative values or > 1 before the curve is applied (now
it's after).

Tone reproduction is a fundamental aspect of raw conversion, and it's really underappreciated.
If we'd do a new raw converter from start getting it done right would have to be a
high priority so we don't get stuck in the RGB soup like all other raw converters out
there.

I use the dual curve feature myself but for other purposes, I use one curve for applying
a "default" curve to get a neutral look with suitable contrast, and the other to apply
a look. It should be possible to make a tone curve that can apply an S without "dirty
color" issues, I'd like to see that...

I work with DCamProf quite much now (a camera profile maker), and the main problem
I see now is that when I create an accurate profile it's really hard to apply contrast
without distorting the color. I see other profiles be deliberately desaturated (even
matrix-only profiles) to cause less crazy color when an RGB curve is applied, and I
think then something is very wrong.

In RT we have a few choices, either do like the big names with all their legacy do
- have RGB curves and subjectively adapt their profiles to look good with an "average
curve", or have it like now - ignore the fact that RGB curves is default and get bad
color from the profiles designed for linear accuracy, or try to get away from RGB curves
and further develop what "weighted standard" already does, ie try to make a curve that
can apply contrast without color distortion.

Reported by torger@ludd.ltu.se on 2015-06-20 07:46:36

Beep6581 commented 9 years ago
michaelezra000: could you please the export of the same photo without any curves applied?
I want to see if my approach works better.

Here is my attempt in manipulating the OP-photo with curves: http://filebin.net/bet09gya5w

>A straight segment is equal to just simple multiplication, ie exposure adjustment,
so those works well

This is false (unless you applied my patch and are using linear and logarithmic curves)

issue 2644
issue 2642
issue 2640

Straight segment of linear (non-gamma-corrected) curve is not equal to exposure compensation
either  if it is not matching the part of the line which is drawn down to black point.
See illustration in http://filebin.net/bet09gya5w - four regions denoted with pairs
of points are equal to exposure correction.

But: only for linear curves and not for those curves which public version of RT currently
has.

Reported by pinhuer on 2015-06-20 14:07:50

Beep6581 commented 9 years ago
Let me illustrate my counter-scepsis.

http://rawtherapee.com/shared/test_images/snow_street_night_shot.cr2
http://filebin.net/xzhl6ypjkz

These two exports are accompanied with .pp3 files - one contains logarithmic curve
with 14EV DR which I exclusively use in my workflow and another one has gamma curve
(but there is no indication of that inside).

The profile with logarithmic curve additionally has -1,5EV correction and colour propagation
enabled.

Both exports are made with ProPhoto working space.

___________________________________

And: when I ask about what photographic enthusiasts are expected to do with ProPhoto
gamut output, I am perfectly serious. Not that it is bad just because it is ProPhoto,
the problem is that:
1) there is no practical way to use it;
2) RAW software and camera profiles produce out-of-visible-gamut output.

There was mention of that using of curves clips colours in sRGB colour space. This
is of no surprise. Do not get me wrong - I understand that one may wish to adapt their
process for smaller gamut spaces.

I just want to know: how much is the technique which I illustrated worse than the oversaturation
which digital technology produces in general if it is?

Reported by pinhuer on 2015-06-25 21:32:10

Beep6581 commented 9 years ago
I mean, even neutral image with one of usual input profiles does contain non-sRGB colours,
why blame tone curves?

Reported by pinhuer on 2015-06-26 09:29:37

Beep6581 commented 9 years ago
We've taken this discussion back to the steering committee as it's really about how
color rendering should work from start to end.

Here's a discussion about tone curves and their impact I just added to DCamProf's documentation,
that outlines the underlying issue I see:
http://www.ludd.ltu.se/~torger/dcamprof.html#tone_curves

the underlying issue is that RT claims that it wants scene-referred profiles (linear
colorimetric), but to be serious with that one must have well-working neutral tone
reproduction operator. The "weighted standard" indeed goes a long way on this, but
I think more work needs to be done.

Whether one likes it or not many are used to using Prophoto throughout their workflows,
for example making basic raw conversion first then doing most subjective color editing
in a photo editor such as Photoshop, and print from there. Some printer and paper combinations
are capable of outputting some colors outside AdobeRGB.

Anyway, the size of the color space is not really the issue as I see it, the fact that
the base tone reproduction is affected by color space is in itself an issue. It's not
good design to require your camera profiles to be designed for one specific color space,
which is what we have in practice today.

The easiest solution I think is adding a new curve type which can apply contrast without
color shifts, and that is agnostic concerning color space.

Reported by torger@ludd.ltu.se on 2015-06-26 12:14:47

Beep6581 commented 6 years ago

The "Perceptual" curve mode was added in issue #2817 and has the same effect regardless of working space.

We should probably set Perceptual to be the default curve mode, any objections?

https://github.com/Beep6581/RawTherapee/blob/dev/rtengine/procparams.cc#L915 s/TC_MODE_STD/TC_MODE_PERCEPTUAL/

heckflosse commented 6 years ago

@Beep6581

We should probably set Perceptual to be the default curve mode, any objections?

It's slow

Beep6581 commented 6 years ago

Docs updated: http://rawpedia.rawtherapee.com/Exposure#Curve_Mode http://rawpedia.rawtherapee.com/Color_Management#Working_Profile