Retinex - Choice complexity Standard - Advanced (#5871)

* Enabled standard advanced for Retinex

* Added forgotten reset button
This commit is contained in:
Desmis 2020-08-05 10:21:14 +02:00 committed by GitHub
parent 2a31ed9dec
commit 2c3881f3a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 143 additions and 6 deletions

View File

@ -1216,6 +1216,7 @@ HISTORY_MSG_COLORTONING_LABREGION_SATURATION;CT - Saturation
HISTORY_MSG_COLORTONING_LABREGION_SHOWMASK;CT - region show mask
HISTORY_MSG_COLORTONING_LABREGION_SLOPE;CT - region slope
HISTORY_MSG_COMPLEX;Wavelet complexity
HISTORY_MSG_COMPLEXRETI;Retinex complexity
HISTORY_MSG_DEHAZE_DEPTH;Dehaze - Depth
HISTORY_MSG_DEHAZE_ENABLED;Haze Removal
HISTORY_MSG_DEHAZE_LUMINANCE;Dehaze - Luminance only

View File

@ -459,6 +459,7 @@ RetinexParams::RetinexParams() :
shadows(0),
stonalwidth(80),
radius(40),
complexmethod("normal"),
retinexMethod("high"),
retinexcolorspace("Lab"),
gammaretinex("none"),
@ -496,6 +497,7 @@ bool RetinexParams::operator ==(const RetinexParams& other) const
&& shadows == other.shadows
&& stonalwidth == other.stonalwidth
&& radius == other.radius
&& complexmethod == other.complexmethod
&& retinexMethod == other.retinexMethod
&& retinexcolorspace == other.retinexcolorspace
&& gammaretinex == other.gammaretinex
@ -5027,6 +5029,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->retinex.limd, "Retinex", "Limd", retinex.limd, keyFile);
saveToKeyfile(!pedited || pedited->retinex.highl, "Retinex", "highl", retinex.highl, keyFile);
saveToKeyfile(!pedited || pedited->retinex.skal, "Retinex", "skal", retinex.skal, keyFile);
saveToKeyfile(!pedited || pedited->retinex.complexmethod, "Retinex", "complexMethod", retinex.complexmethod, keyFile);
saveToKeyfile(!pedited || pedited->retinex.retinexMethod, "Retinex", "RetinexMethod", retinex.retinexMethod, keyFile);
saveToKeyfile(!pedited || pedited->retinex.mapMethod, "Retinex", "mapMethod", retinex.mapMethod, keyFile);
saveToKeyfile(!pedited || pedited->retinex.viewMethod, "Retinex", "viewMethod", retinex.viewMethod, keyFile);
@ -6497,6 +6500,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
if (keyFile.has_group("Retinex")) {
assignFromKeyfile(keyFile, "Retinex", "Median", pedited, retinex.medianmap, pedited->retinex.medianmap);
assignFromKeyfile(keyFile, "Retinex", "complexMethod", pedited, retinex.complexmethod, pedited->retinex.complexmethod);
assignFromKeyfile(keyFile, "Retinex", "RetinexMethod", pedited, retinex.retinexMethod, pedited->retinex.retinexMethod);
assignFromKeyfile(keyFile, "Retinex", "mapMethod", pedited, retinex.mapMethod, pedited->retinex.mapMethod);
assignFromKeyfile(keyFile, "Retinex", "viewMethod", pedited, retinex.viewMethod, pedited->retinex.viewMethod);

View File

@ -336,6 +336,7 @@ struct RetinexParams {
int stonalwidth;
int radius;
Glib::ustring complexmethod;
Glib::ustring retinexMethod;
Glib::ustring retinexcolorspace;
Glib::ustring gammaretinex;

View File

@ -60,6 +60,7 @@ void ParamsEdited::set(bool v)
retinex.mapcurve = v;
retinex.cdHcurve = v;
retinex.lhcurve = v;
retinex.complexmethod = v;
retinex.retinexMethod = v;
retinex.mapMethod = v;
retinex.viewMethod = v;
@ -711,6 +712,7 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
retinex.lhcurve = retinex.lhcurve && p.retinex.lhcurve == other.retinex.lhcurve;
retinex.transmissionCurve = retinex.transmissionCurve && p.retinex.transmissionCurve == other.retinex.transmissionCurve;
retinex.gaintransmissionCurve = retinex.gaintransmissionCurve && p.retinex.gaintransmissionCurve == other.retinex.gaintransmissionCurve;
retinex.complexmethod = retinex.complexmethod && p.retinex.complexmethod == other.retinex.complexmethod;
retinex.retinexMethod = retinex.retinexMethod && p.retinex.retinexMethod == other.retinex.retinexMethod;
retinex.mapMethod = retinex.mapMethod && p.retinex.mapMethod == other.retinex.mapMethod;
retinex.viewMethod = retinex.viewMethod && p.retinex.viewMethod == other.retinex.viewMethod;
@ -1917,6 +1919,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.retinex.gaintransmissionCurve = mods.retinex.gaintransmissionCurve;
}
if (retinex.complexmethod) {
toEdit.retinex.complexmethod = mods.retinex.complexmethod;
}
if (retinex.retinexMethod) {
toEdit.retinex.retinexMethod = mods.retinex.retinexMethod;
}

View File

@ -73,6 +73,7 @@ struct RetinexParamsEdited {
bool slope;
bool neigh;
bool offs;
bool complexmethod;
bool retinexMethod;
bool mapMethod;
bool viewMethod;

View File

@ -9,6 +9,7 @@
#include "rtimage.h"
#include "options.h"
#include "../rtengine/color.h"
#include "eventmapper.h"
using namespace rtengine;
using namespace rtengine::procparams;
@ -25,13 +26,26 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
nextsigma = 0.;
nextminT = 0.;
nextmaxT = 0.;
auto m = ProcEventMapper::getInstance();
EvReticomplex = m->newEvent(DEMOSAIC, "HISTORY_MSG_COMPLEXRETI");
const RetinexParams default_params;
// MAIN Expander ==================================================================
complexmethod = Gtk::manage (new MyComboBoxText ());
complexmethod->append(M("TP_WAVELET_COMPNORMAL"));
complexmethod->append(M("TP_WAVELET_COMPEXPERT"));
complexmethodconn = complexmethod->signal_changed().connect(sigc::mem_fun(*this, &Retinex::complexmethodChanged));
complexmethod->set_tooltip_text(M("TP_WAVELET_COMPLEX_TOOLTIP"));
Gtk::HBox* const complexHBox = Gtk::manage(new Gtk::HBox());
Gtk::Label* const complexLabel = Gtk::manage(new Gtk::Label(M("TP_WAVELET_COMPLEXLAB") + ":"));
complexHBox->pack_start(*complexLabel, Gtk::PACK_SHRINK, 4);
complexHBox->pack_start(*complexmethod);
pack_start(*complexHBox);
Gtk::Grid *retinexGrid = Gtk::manage ( new Gtk::Grid());
@ -116,7 +130,8 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
// MAP (MASK) Frame ---------------------------------------------------------------
Gtk::Frame *maskFrame = Gtk::manage (new Gtk::Frame (M ("TP_RETINEX_LABEL_MASK")) );
// Gtk::Frame *maskFrame = Gtk::manage (new Gtk::Frame (M ("TP_RETINEX_LABEL_MASK")) );
maskFrame = Gtk::manage (new Gtk::Frame (M ("TP_RETINEX_LABEL_MASK")) );
setExpandAlignProperties (maskFrame, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START);
Gtk::Grid *maskGrid = Gtk::manage ( new Gtk::Grid());
@ -384,7 +399,6 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
Gtk::Grid *tranGrid = Gtk::manage (new Gtk::Grid());
setExpandAlignProperties (tranGrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START);
const RetinexParams default_params;
// Transmission map curve
transmissionCurveEditorG = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_TRANSMISSION"));
@ -628,12 +642,14 @@ void Retinex::neutral_pressed ()
limd->resetValue (false);
highl->resetValue (false);
gam->resetValue (false);
skal->resetValue (false);
slope->resetValue (false);
highlights->resetValue (false);
h_tonalwidth->resetValue (false);
shadows->resetValue (false);
s_tonalwidth->resetValue (false);
radius->resetValue (false);
medianmap->set_active (false);
mapMethod->set_active (0);
viewMethod->set_active (0);
retinexMethod->set_active (2);
@ -742,7 +758,53 @@ void Retinex::updateTrans ()
}
}
void Retinex::convertParamToNormal()
{
const RetinexParams def_params;
disableListener();
iter->setValue(def_params.iter);
viewMethod->set_active(0);
mapMethod->set_active(0);
cdshape->reset();
cdshapeH->reset();
lhshape->reset();
transmissionShape->reset();
medianmap->set_active(def_params.medianmap);
enableListener();
}
void Retinex::updateGUIToMode(int mode)
{
if(mode ==0) {
iterFrame->hide();
maskFrame->hide();
equalFrame->hide();
viewMethod->hide();
mapMethod->hide();
transmissionCurveEditorG->hide();
medianmap->hide();
} else {
iterFrame->show();
maskFrame->show();
equalFrame->show();
viewMethod->show();
transmissionCurveEditorG->show();
medianmap->show();
mapMethod->show();
if (iter->getIntValue() > 1) {
grad->set_sensitive (true);
scal->set_sensitive (true);
grads->set_sensitive (true);
} else {
grad->set_sensitive (false);
scal->set_sensitive (false);
grads->set_sensitive (false);
}
}
}
void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
{
@ -752,6 +814,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
gammaretinexConn.block (true);
mapMethodConn.block (true);
viewMethodConn.block (true);
complexmethodconn.block (true);
if (pedited) {
@ -775,6 +838,9 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
shadows->setEditedState (pedited->retinex.shadows ? Edited : UnEdited);
s_tonalwidth->setEditedState (pedited->retinex.stonalwidth ? Edited : UnEdited);
if (!pedited->retinex.complexmethod) {
complexmethod->set_active_text (M ("GENERAL_UNCHANGED"));
}
if (!pedited->retinex.retinexMethod) {
retinexMethod->set_active_text (M ("GENERAL_UNCHANGED"));
@ -844,6 +910,13 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
medianmapConn.block (false);
lastmedianmap = pp->retinex.medianmap;
if (pp->retinex.complexmethod == "normal") {
complexmethod->set_active(0);
} else if (pp->retinex.complexmethod == "expert") {
complexmethod->set_active(1);
}
if (pp->retinex.retinexMethod == "low") {
retinexMethod->set_active (0);
} else if (pp->retinex.retinexMethod == "uni") {
@ -906,6 +979,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
mapMethodChanged ();
viewMethodChanged ();
medianmapConn.block (true);
medianmapChanged ();
medianmapConn.block (false);
@ -914,7 +988,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
cdshapeH->setCurve (pp->retinex.cdHcurve);
lhshape->setCurve (pp->retinex.lhcurve);
mapshape->setCurve (pp->retinex.mapcurve);
retinexMethodConn.block (false);
retinexColorSpaceConn.block (false);
gammaretinexConn.block (false);
@ -923,8 +997,18 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
transmissionShape->setCurve (pp->retinex.transmissionCurve);
gaintransmissionShape->setCurve (pp->retinex.gaintransmissionCurve);
complexmethodconn.block (false);
enableListener ();
if (complexmethod->get_active_row_number() == 0) {
updateGUIToMode(0);
// convertParamToNormal();
} else {
updateGUIToMode(1);
}
}
@ -961,6 +1045,7 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
pp->retinex.stonalwidth = (int)s_tonalwidth->getValue ();
if (pedited) {
pedited->retinex.complexmethod = complexmethod->get_active_text() != M ("GENERAL_UNCHANGED");
pedited->retinex.retinexMethod = retinexMethod->get_active_text() != M ("GENERAL_UNCHANGED");
pedited->retinex.retinexcolorspace = retinexcolorspace->get_active_text() != M ("GENERAL_UNCHANGED");
pedited->retinex.gammaretinex = gammaretinex->get_active_text() != M ("GENERAL_UNCHANGED");
@ -998,6 +1083,12 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
}
if (complexmethod->get_active_row_number() == 0) {
pp->retinex.complexmethod = "normal";
} else if (complexmethod->get_active_row_number() == 1) {
pp->retinex.complexmethod = "expert";
}
if (retinexMethod->get_active_row_number() == 0) {
pp->retinex.retinexMethod = "low";
} else if (retinexMethod->get_active_row_number() == 1) {
@ -1056,6 +1147,27 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
}
void Retinex::complexmethodChanged()
{
if (!batchMode) {
if (complexmethod->get_active_row_number() == 0) {
updateGUIToMode(0);
convertParamToNormal();
} else {
updateGUIToMode(1);
}
}
if (listener) {
listener->panelChanged(EvReticomplex, complexmethod->get_active_text());
}
}
void Retinex::retinexMethodChanged()
{
@ -1138,8 +1250,11 @@ void Retinex::viewMethodChanged()
limd->show();
transmissionCurveEditorG->show();
medianmap->show();
iterFrame->show();
if (complexmethod->get_active_row_number() == 0) {
iterFrame->hide();
} else {
iterFrame->show();
}
/*
iter->show();
scal->show();
@ -1522,6 +1637,7 @@ void Retinex::setBatchMode (bool batchMode)
h_tonalwidth->showEditedCB ();
shadows->showEditedCB ();
s_tonalwidth->showEditedCB ();
// complexmethod->append(M("GENERAL_UNCHANGED"));
skal->showEditedCB ();
curveEditorGD->setBatchMode (batchMode);

View File

@ -28,6 +28,7 @@ class Retinex final :
{
private:
IdleRegister idle_register;
rtengine::ProcEvent EvReticomplex;
protected:
CurveEditorGroup* curveEditorGD;
@ -72,6 +73,9 @@ protected:
MyComboBoxText* mapMethod;
MyComboBoxText* viewMethod;
Gtk::CheckButton* medianmap;
MyComboBoxText* complexmethod;
sigc::connection complexmethodconn;
double nextmin;
double nextmax;
double nextminiT;
@ -87,6 +91,7 @@ protected:
Gtk::Frame *gainFrame;
Gtk::Frame *tranFrame;
Gtk::Frame *iterFrame;
Gtk::Frame *maskFrame;
Gtk::Frame *equalFrame;
DiagonalCurveEditor* cdshape;
@ -148,4 +153,7 @@ public:
private:
void foldAllButMe(GdkEventButton* event, MyExpander *expander);
void convertParamToNormal();
void updateGUIToMode(int mode);
void complexmethodChanged();
};

View File

@ -2920,8 +2920,8 @@ void Wavelet::convertParamToNormal()
//final touchup
BAmethod->set_active(0);
enableListener();
sigmafin->setValue(def_params.sigmafin);
enableListener();
// Update GUI based on converted widget parameters:
}