add selected TRC to FOIP

This commit is contained in:
Desmis 2018-04-10 15:29:05 +02:00
parent b5f4cbd728
commit dedce5d383
8 changed files with 115 additions and 31 deletions

View File

@ -1595,7 +1595,7 @@ TP_FLATFIELD_LABEL;Flat-Field
TP_GAMMA_CURV;Gamma TP_GAMMA_CURV;Gamma
TP_GAMMA_FREE;Free Output Integrate Profile (FOIP) TP_GAMMA_FREE;Free Output Integrate Profile (FOIP)
TP_GAMMA_PRIM;Primaries Output profile TP_GAMMA_PRIM;Primaries Output profile
TP_GAMMA_OUTPUT;Output gamma TP_GAMMA_OUTPUT;Gamma - TRC
TP_GAMMA_PROF;Generate ICC profile TP_GAMMA_PROF;Generate ICC profile
TP_GAMMA_PROF_NONE;none TP_GAMMA_PROF_NONE;none
TP_GAMMA_PROF_V2;ICC V2 TP_GAMMA_PROF_V2;ICC V2

View File

@ -199,7 +199,7 @@ cmsHPROFILE createXYZProfile()
const double(*wprofiles[])[3] = {xyz_sRGB, xyz_adobe, xyz_prophoto, xyz_widegamut, xyz_bruce, xyz_beta, xyz_best, xyz_rec2020, xyz_ACESc}; const double(*wprofiles[])[3] = {xyz_sRGB, xyz_adobe, xyz_prophoto, xyz_widegamut, xyz_bruce, xyz_beta, xyz_best, xyz_rec2020, xyz_ACESc};
const double(*iwprofiles[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz, bruce_xyz, beta_xyz, best_xyz, rec2020_xyz, ACESc_xyz}; const double(*iwprofiles[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz, bruce_xyz, beta_xyz, best_xyz, rec2020_xyz, ACESc_xyz};
const char* wpnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB", "Rec2020", "ACESc"}; const char* wpnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB", "Rec2020", "ACESc"};
const char* wpgamma[] = {"default", "BT709_g2.2_s4.5", "sRGB_g2.4_s12.92", "linear_g1.0", "standard_g2.2", "standard_g1.8", "High_g1.3_s3.35", "Low_g2.6_s6.9"}; //gamma free const char* wpgamma[] = {"Free", "BT709_g2.2_s4.5", "sRGB_g2.4_s12.92", "linear_g1.0", "standard_g2.2", "standard_g1.8", "High_g1.3_s3.35", "Low_g2.6_s6.9", "Lab_g3.0s9.03296"}; //gamma free
//default = gamma inside profile //default = gamma inside profile
//BT709 g=2.22 s=4.5 sRGB g=2.4 s=12.92 //BT709 g=2.22 s=4.5 sRGB g=2.4 s=12.92
//linear g=1.0 //linear g=1.0
@ -1067,7 +1067,7 @@ void rtengine::ICCStore::getGammaArray(const procparams::ColorManagementParams &
{ {
const double eps = 0.000000001; // not divide by zero const double eps = 0.000000001; // not divide by zero
if (!icm.freegamma) {//if Free gamma not selected if (icm.freegamma && icm.gamma != "Free") { //if Free gamma selected with other than Free
// gamma : ga[0],ga[1],ga[2],ga[3],ga[4],ga[5] by calcul // gamma : ga[0],ga[1],ga[2],ga[3],ga[4],ga[5] by calcul
if (icm.gamma == "BT709_g2.2_s4.5") { if (icm.gamma == "BT709_g2.2_s4.5") {
ga[0] = 2.22; //BT709 2.2 4.5 - my preferred as D.Coffin ga[0] = 2.22; //BT709 2.2 4.5 - my preferred as D.Coffin
@ -1105,6 +1105,13 @@ void rtengine::ICCStore::getGammaArray(const procparams::ColorManagementParams &
ga[2] = 0.; ga[2] = 0.;
ga[3] = 1. / eps; ga[3] = 1. / eps;
ga[4] = 0.; ga[4] = 0.;
} else if (icm.gamma == "Lab_g3.0s9.03296") {
ga[0] = 3.0; //Lab gamma =3 slope=9.03296
ga[1] = 0.8621;
ga[2] = 0.1379;
ga[3] = 0.1107;
ga[4] = 0.08;
} else { /* if (icm.gamma == "linear_g1.0") */ } else { /* if (icm.gamma == "linear_g1.0") */
ga[0] = 1.0; //gamma=1 linear : for high dynamic images(cf : D.Coffin...) ga[0] = 1.0; //gamma=1 linear : for high dynamic images(cf : D.Coffin...)
ga[1] = 1.; ga[1] = 1.;
@ -1455,6 +1462,7 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
Glib::ustring outProfile; Glib::ustring outProfile;
cmsHPROFILE outputProfile = nullptr; cmsHPROFILE outputProfile = nullptr;
Glib::ustring outPr; Glib::ustring outPr;
Glib::ustring gammaStr;
if (icm.freegamma && icm.gampos < 1.35) { if (icm.freegamma && icm.gampos < 1.35) {
@ -1463,7 +1471,7 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
pro = true; //pro=0 RT_sRGB || Prophoto pro = true; //pro=0 RT_sRGB || Prophoto
} }
//necessary for V2 profile //necessary for V2 profile
if (icm.wprimari == "ProPhoto" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.prophoto) && !pro) { if (icm.wprimari == "ProPhoto" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.prophoto) && !pro) {
outProfile = options.rtSettings.prophoto; outProfile = options.rtSettings.prophoto;
outPr = "RT_large"; outPr = "RT_large";
@ -1538,32 +1546,52 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
mlu = cmsMLUalloc(ContextID, 1); mlu = cmsMLUalloc(ContextID, 1);
Glib::ustring outPro; Glib::ustring outPro;
if (icm.gamma == "High_g1.3_s3.35") {
gammaStr = "_High_g=1.3_s=3.35";
} else if (icm.gamma == "Low_g2.6_s6.9") {
gammaStr = "_Low_g=2.6_s=6.9";
} else if (icm.gamma == "sRGB_g2.4_s12.92") {
gammaStr = "_sRGB_g=2.4_s=12.92";
} else if (icm.gamma == "BT709_g2.2_s4.5") {
gammaStr = "_BT709_g=2.2_s=4.5";
} else if (icm.gamma == "linear_g1.0") {
gammaStr = "_Linear_g=1.0";
} else if (icm.gamma == "standard_g2.2") {
gammaStr = "_g=2.2";
} else if (icm.gamma == "standard_g1.8") {
gammaStr = "_g=1.8";
} else if (icm.gamma == "Lab_g3.0s9.03296") {
gammaStr = "_LAB_g3.0_s9.03296";
}
// instruction with //ICC are used to generate ICC profile // instruction with //ICC are used to generate ICC profile
if (mlu == nullptr) { if (mlu == nullptr) {
printf("Description error\n"); printf("Description error\n");
} else { } else {
// Description TAG : selection of gamma and Primaries // Description TAG : selection of gamma and Primaries
if (!icm.freegamma) { if (icm.freegamma && icm.gamma != "Free") {
std::wstring gammaStr; /*
// std::wstring gammaStr;
if (icm.gamma == "High_g1.3_s3.35") { if (icm.gamma == "High_g1.3_s3.35") {
gammaStr = std::wstring(L"GammaTRC: High g=1.3 s=3.35"); gammaStr = "_TRC: High g=1.3 s=3.35";
} else if (icm.gamma == "Low_g2.6_s6.9") { } else if (icm.gamma == "Low_g2.6_s6.9") {
gammaStr = std::wstring(L"GammaTRC: Low g=2.6 s=6.9"); gammaStr = "_TRC: Low g=2.6 s=6.9";
} else if (icm.gamma == "sRGB_g2.4_s12.92") { } else if (icm.gamma == "sRGB_g2.4_s12.92") {
gammaStr = std::wstring(L"GammaTRC: sRGB g=2.4 s=12.92"); gammaStr = "_TRC: sRGB g=2.4 s=12.92";
} else if (icm.gamma == "BT709_g2.2_s4.5") { } else if (icm.gamma == "BT709_g2.2_s4.5") {
gammaStr = std::wstring(L"GammaTRC: BT709 g=2.2 s=4.5"); gammaStr = "_TRC: BT709 g=2.2 s=4.5";
} else if (icm.gamma == "linear_g1.0") { } else if (icm.gamma == "linear_g1.0") {
gammaStr = std::wstring(L"GammaTRC: Linear g=1.0"); gammaStr = "_TRC: Linear g=1.0";
} else if (icm.gamma == "standard_g2.2") { } else if (icm.gamma == "standard_g2.2") {
gammaStr = std::wstring(L"GammaTRC: g=2.2"); gammaStr = "GammaTRC: g=2.2";
} else if (icm.gamma == "standard_g1.8") { } else if (icm.gamma == "standard_g1.8") {
gammaStr = std::wstring(L"GammaTRC: g=1.8"); gammaStr = "GammaTRC: g=1.8";
} }
*/
//cmsMLUsetWide(mlu, "en", "US", gammaStr.c_str());
cmsMLUsetWide(mlu, "en", "US", gammaStr.c_str());
} else { } else {
/* /*
// create description with gamma + slope + primaries // create description with gamma + slope + primaries
@ -1709,25 +1737,43 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
// create description with gamma + slope + primaries // create description with gamma + slope + primaries
std::wostringstream gammaWs; std::wostringstream gammaWs;
//std::string gammaWsICC; //std::string gammaWsICC;
std::wstring gammaStrICC; std::wstring gammaStrIC;
gammaWs.precision(6); gammaWs.precision(6);
if (icm.wprofile == "v4") { if (icm.gamma == "Free") {
outPro = outPr + "_FOIP_V4_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc"; if (icm.wprofile == "v4") {
} else if (icm.wprofile == "v2") { outPro = outPr + "_FOIP_V4_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc";
outPro = outPr + "_FOIP_V2_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc"; } else if (icm.wprofile == "v2") {
outPro = outPr + "_FOIP_V2_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc";
}
gammaWs << outPro.c_str() << (float)icm.gampos << " s=" << (float)icm.slpos;
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str());
} else {
if (icm.wprofile == "v4") {
outPro = outPr + "_FOIP_V4_" + gammaStr + ".icc";
} else if (icm.wprofile == "v2") {
outPro = outPr + "_FOIP_V2_" + gammaStr + ".icc";
}
gammaWs << outPro.c_str() << " s=";
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str());
} }
gammaWs << outPro.c_str() << (float)icm.gampos << " s=" << (float)icm.slpos;
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str());
cmsMLU *copyright = cmsMLUalloc(NULL, 1); cmsMLU *copyright = cmsMLUalloc(NULL, 1);
cmsMLUsetASCII(copyright, "en", "US", "No copyright Rawtherapee"); cmsMLUsetASCII(copyright, "en", "US", "No copyright Rawtherapee");
cmsWriteTag(outputProfile, cmsSigCopyrightTag, copyright); cmsWriteTag(outputProfile, cmsSigCopyrightTag, copyright);
cmsMLUfree(copyright); cmsMLUfree(copyright);
} }
cmsMLU *descrip = cmsMLUalloc(NULL, 1); cmsMLU *descrip = cmsMLUalloc(NULL, 1);
cmsMLUsetASCII(descrip, "en", "US", "Rawtherapee"); cmsMLUsetASCII(descrip, "en", "US", "Rawtherapee");
cmsWriteTag(outputProfile, cmsSigDeviceModelDescTag, descrip); cmsWriteTag(outputProfile, cmsSigDeviceModelDescTag, descrip);

View File

@ -93,7 +93,7 @@ ImProcCoordinator::ImProcCoordinator ()
fw (0), fh (0), tr (0), fw (0), fh (0), tr (0),
fullw (1), fullh (1), fullw (1), fullh (1),
pW (-1), pH (-1), pW (-1), pH (-1),
plistener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), awbListener (nullptr), frameCountListener (nullptr), imageTypeListener (nullptr), actListener (nullptr), adnListener (nullptr), awavListener (nullptr), dehaListener (nullptr), hListener (nullptr), plistener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), awbListener (nullptr), icmListener (nullptr), frameCountListener (nullptr), imageTypeListener (nullptr), actListener (nullptr), adnListener (nullptr), awavListener (nullptr), dehaListener (nullptr), hListener (nullptr),
resultValid (false), lastOutputProfile ("BADFOOD"), lastOutputIntent (RI__COUNT), lastOutputBPC (false), thread (nullptr), changeSinceLast (0), updaterRunning (false), destroying (false), utili (false), autili (false), resultValid (false), lastOutputProfile ("BADFOOD"), lastOutputIntent (RI__COUNT), lastOutputBPC (false), thread (nullptr), changeSinceLast (0), updaterRunning (false), destroying (false), utili (false), autili (false),
butili (false), ccutili (false), cclutili (false), clcutili (false), opautili (false), wavcontlutili (false), colourToningSatLimit (0.f), colourToningSatLimitOpacity (0.f), highQualityComputed (false) butili (false), ccutili (false), cclutili (false), clcutili (false), opautili (false), wavcontlutili (false), colourToningSatLimit (0.f), colourToningSatLimitOpacity (0.f), highQualityComputed (false)
{} {}

View File

@ -159,6 +159,7 @@ protected:
AutoCamListener* acListener; AutoCamListener* acListener;
AutoBWListener* abwListener; AutoBWListener* abwListener;
AutoWBListener* awbListener; AutoWBListener* awbListener;
ICMListener* icmListener;
FrameCountListener *frameCountListener; FrameCountListener *frameCountListener;
ImageTypeListener *imageTypeListener; ImageTypeListener *imageTypeListener;
@ -323,6 +324,11 @@ public:
{ {
awbListener = awb; awbListener = awb;
} }
void setICMListener (ICMListener* icml)
{
icmListener = icml;
}
void setAutoColorTonListener (AutoColorTonListener* bwct) void setAutoColorTonListener (AutoColorTonListener* bwct)
{ {
actListener = bwct; actListener = bwct;

View File

@ -348,6 +348,13 @@ public :
virtual void WBChanged (double temp, double green) = 0; virtual void WBChanged (double temp, double green) = 0;
}; };
class ICMListener
{
public :
virtual ~ICMListener() = default;
virtual void TRCChanged (double gamm, double slo) = 0;
};
class FrameCountListener class FrameCountListener
{ {
public : public :
@ -469,6 +476,7 @@ public:
virtual void setFrameCountListener (FrameCountListener* l) = 0; virtual void setFrameCountListener (FrameCountListener* l) = 0;
virtual void setAutoBWListener (AutoBWListener* l) = 0; virtual void setAutoBWListener (AutoBWListener* l) = 0;
virtual void setAutoWBListener (AutoWBListener* l) = 0; virtual void setAutoWBListener (AutoWBListener* l) = 0;
virtual void setICMListener (ICMListener* l) = 0;
virtual void setAutoColorTonListener (AutoColorTonListener* l) = 0; virtual void setAutoColorTonListener (AutoColorTonListener* l) = 0;
virtual void setAutoChromaListener (AutoChromaListener* l) = 0; virtual void setAutoChromaListener (AutoChromaListener* l) = 0;
virtual void setRetinexListener (RetinexListener* l) = 0; virtual void setRetinexListener (RetinexListener* l) = 0;

View File

@ -229,7 +229,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
wgamma = Gtk::manage(new MyComboBoxText()); wgamma = Gtk::manage(new MyComboBoxText());
gaHBox->pack_start(*wgamma, Gtk::PACK_EXPAND_WIDGET); gaHBox->pack_start(*wgamma, Gtk::PACK_EXPAND_WIDGET);
oVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET); // oVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET);
std::vector<Glib::ustring> wpgamma = rtengine::ICCStore::getGamma(); std::vector<Glib::ustring> wpgamma = rtengine::ICCStore::getGamma();
@ -267,6 +267,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
} }
wprimari->set_active(6); wprimari->set_active(6);
fgVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET);
gampos = Gtk::manage(new Adjuster(M("TP_GAMMA_CURV"), 1, 3.5, 0.00001, 2.4)); gampos = Gtk::manage(new Adjuster(M("TP_GAMMA_CURV"), 1, 3.5, 0.00001, 2.4));
gampos->setAdjusterListener(this); gampos->setAdjusterListener(this);
@ -617,12 +618,12 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
lastgamfree = pp->icm.freegamma; lastgamfree = pp->icm.freegamma;
if (!batchMode) { if (!batchMode) {
onames->set_sensitive(wgamma->get_active_row_number() == 0 && !pp->icm.freegamma); //"default" onames->set_sensitive(/*wgamma->get_active_row_number() == 0 &&*/ !pp->icm.freegamma); //"default"
wgamma->set_sensitive(!pp->icm.freegamma); wgamma->set_sensitive(pp->icm.freegamma);
gampos->set_sensitive(pp->icm.freegamma); gampos->set_sensitive(pp->icm.freegamma);
slpos->set_sensitive(pp->icm.freegamma); slpos->set_sensitive(pp->icm.freegamma);
updateRenderingIntent(pp->icm.output); updateRenderingIntent(pp->icm.output);
//wprimari->set_sensitive(!pp->icm.freegamma); wprimari->set_sensitive(pp->icm.freegamma);
} }
gampos->setValue(pp->icm.gampos); gampos->setValue(pp->icm.gampos);
@ -813,6 +814,13 @@ void ICMPanel::wprofileChanged()
void ICMPanel::gpChanged() void ICMPanel::gpChanged()
{ {
if (wgamma->get_active_row_number() == 0) {
gampos->set_sensitive(true);
slpos->set_sensitive(true);
} else {
gampos->set_sensitive(false);
slpos->set_sensitive(false);
}
if (listener) { if (listener) {
listener->panelChanged(EvGAMMA, wgamma->get_active_text()); listener->panelChanged(EvGAMMA, wgamma->get_active_text());
@ -931,6 +939,19 @@ void ICMPanel::applyHueSatMapChanged()
} }
} }
void ICMPanel::TRCChanged(double gamm, double slo)
{
GThreadLock lock;
disableListener();
setEnabled(true);
gampos->setValue(gamm);
slpos->setValue(slo);
gampos->setDefault(gamm);
slpos->setDefault(slo);
enableListener();
}
void ICMPanel::ipChanged() void ICMPanel::ipChanged()
{ {
@ -980,7 +1001,7 @@ void ICMPanel::GamChanged()
if (!batchMode) { if (!batchMode) {
onames->set_sensitive(false);//disabled choice onames->set_sensitive(false);//disabled choice
wgamma->set_sensitive(false); wgamma->set_sensitive(true);
gampos->set_sensitive(true); gampos->set_sensitive(true);
slpos->set_sensitive(true); slpos->set_sensitive(true);
wprimari->set_sensitive(true); wprimari->set_sensitive(true);
@ -991,8 +1012,9 @@ void ICMPanel::GamChanged()
listener->panelChanged(EvGAMFREE, M("GENERAL_DISABLED")); listener->panelChanged(EvGAMFREE, M("GENERAL_DISABLED"));
if (!batchMode) { if (!batchMode) {
onames->set_sensitive(wgamma->get_active_row_number() == 0); // onames->set_sensitive(wgamma->get_active_row_number() == 0);
wgamma->set_sensitive(true); onames->set_sensitive(true);
wgamma->set_sensitive(false);
gampos->set_sensitive(false); gampos->set_sensitive(false);
slpos->set_sensitive(false); slpos->set_sensitive(false);
wprimari->set_sensitive(false); wprimari->set_sensitive(false);

View File

@ -36,7 +36,7 @@ public:
virtual void saveInputICCReference(Glib::ustring fname, bool apply_wb) {} virtual void saveInputICCReference(Glib::ustring fname, bool apply_wb) {}
}; };
class ICMPanel : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel class ICMPanel : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::ICMListener
{ {
protected: protected:
@ -130,6 +130,7 @@ public:
void applyLookTableChanged(); void applyLookTableChanged();
void applyBaselineExposureOffsetChanged(); void applyBaselineExposureOffsetChanged();
void applyHueSatMapChanged(); void applyHueSatMapChanged();
void TRCChanged (double gamm, double slo);
void setRawMeta(bool raw, const rtengine::FramesData* pMeta); void setRawMeta(bool raw, const rtengine::FramesData* pMeta);
void saveReferencePressed(); void saveReferencePressed();

View File

@ -515,6 +515,7 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool
ipc->setAutoBWListener (blackwhite); ipc->setAutoBWListener (blackwhite);
ipc->setFrameCountListener (bayerprocess); ipc->setFrameCountListener (bayerprocess);
ipc->setAutoWBListener (whitebalance); ipc->setAutoWBListener (whitebalance);
ipc->setICMListener (icm);
ipc->setAutoColorTonListener (colortoning); ipc->setAutoColorTonListener (colortoning);
ipc->setAutoChromaListener (dirpyrdenoise); ipc->setAutoChromaListener (dirpyrdenoise);
ipc->setWaveletListener (wavelet); ipc->setWaveletListener (wavelet);