Files
rawTherapee/rtengine/iccmatrices.h
Desmis 8d0333120e Research and development - WB auto -temperature correlation - tests - finding the optimum settings (#6643)
* Change estimchrom estim hue final

* Itcw observer checkbox

* 8 spectral colors

* 11 spectral colors

* 6 spectral colors

* Small change to correction green

* Fixed various bad behavior - settings itcwb_deltaspec

* 4 spectral colors green

* 3 green spectral colors

* 3 spectral colors green

* 5 spectral colors red green

* 3 spectral colors red green

* 3 spectral colrs green red

* Chnage slider choice deltaE - to size color patch

* display more info in console

* Display more info in console - comment code

* Clean - comment code

* 8 spectral colors green red

* 8 spectral colors blue

* 8 spectral colors blue

* 3 spectral colors

* 6 spectral colors

* 4 spectal colors

* 2 spectral colors

* Eliminate high Y - increse temp iteration - recenter selection inside patch

* compatibility 5.9

* Modify dislay and place selected dats in patch

* Dispaly in console hue chroma image selection

* First optimization

* optimization code - clean unused variables

* Remove sorted in chroma order - some others changes

* 5.9 compatibility

* Clean and optimize code

* Clean code - more display info in console

* More info in console - set itcwb_minsize in option

* Display patch chroma in GUI

* Change some default settings

* Minsize patch GUI

* Display GUI patch size

* Chroma patch variations

* Display in GUI min and max dats found in patch

* Some adjustments

* Remove too low datas in patch

* Various improvment - ponderate

* Clean code colortemp comment spectral datas

* Comment code - correc gren

* Comment and refine code

* Fixed bug in improcoordinator

* fixes a malfunction of AWB bias in improcoordinator

* Various improvments - clean code

* 2 improvments green and find patch

* Allows parametrind ponder and Ypurple in options

* Update autowb - filter on magenta purple

* Clean and optimize code

* Read colors in GUI

* Denoise median 5x5 image datas before Itcwb

* Change to GUI

* Replace median5x5 by 2 median3x3 - clean GUI code

* Work around to recalculate wbauto

* Remove work around - change params->wb related change

* Disabled low_sampling 5.9

* First try for compatibility Low sampling 5.9

* Re-enable WB autogrey

* Change reference image to autogrey if camera settings probably out

* Clean code aand adjust settings camera out

* Format astylert rawimagesource.cc - various small adjustments

* Small correction

* Small green correction

* Change default settings - correction to autowb bias in improccoordinator

* Save provisory work

* Save provisory work 2

* Try to find good tempitc with iterate when temptitc very different 5000K

* Change 2 default settings

* Work around awb temp bias

* Limit work around bias - small other changes

* 3 spectral colors deep blue

* 4 spectral color deep blue

* 4 color spectral yellow

* 5 spectral colors neutral red-magenta

* 5 spectral color neutral red magenta

* Change threshold tempitc

* 5.9 compatibility

* Work around bad claculation Planck's formula

* Fixed bad behavior when using blackbody spectal

* 6 spectral color - checkbutton remove 2 passes

* Fixed various bugs

* Format rawimagesource.cc

* Various improvment before to find the good selection

* First new optimization (perhaps?)

* Display GUI patc deltaE

* Various optimzation and tooltip

* Default observer 2°- Simplify GUI - improve display GUI - remove too low numbers datas

* 4 spectral colors - change 2 settings

* Change calculation threshold 2 passes

* 6 spectral colors magenta

* 13 spectral colors

* Improvment GUI display

* remove checkbutton no_purple

* 2 spectral colors - remove in GUI low sampling 5.9

* Change default setting display in console

* Change behavior when temp near stdA

* 4 spectral colors - settings Itcwb_tempstdA

* Gamut control on image histogram

* Clean code and format rawimagesource.cc

* Comment and format colortemp.cc

* Remove unused fileds from GUI - change tooltips

* Add tooltips

* Various changes

* Change settings when camera temperature is out

* improvment extra and tooltip

* Small change when using auto grey as start reference

* Remove itcwb_fgreen from GUI

* Various change - and 'unsatisfactory' test to take into account Custom

* Change second temp when < 4000 - replace automatic by automatic and refinement

* Neutralize 'Use custom tempertaure and green'

* Green refinement

* Clean code - small changes

* Other clean code

* Added forgotten itcw_green in procparams.cc

* Fixed a bug dispaly deltaE

* Change threshold settings - change code for Custom

* various change in case of using camera settings

* Change way to estimate range green

* clean code and message in console

* Clean and optimize

* Disable 2 passes if custom

* Improve GUI 2 passes

* Increase sampling and number of temperature above 9400K

* Hide AWB temperature bais and green refinement when Custom temerature ans green

* marks out the code with past time markers

* Improve time processing with spectral colors temp calculations

* Replace in console msec by nsec

* Scan temp 5.9

* Change max temp and behavior if temp > 15000k

* Refine temp near 14000K

* Increase sampling temperature 132 to 167

* Increase sampling temperature

* Set in preference choice for itcwb_custom

* White point calculated  with observer instead of table

* More on whitepoint calculation - informations

* Clean and format code with astyle colortemp.cc rawimagesource.cc improccoordinator.cc

* Small change tooltip

* Improve update auto-wb

* Remove 'use custom temperature and tin' - simplify sampling to 2 choice

* Small change to rand AWB bias - green refinement - tooltips

* slightly modify the parameters upstream of the algo - do not use camera in some cases

* Mixed initial green

* Refine init green and temp when no camera

* Refine temp and green in do not use camera settings

* Change tint threshold and various improvments (tooltips, wrong values..)

* Refinment and clean code

* Improve mode No use camera settings

* Init nocam

* Refine use no camera  settings

* Small change

* 5.9 compatibility - and format

* Refine sampling temperature  around 7000 - 8000K

* Format astylert rawimagesource colortemp

* 5.9 settings

* 5.9 settings 2

* Various change - 5.9 - format

* Improve pre and post algorithm

* Fixed correction temp > 8000K

* Fixed bad behavior Tppat.minchroma

* Change sampling choices and tooltip

* Change name wp wp2 wip to wb wb2 iwb to avoid misunderstood

* Small Change settings - limit display studgood to 0.0001

* Improvment display GUI temp

* Change default sampling

* Change ACESP0 to JDCmax

* Improve GUI abstract profile

* Allows dispaly in console xy values thanks to Reffort

* Remove bruce rgb in wp and abstract

* Change wp abstract and save itcwb with dispaly cellxy

* Change prim = 13 improccoordinator iplab2rgb

* remove display datas in console - fixed wrong display Y xyY

* Fixed ifferences in GUI maxhist minhist

* Change limits x y in function sampling

* fixed a dizziness

* Change  after algorithm rule when temp > 6000K

* Harmonize limx limy for oldsampling 5.9

* Added Cam xyz matrix to sampling - thanks to Reffort

* Display in console xyz matrix

* Forgotten instruction when mix camera and autowb grey

* Change rgbloc with Camera matrix Dcraw when no input profile

* Change rep to repref in rgbxyz

* Remove message in console

* 5.9 compat

* 5.9 compat 2

* 5.9 compat 3

* 5.9 compat 4

* 5.9 compat 5 format

* 5.9 compta 6

* Improve code

* Diasble itcwb_sampling in GUI

* Comment code

* Clean and comment code

* 5 spectral colors

* 9 spectral colors

* 2 spectral colors

* Various improvments

* 5 spectral colors

* 5 spectral colors

* First changes review lawrence37

* Second changes review Lawrence37

* 3rd changes review Lawrence37

* 4th changes review Lawrence37

* Change windows and appimage yml

* Re-enable Rtv4_Bruce in procparams.cc

* test for 5.9 compatibility

* Try to fixed crash

* Slightly improve the management of 5.9

* test for 5.9 compatibility by passing parameters via the GUI

* Forgotten parameter

* Change ref_spec limit and remove pac_start for itcwb_sampling

* Puts back the old Planck formula - the same as in dev

* Revert "test for 5.9 compatibility by passing parameters via the GUI"

This reverts commit d6b5a8feda31b93a5574cee6ebf4d3e9d58bbcfb.

* Switch to new ITCWB only when changing WB method

Prevents sudden changing of the white balance if ITCWB is selected and
the image is reopened.

* Fix spelling in comment

* Suggested change from Lawrence37 to whitebalance - small change to improcoordinator

* tempbias Set_sentive(false) if itcwb_smapling - clean whitebalance

* Another clean whitebalance.cc

---------

Co-authored-by: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com>
2023-08-06 13:44:48 +02:00

311 lines
9.7 KiB
C++

/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
// Bradford transform between illuminants
constexpr double d65_d50[3][3] = {
{0.9555766, -0.0230393, 0.0631636},
{ -0.0282895, 1.0099416, 0.0210077},
{0.0122982, -0.0204830, 1.3299098}
};
constexpr double d50_d65[3][3] = {
{ 1.0478112, 0.0228866, -0.0501270},
{0.0295424, 0.9904844, -0.0170491},
{ -0.0092345, 0.0150436, 0.7521316}
};
//J.Desmis 04 2018
constexpr double d50_d60[3][3] = {
{ 1.034368, 0.016908, -0.037658},
{0.021752, 0.992183, -0.012785},
{ -0.006971, 0.011377, 0.812150}
};
constexpr double d60_d50[3][3] = {
{ 0.96743198, -0.01699717, 0.044590689},
{-0.02109893, 1.008067172, 0.014890785},
{0.008598998, -0.01426777, 1.231474467}
};
// Color space conversion to/from XYZ; color spaces adapted to D65
constexpr double xyz_sRGBd65[3][3] = {
{0.4124564, 0.3575761, 0.1804375},
{0.2126729, 0.7151522, 0.0721750}, // WARNING: the summ of this line is > 1.0
{0.0193339, 0.1191920, 0.9503041}
};
constexpr double sRGBd65_xyz[3][3] = {
{ 3.2404542, -1.5371385, -0.4985314},
{ -0.9692660, 1.8760108, 0.0415560},
{0.0556434, -0.2040259, 1.0572252}
};
//%%%%%%%%%%%%%%%%%%%%%%%%
// TEST using Gabor's matrices
/*constexpr double xyz_sRGB[3][3] = {
{0.435859, 0.385336, 0.143023},
{0.222385, 0.717021, 0.0605936 },
{0.0139162, 0.0971389, 0.713817}};
constexpr double sRGB_xyz[3][3] = {
{3.13593293538656, -1.61878246026431, -0.490913888760734},
{-0.978702373022194, 1.91609508555177, 0.0334453372795315},
{0.0720490013929888, -0.22919049060526, 1.40593851447263}};*/
//%%%%%%%%%%%%%%%%%%%%%%%%
// Color space conversion to/from XYZ; color spaces adapted to D50 using Bradford transform
constexpr double xyz_sRGB[3][3] = {
{0.4360747, 0.3850649, 0.1430804},
{0.2225045, 0.7168786, 0.0606169},
{0.0139322, 0.0971045, 0.7141733}
};
constexpr double xyz_ACESp0[3][3] = {
{0.9908526, 0.0122334, -0.0388654},
{0.3618807, 0.72255045 , -0.0843859},
{-0.0027093, 0.0082323, 0.8196880}
};
constexpr double ACESp0_xyz[3][3] = {
{1.01583320, -0.01772807, 0.04634052},
{-0.50781231, 1.39131494 , 0.11915641},
{0.00845768, -0.01403193, 1.21893277}
};
constexpr double xyz_jdcmax[3][3] = {//prim red 0.734702 0.265302 gr 0.021908 0.930288 bl 0.120593 0.001583
{0.8394088, 0.0163780, 0.1084133},
{0.3031122, 0.6954651, 0.0014227},
{-0.000048, 0.0357376, 0.7891671}
};
constexpr double jdcmax_xyz[3][3] = {
{1.1984508, -0.0197646, -0.1646037},
{-0.5223824, 1.4466349, 0.0691553},
{0.0236634, -0.0655113, 1.2640260}
};
constexpr double xyz_ACESp1[3][3] = {
{0.689697, 0.149944, 0.124559},
{0.284448, 0.671758 , 0.043794},
{-0.006043, 0.009998, 0.820945}
};
constexpr double ACESp1_xyz[3][3] = {
{1.5932624, -0.352316, -0.222945},
{-0.6759496, 1.639286 , 0.01511026},
{0.0199602, -0.0225577, 1.2162833}
};
constexpr double sRGB_xyz[3][3] = {
{3.1338561, -1.6168667, -0.4906146},
{ -0.9787684, 1.9161415, 0.0334540},
{0.0719453, -0.2289914, 1.4052427}
};
constexpr double xyz_adobe[3][3] = {
{0.6097559, 0.2052401, 0.1492240},
{0.3111242, 0.6256560, 0.0632197},
{0.0194811, 0.0608902, 0.7448387}
};
constexpr double adobe_xyz[3][3] = {
{1.9624274, -0.6105343, -0.3413404},
{ -0.9787684, 1.9161415, 0.0334540},
{0.0286869, -0.1406752, 1.3487655}
};
constexpr double xyz_prophoto[3][3] = {
{0.7976749, 0.1351917, 0.0313534},
{0.2880402, 0.7118741, 0.0000857},
{0.0000000, 0.0000000, 0.8252100}
};
constexpr double prophoto_xyz[3][3] = {
{1.3459433, -0.2556075, -0.0511118},
{ -0.5445989, 1.5081673, 0.0205351},
{0.0000000, 0.0000000, 1.2118128}
};
/*
constexpr double xyz_rec2020[3][3] = {
{0.636958, 0.144617, 0.168881},
{0.262700, 0.677998, 0.059302},
{0.0000000, 0.028073, 1.060985}
};
constexpr double rec2020_xyz[3][3] = {
{1.716651, -0.355671, -0.253366},
{ -0.666684, 1.616481, 0.015769},
{0.017640, -0.042771, 0.942103}
};
*/
constexpr double xyz_rec2020[3][3] = {
{0.6734241, 0.1656411, 0.1251286},
{0.2790177, 0.6753402, 0.0456377},
{ -0.0019300, 0.0299784, 0.7973330}
};
constexpr double rec2020_xyz[3][3] = {
{1.6473376, -0.3935675, -0.2359961},
{ -0.6826036, 1.6475887, 0.0128190},
{0.0296524, -0.0628993, 1.2531279}
};
constexpr double xyz_widegamut[3][3] = {
{0.7161046, 0.1009296, 0.1471858},
{0.2581874, 0.7249378, 0.0168748},
{0.0000000, 0.0517813, 0.7734287}
};
constexpr double widegamut_xyz[3][3] = {
{ 1.4628067, -0.1840623, -0.2743606},
{ -0.5217933, 1.4472381, 0.0677227},
{0.0349342, -0.0968930, 1.2884099}
};
constexpr double xyz_bruce[3][3] = {
{0.4941816, 0.3204834, 0.1495550},
{0.2521531, 0.6844869, 0.0633600},
{0.0157886, 0.0629304, 0.7464909}
};
constexpr double bruce_xyz[3][3] = {
{2.6502856, -1.2014485, -0.4289936},
{ -0.9787684, 1.9161415, 0.0334540},
{0.0264570, -0.1361227, 1.3458542}
};
constexpr double xyz_beta[3][3] = {
{0.6712537, 0.1745834, 0.1183829},
{0.3032726, 0.6637861, 0.0329413},
{0.0000000, 0.0407010, 0.7845090}
};
constexpr double beta_xyz[3][3] = {
{1.6832270, -0.4282363, -0.2360185},
{ -0.7710229, 1.7065571, 0.0446900},
{0.0400013, -0.0885376, 1.2723640}
};
constexpr double xyz_best[3][3] = {
{0.6326696, 0.2045558, 0.1269946},
{0.2284569, 0.7373523, 0.0341908},
{0.0000000, 0.0095142, 0.8156958}
};
constexpr double best_xyz[3][3] = {
{1.7552599, -0.4836786, -0.2530000},
{ -0.5441336, 1.5068789, 0.0215528},
{0.0063467, -0.0175761, 1.2256959}
};
/*
constexpr double sRGB_d50[3][3] = {
{0.4360520246092, 0.2224915978656, 0.0139291219896},
{0.38508159282, 0.716886060114, 0.09709700166},
{0.1430874138552, 0.0606214863936, 0.714185469944}
};
constexpr double d50_sRGB[3][3] = {
{3.13405134405167,-0.978762729953942, 0.0719425766617001},
{-1.61702771153574,1.91614222810656, -0.228971178679309},
{-0.49065220876631,0.0334496273068589, 1.40521830559074}
};
*/
/*
// Gabor's matrices
constexpr double sRGB_d50[3][3] = {
{0.435859, 0.222385, 0.0139162},
{0.385336, 0.717021, 0.0971389},
{0.143023, 0.0605936, 0.713817}
};
constexpr double d50_sRGB[3][3] = {
{3.13593293538656, -0.978702373022194, 0.0720490013929888},
{-1.61878246026431, 1.91609508555177, -0.22919049060526},
{-0.490913888760734, 0.0334453372795315, 1.40593851447263}
};
constexpr double adobe_d50[3][3] = {
{0.6097395054954, 0.3111142944042, 0.0194773131652},
{0.2052518325737, 0.6256618480686, 0.0608872306106},
{0.1492308013399, 0.0632241329247, 0.744846530711}
};
constexpr double d50_adobe[3][3] = {
{1.9624959949628, -0.978762712052774, 0.0286904764959749},
{-0.610587687828765,1.91614073756734, -0.140667763143042},
{-0.34136021627766, 0.0334501217627688, 1.34875045144924}
};
constexpr double prophoto_d50[3][3] = {
{0.797675, 0.288040, 0.000000},
{0.135192, 0.711874, 0.000000},
{0.0313534,0.000086, 0.825210}
};
constexpr double d50_prophoto[3][3] = {
{1.34594335079331, -0.544598514291158, 0},
{-0.255608118122657, 1.50816768465213, 0},
{-0.0511117387775285, 0.0205345459181255, 1.21181275069376}
};
constexpr double widegamut_d50[3][3] = {
{0.716105, 0.258187, 0.000000},
{0.100930, 0.724938, 0.0517813},
{0.147186, 0.0168748, 0.773429}
};
constexpr double d50_widegamut[3][3] = {
{1.46280597103052, -0.521792197260068, 0.0349341417298585},
{-0.184062984909417, 1.44723786022891, -0.0968930022172314},
{-0.27436071519732, 0.0677226440980744,1.28840945122198}
};
constexpr double bruce_d50[3][3] = {
{0.4941607255908, 0.2521412970174, 0.0157852934504},
{0.3204990468435, 0.684494580042, 0.062927176507},
{0.1495612990809, 0.0633643619597, 0.746498914581}
};
constexpr double d50_bruce[3][3] = {
{2.65042308164152, -0.978762745761462, 0.0264609493245811},
{-1.20155941925411, 1.9161402914007, -0.136115844662896},
{-0.42902228923717, 0.0334495071197919, 1.34583900936772}
};
constexpr double beta_d50[3][3] = {
{0.671254, 0.303273, 0.000000},
{0.174583, 0.663786, 0.040701},
{0.118383, 0.0329413, 0.784509}
};
constexpr double d50_beta[3][3] = {
{1.68322591962771, -0.771023599950842, 0.0400013658754702},
{-0.428235060337656, 1.70655704781303, -0.0885376438040078},
{-0.236018598193503, 0.0446902191738489,1.27236406897742}
};
constexpr double best_d50[3][3] = {
{0.632670, 0.228457, 0.000000},
{0.204556, 0.737352, 0.00951424},
{0.126995, 0.0341908, 0.815696}
};
constexpr double d50_best[3][3] = {
{1.75525923340349, -0.544133953997468, 0.00634675299435191},
{-0.483679025800866, 1.50687975713407, -0.017576175021718},
{-0.253000840399762, 0.0215532098817316,1.22569552576991}
};
*/