Beep6581 / RawTherapee

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

Color appearance CIECAM02 #1556

Closed Beep6581 closed 9 years ago

Beep6581 commented 9 years ago

Originally reported on Google Code with ID 1572

Here a new patch for CIECAM02

You can read these links about CIECAM02

http://en.wikipedia.org/wiki/CIECAM02
http://www.cis.rit.edu/fairchild/PDFs/AppearanceLec.pdf

http://www.ens-louis-lumiere.fr/fileadmin/recherche/Laborie-photo-2007-mem.pdf
http://www.polybytes.com/misc/Meet_CIECAM02.pdf

You can also read , RT forum http://www.rawtherapee.com/forum/viewtopic.php?f=1&t=4319&start=30

This patch is not optimized, the goal is to discover CIECAM02, which is still to this
day the best system to take into account the appearance, that can not be done by models
as RGB, XYZ, Lab …

I will be away from thursday to several weeks for health reasons.
I suggest you review this patch, modify, optimize it if you want.

To date there has only minimal options, regarding the controls chroma, lightness ;
the others controls (CAT02, surround, background, adpatation...) are near of optimals.

Processing time mode "release" are acceptable, about 1 second per M°, significantly
less than "Noise reduction"...
:)

Reported by jdesmis on 2012-10-02 17:27:16


Beep6581 commented 9 years ago
Thanks Jacques! I will try this tonight

Reported by michaelezra000 on 2012-10-02 20:10:45

Beep6581 commented 9 years ago

Reported by michaelezra000 on 2012-10-02 20:10:59

Beep6581 commented 9 years ago
colorappearance.* go into rtgui

Reported by entertheyoni on 2012-10-02 20:48:42

Beep6581 commented 9 years ago
I have no idea how to correctly use this.

Reported by entertheyoni on 2012-10-02 20:55:41

Beep6581 commented 9 years ago
Wow....this is remarkable:)
Such natural results, just by playing with Surround and Chroma!

Could you explain how to evaluate & use Chromatic Adaptation, Model White point, Adaptation
Luminosity and Background Luminosity;
2 minor issues - history messages for Lightness-J and Chroma-C

Reported by michaelezra000 on 2012-10-03 00:39:37

Beep6581 commented 9 years ago
Jacques, I looked through the patch... this is such huge amount of work and research,
thank you very much for this contribution!

I did more poking and here is a list of some UI issues:

1. need to add CIECAM02 to partial paste, probably as a single checkbox
2. preferences - should all CIECAM02 params be added? (why only degree)
3. Editing CIECAM02 params in filebrowser: 
 3a. dropdowns have no effect in filebrowser
 3b. make edit, go back one step in history, go to last step - CIECAM02 dropdowns loose
values.
 3.c dropdowns need to dislay (Unchanged) when multiple thumbs with different values
are selected - see exposure/Curve modes

Question - How to make use of CRI?

Reported by michaelezra000 on 2012-10-03 02:09:21

Beep6581 commented 9 years ago
I just converted a 216 megapixels image using CIECAM02 to make it brighter and it worked
like a charm.

Reported by michaelezra000 on 2012-10-03 03:28:08

Beep6581 commented 9 years ago
Jacques THANKS.

Michael, any samples ...

Reported by iliasgiarimis on 2012-10-03 07:59:51

Beep6581 commented 9 years ago
Hello Michael

I have slightly modified the code..a little faster.
I took into account your remarks to:

* Preference, history, partial paste
For this new patch, no changes for colorapperance.cc and colorappearance.h

But I do not know how to deal with point 3. ; can you assist me and adapt the code,
because from tomorrow I would be absent ; thank's in advance.

Some brief explanations.
Chromatic adaptation: it uses the CAT02 significantly higher than Bradford

If you choose "Model white point" = « equal », RT will take into account that the user
wants to keep the original white balance.
If you choose "Model white point" = « inverse = D50 », chromatic adaptation will do
to WB =>D50 - what should be the most frequent case
I expected "" Model white point "= « forward,=D50 » because this case can occur

If you choose "degree" = 101, the software will calculate itself the degree of adaptation
« D », or you can set it from 0 to 100 (percentage of adaptation). 

This level is used for both "equal" as "inverse= 50" or "Forward=D50" because it is
something else than CAT02

Surround tries to take into account the "surround environment" in which we observe
the image : the more environment will be more darker, CIECAM02 will change the image,
as well as the brightness of the colors ... see the links I put .

Background luminosity%: if your monitor is set (gray 20%) You do not normally need
to change this setting

Adaptation luminosity (cd/m2): absolute luminance of the adapting field ... Normally
when you set your monitor, this value is about 20% of the ambient light level. This
parameter works in conjunction with "surround"...See the file « adap.html »

To this day "CRI" is only information that appears in "Debug  verbose" ...

In "option" [Color Management] you can change CRI with a number of color (see http://jacques.desmis.perso.neuf.fr/RT/ColorRT2_6.html
"Diagrammes des illuminants et Color Rendering Index (CRI)"
You will see in changing the settings « white balance », CRI values ​​and the new values
​​of the reference colors (Lab). This should be useful if one day RT has a pipette
and a color palette (skin, sky,..)

:)

Reported by jdesmis on 2012-10-03 09:54:10


Beep6581 commented 9 years ago
I tweaked the file adap.jpg

Reported by jdesmis on 2012-10-03 11:15:24


Beep6581 commented 9 years ago
Here is an updated patch which includes colorappearance.cc and colorappearance.h
Changes address all issues in comment 6, points 3

Reported by michaelezra000 on 2012-10-03 12:49:45


Beep6581 commented 9 years ago
The issue was with options.cc in babehav[] - new params had to be added at the end
and a few tweaks in colorappearance.cc

Reported by michaelezra000 on 2012-10-03 12:51:38

Beep6581 commented 9 years ago

Michael : thank you for this work. For me the GUI is still a mystery .. but it works,
it is essential.
I think we should leave time for other people comment on this patch, which is a novelty
for RT.

I propose that:
1) Michael (you) "update default" (commit) - so of course you wants to do and if no
one opposes - tomorrow during the day :)
2) users evaluate "color appearance" on this simple basis.
3) Then, it leaves several weeks (my recovery time) to evaluate and propose possible
changes: better control of J and chroma, etc..

:)

Reported by jdesmis on 2012-10-03 14:30:51

Beep6581 commented 9 years ago
Would be good if someone could shed some light on the practical use of this in photography.
Who is it for, when do you use it, and how.

I assume the final version won't have so many sliders and options...

Reported by entertheyoni on 2012-10-03 14:38:04

Beep6581 commented 9 years ago
Jacques, I wish you lots of energy for a very speedy recovery!

About the adaptation, I am curious why only to darker surround and not lighter. 

Another question. Surrounding near my workstation is dark, monitor is calibrated to
110 cd/m2. What adaptation settings should i use?

DrSlony, I am still evaluating how to make a proper use of this tool. 
But what is immediately evident - one could process image in rt to be optimally viewed
under specific viewing conditions that are characterized by these new parameters.

Reported by michaelezra000 on 2012-10-03 14:53:26

Beep6581 commented 9 years ago
P.S. I cannot believe how were you able to produce this patch so fast!:)

Reported by michaelezra000 on 2012-10-03 14:54:43

Beep6581 commented 9 years ago
Like everything is new, people ask the question what is the point?

If you look back 20 years, who took care of internet, mobile phone ?
Closer to us, that there are 5 or 10 years who spoke to calibrate the monitor, or even
calibrate the camera ?

I do not think "CIECAM02" is the "Grall" in photography ... we went in for many years,
and myself there is still a month (or 2) was skeptical about the suitability of the
product. But now after working on the subject, I fully appreciate the advantages (and
disadvantages)

However, these algorithms have been developed by leading international experts colorimetry.

Among the difficulties are:
* Difficulty communicating on a sensitive topic (the notion of "color appearance"),
which is unknown to many people
* Unusual vocabulary
* Processing time long enough

I think it is practice makes perfect (in french : c'est en forgeant qu'on devient forgeron)
and it costs nothing to offer this feature with RT.

There will probably always be the same number of settings, a little more or a little
less.

The utility is included in the documentation that I have joined, including preparing
images to see them with a projector or a large screen TV ... There is not only "photo
working with a printer", more and more people look at their photos on screens ... and
this is the great purpose of "color appearance"

Michael, I worked before I get hospitalized, but part of the code existed before (CRI.).

For the point "darker" / "lighter", for me also it'curious, but it will be easy, a
little later, to do this reverse effect also.

Michael, for your settings, the best answer is to try  :)

Reported by jdesmis on 2012-10-03 15:07:17

Beep6581 commented 9 years ago
Jacques I didn't ask "whats the point", that would be rude and would imply I think this
is useless, which I don't. As Michael said, well done!
I had an operation a week ago myself, so good luck with that too :]

I did browse through the linked documents. The one English PDF is just a slideshow
that means quite nothing to me without the lecture that went with it, and the other
just documents "the decisions that went into the design of CIECAM02" and not how to
use it. "For (...) usage guidelines, interested readers are urged to refer to the TC
8-01 web site" which links to http://www.colour.org/tc8-01/ and that link is dead.

The question still stands - how do we use it? Eventually this will have to be documented
in simple, layman terms. It can't remain a "Find a book and read the whole thing and
try to figure out how the sliders correspond to the theory" thing. Say I want to put
photos on a website with a background of #161616, what do I measure? How do I translate
that into those settings?

Reported by entertheyoni on 2012-10-03 16:03:14

Beep6581 commented 9 years ago
DrSlony, I understand perfectly.... and thanks for your "good luck"...
I think I would be absent (as "forum", exchange,...) for several weeks

The link you give (TC 8-01) is broken :)

But how tu use it (ciecam02), is a good question ? but as I say in french "c'est en
forgeant qu'on devient forgeron")

Reported by jdesmis on 2012-10-03 16:13:20

Beep6581 commented 9 years ago
my last contribution ....
Now you can also select ​​"surround" = light

to try ... otherwise prefer the previous patch

Good night :)

Reported by jdesmis on 2012-10-03 16:31:45


Beep6581 commented 9 years ago
Good luck Jacques and entertheyoni, get better!

Are the patches additive or the last one is enough to apply?

Reported by gyurko.david@e-arc.hu on 2012-10-03 17:26:15

Beep6581 commented 9 years ago
ciecam02-3oct-M01.patch  and ciecam02-3oct-M02.patch are self-sufficient

Reported by michaelezra000 on 2012-10-03 17:35:14

Beep6581 commented 9 years ago
if no objections, I will commit

Reported by michaelezra000 on 2012-10-05 18:21:19

Beep6581 commented 9 years ago
Can i test briefly before you commit it? It will take me 2 hour max.

Reported by natureh.510 on 2012-10-05 20:31:19

Beep6581 commented 9 years ago
Looks very interesting, but a bit difficult to understand. I wish you could give me
French strings so i can add them to the catalog and see if there may be better translation
possible, but at that time, i can only wish you to come us back in good health.

I think there is room for optimization: it actually process in 2 seconds (or even more)
in may non optimized build (-O0), but on a high end hardware, so i think it's quite
a lot for rendering only the preview area. Let me look at this, I'll try to come up
with something - hopefully - faster by the end of this Sunday.

Reported by natureh.510 on 2012-10-05 22:14:27

Beep6581 commented 9 years ago
Hi Hombre, there is a small UI bug in ciecam02-3oct-M02.patch, I will upload the new
patch soon

Reported by michaelezra000 on 2012-10-05 23:07:56

Beep6581 commented 9 years ago
Nope, i'm already working on it (and already heavily modified!). Just tell me what i
should change.

Reported by natureh.510 on 2012-10-05 23:10:20

Beep6581 commented 9 years ago
Issue is that Surround (which is MyComboBoxText method) gets overwritten when it should
not. 
select different values of Surround in 2 thumbs, then select both thumbs, move Background
luminocity slider. click away from thumbs, then see surround value in thumbs - it is
changed and now is identical in both thumbs

Reported by michaelezra000 on 2012-10-05 23:38:55

Beep6581 commented 9 years ago
Hi Hombre, do you have any luck with performance improvements?

Reported by michaelezra000 on 2012-10-12 20:03:10

Beep6581 commented 9 years ago
Nope. I thought there was room for improvement, but didn't find any so far: the algorithm
looks complex, so maybe it can bee speed-ed up, but not this time. But I've worked
on Jacques' patch to correctly handle the GUI. I'm finishing it by reworking the labels,
and I'll post it in 1 or 2 hours for testing.

Reported by natureh.510 on 2012-10-12 20:09:10

Beep6581 commented 9 years ago
Finally, here is it, later than expected as usual :(

There a transparent code refactoring about how the spectrum values are handled, wich
didn't brought any speed improvement as expected, but i've kept it: it doesn't harm.

I've added a new feature to the Adjusted widget: any dev can now ask to display an
"Automatic" checkbox on the right of the reset button. When clicked, and in editor
tabs only, the slider and spin button are disabled, but not the reset button. Btw,
pressing on this reset button will reset the slider's value (even if disabled) but
not the Automatic checkbox, which should be considered a separate "Enable/Disable like"
button.

The sliders should be correctly handled now.

A last word about the labels and the tooltips: i've read the Wikipedia's page about
CIE CAM02, but didn't managed to find out how this algorithm works, also given that
the initial labels and tooltips were... well... too technical (and a bit cryptic, sorry
Jacques ;)). So the best is to try the different values and solutions and ask Jacques'
for a documentation/summary when he'll come back.

Reported by natureh.510 on 2012-10-13 00:59:16

Beep6581 commented 9 years ago
Hi Hombre, could you please include colorappearance.cc and colorappearance.h (not sure
if you made any changes vs from previous patches).

I am curious, what is the purpose of "Automatic" checkbox besides Enable/Disable? what
kind of automation did you have in mind? Some kind of automation that could drive any
given slider?

Reported by michaelezra000 on 2012-10-13 01:38:01

Beep6581 commented 9 years ago
Sorry, i should have added those files to Mercurial. Here is the complete patch.

The "Automatic" checkbox replace what Jacques made with the "CAT02 Degree" slider,
ranging from 0 to 101, but the useful range was 0-100, and value 101 was used as "Automatic"
by his algorithm. It couldn't be handled properly by the batch editor panel, so I've
created an "Automatic" button that can be displayed in any Adjuster widget, but has
still to be handled by the developer (front-end and back-end).

So far, I've used this button in ColorAppearance only. But while i was trying to handle
it properly, i discovered that the check box buttons (like Enable/Disable of tools
having one) was working quite suboptimally, so i've corrected that for the "Automatic"
button of the Adjuster class, but for the Enable/Disable button of the Sharpening tool
too, for trial. All other checkbox button has to be converter too, but it will be done
in a second time, with medium priority.

If you want to see what was wrong with Enable/Disable buttons, select only one file
in the File Browser and go in the Batch Tool panel, then click on e.g. Crop's Enable/Disable.
It's state will cycle between Enable/Disable/Inconsistent *even if only one file is
selected*, while it could cycle to Enable/Disable only (this is the new behavior, just
look at Sharpening's Enable/Disable). And if multiple files was selected, the "Unchanged"
label in the history was wrong, now. I've set it to "Initial values" ("Unchanged" could
be more appropriated though).

Reported by natureh.510 on 2012-10-13 09:47:07

Beep6581 commented 9 years ago
This makes sense, thanks for adding this feature. I am glad that inconsistency of checkbox
states in batch tool panel can be fixed!

while compiling, I got this error (which I have never seen before):
[ 47%] Building CXX object rtgui/CMakeFiles/rth.dir/filepanel.cc.obj
C:\Users\Michael\workspace\rawtherapee_default\rtgui\filepanel.cc:275:1: internal compiler
error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://tdm-gcc.tdragon.net/bugs> for instructions.
mingw32-make[2]: *** [rtgui/CMakeFiles/rth.dir/filepanel.cc.obj] Error 1
mingw32-make[1]: *** [rtgui/CMakeFiles/rth.dir/all] Error 2
mingw32-make: *** [all] Error 2

Here is my setup:
Compiler: gcc 4.6.1
Processor: corei7
System: Windows     7 
Bit depth: 64 bits
Gtkmm: V2.22.0
Build type: Release
Build flags: -m64 -mwin32 -mthreads -march=corei7 -fopenmp -mwindows -DNDEBUG -O3
Link flags: -mwin32 -mthreads -mthread -static-libgcc  -march=corei7 -mwindows -s -O3
OpenMP support: ON
MMAP support: ON

Reported by michaelezra000 on 2012-10-13 12:19:48

Beep6581 commented 9 years ago
It compiles fine here, Win7/64bits too. I guess you have a problem with your tool chain,
not related to the source code. Did you tried to reboot your system?

Reported by natureh.510 on 2012-10-13 12:24:05

Beep6581 commented 9 years ago
Strange, it compiles fine without the patch. I submitted a bug report at http://sourceforge.net/p/tdm-gcc/bugs/170/

Reported by michaelezra000 on 2012-10-13 12:35:13

Beep6581 commented 9 years ago
Just restarted compilation without cmake and it goes through...

Reported by michaelezra000 on 2012-10-13 12:37:32

Beep6581 commented 9 years ago
I'll post issues as I find them:
When adjusting a thumbnail surround=Extremely Dark is darker than surround=Dark.
In editor surround=Extremely Dark is lighter than surround=Dark.

Reported by michaelezra000 on 2012-10-13 12:45:58

Beep6581 commented 9 years ago
Enable/Disable in Sharpening tool is excellent!
I still see issue with Surround in Batch tool panel as in comment 28

I was thinking about the effects of surround. As-is it would make sense for reflective
presentation of the image only, meaning for prints. If print should hand in the dark
environment, it would make sense to print it brighter - this is when current behavior
of Surround=Dark makes sense. 

However, this is not the case for transmissive sources - projectors & monitors. If
you are viewing a TV is a very dark room, it would feel more natural to make TV *darker*.
If you are viewing camera's LCD on bright sunlight, you would rather make it *brighter*.
So the functionality driven be selection of Surround needs to be modulated by selection
of either Reflective or Transmissive presentation of the image.

Reported by michaelezra000 on 2012-10-13 13:01:03

Beep6581 commented 9 years ago
I also noticed some problem with the Extremely Dark option, that leads to a completely
white image. I think there's something wrong in the algorithm, but for this question
and the one from comment 39, I'll let Jacques address them, and will only take care
of the GUI part. Maybe using Jacques' labels makes more sense, i tried to make them
simpler to understand for the average user, but i don't know if they are correct.

Reported by natureh.510 on 2012-10-13 13:49:20

Beep6581 commented 9 years ago
minor changes I would recommend:

TP_COLORAPP_LABEL;CIE Color Appearance Model 2002
(Model - not Modele)
TP_CIECAT_DEGREE;CAT02 adaptation
TP_COLORAPP_MODEL_TOOLTIP;Equal: preserve your WB settings\nInverse=D50: the image's
WB is used before processing, then converted to Daylight (D50)\nForward=D50: the image's
WB is set to Daylight (D50) before processing then converted to your WB settings
TP_COLORAPP_ADAPLUM;Adaptation luminosity (cd/m2)
not sure if "Monitor" is always applicable here, may be better leave as "Adaptation
field" and explain about the monitor in the tooltip.

TP_COLORAPP_JLIGHT_TOOLTIP;Lightness in CIECAM02 is different from Lab and RGB
TP_COLORAPP_CHROMA_TOOLTIP;Chroma in CIECAM02 is different from Lab and RGB

Reported by michaelezra000 on 2012-10-13 15:17:59

Beep6581 commented 9 years ago
Here is a corrected version. I've also added a special typo (italic) for Adjuster's
values which are set in Add mode (in the Batch Panel's History).

Jacques will soon get back from the hospital and I'll stop interfering in his code
for now.

Reported by natureh.510 on 2012-10-13 17:04:27


Beep6581 commented 9 years ago
Here is an updated patch with fixes UI bug (comment 28) and adds a few line breaks in
tooltips, so it is easier to read.
I also renamed 'method' to 'surround' and 'method_' to 'wbmodel'.

Reported by michaelezra000 on 2012-10-13 19:31:15


Beep6581 commented 9 years ago
Here is a new patch.

Thank you to Hombre for his work on the GUI which provides improvements beyond CIECAM.

Of course we can add more features, but I think it is necessary to stabilize the work,
and that further improvements will come later.

Attached is a tutorial in French.
http://jacques.desmis.perso.neuf.fr/RT/ciecamRT.html

Reported by jdesmis on 2012-11-04 07:35:15


Beep6581 commented 9 years ago
The new feature added for RT but that i had in mind for a long time now is the possibility
for the Adjuster class to throw an event on button release, to make it smarter. This
possibility can be cumulated to the Delay that one can set globally or on a per Adjuster
basis. In this case, the signal will be thrown on the first occurring event. Try to
adjust one of the CIECAM slider and stop moving without releasing the button: the event
will be sent after a 1s delay. Move it again then immediately release the mouse button
after the move: the event will be thrown without waiting on the 1s delay. It wasn't
the case before. The reset button now also throw the event on button release even if
a delay has been set to the slider, wasn't the case before.

I've also added a line of code in main.cc to let devs use the Gtk debug feature for
easiest debugging. Please tell if gtk_init() is a problem for you.

Reported by natureh.510 on 2012-11-04 11:33:29

Beep6581 commented 9 years ago
Jacques, do you think that this patch can be stabilized in a 1 (or 2) week delay? It
means that you have to make a pause in your constant dev effort ;). It would be nice
to include it in the upcoming Release. But if you feel that it's not stable (feature
wise), then it's better not to include it.

Reported by natureh.510 on 2012-11-04 11:40:04

Beep6581 commented 9 years ago
Good. I would prefer a period much shorter than that - something just longer than the
longest accidental/unintentional pause while dragging a slider, perhaps 0.2s or less.

Reported by entertheyoni on 2012-11-04 14:02:02

Beep6581 commented 9 years ago
Jacques, glad to see you back, and hope you are all well. Such an impressive extension
of the patch, Hombre, great job as well!
Some feedback, questions:

1. White Point Model - what happened to option "Equal"? it is still in the tooltip.

2. UI labels don't need "'" - "Scene Conditions", "White Point Model"

3. Saturation (S)=-100 sets saturated colors to black. This is only when Algorithm=All.
This problem does not occur when Algorithm=JS

4. Viewing Conditions
4a. Adaptation Luminosity slider does not cause any visible effect.
4b. Why output device's WB and Luminance are in the preferences? Shouldn't this be
under the Viewing conditions?
4.c Currently the effects of Surround options are for luminous image sources, not for
reflective image sources - prints. In the previous versions of the patch effect of
Surround was the opposite, thus suitable for Print output. 
May be there should be a new drop down "Output Type"=Tranmissive/Print and effects
of Surround would be modulated by it? 

5. The new UI lag is nice to have for slow machines and I would have especially appreciated
it a few months ago:) Going forward, let's restrict it to only very calculation-intensive
sliders.

Reported by michaelezra000 on 2012-11-04 15:04:46

Beep6581 commented 9 years ago
Correction for 4c. "Output Type"=Luminous/Print

Reported by michaelezra000 on 2012-11-04 15:13:59

Beep6581 commented 9 years ago
Hello Michael

Thank you for this review ...:)

I corrected the label to "scene conditions" and "white point model"
I also corrected for "saturation" in mode "all".

1. "equal" disappeared, it was completely redundant with WB [RT] + output (I correct
tooltip)

4a. the cursor has an effect: look at the histogram
4b. Why output device's luminance and WB are in the preferences? These are two settings
that are generally constant for a user (see the tutorial ... in French)
4c. the previous settings were totally wrong ... but when I came to realize I was in
the hospital!
There is no difference for "Transmissive/Luminous/ Print" ... (see tutorial)

:)

Reported by jdesmis on 2012-11-04 16:12:13