Merge pull request #3111 from Beep6581/newretinex

Newretinex - new features and bug fixes
This commit is contained in:
Beep6581
2016-01-22 17:39:03 +01:00
5 changed files with 91 additions and 69 deletions

View File

@@ -1665,7 +1665,7 @@ TP_RETINEX_CURVEEDITOR_LH_TOOLTIP;Strength according to hue Strength=f(H)\nThis
TP_RETINEX_CURVEEDITOR_MAP;L=f(L)
TP_RETINEX_CURVEEDITOR_MAP_TOOLTIP;This curve can be applied alone or with a Gaussian mask or wavelet mask.\nBeware of artifacts!
TP_RETINEX_FREEGAMMA;Free gamma
TP_RETINEX_GAIN;Contrast
TP_RETINEX_GAIN;Gain
TP_RETINEX_GAIN_TOOLTIP;Acts on the restored image.\n\nThis is very different from the others settings. Used for black or white pixels, and to help balance the histogram.
TP_RETINEX_GAMMA;Gamma
TP_RETINEX_GAMMA_FREE;Free
@@ -1687,6 +1687,7 @@ TP_RETINEX_HSLSPACE_LOG;HSL-Logarithmic
TP_RETINEX_ITER;Iterations (Tone-mapping)
TP_RETINEX_ITER_TOOLTIP;Simulate a tone-mapping operator.\nHigh values increase the processing time.
TP_RETINEX_LABEL;Retinex
TP_RETINEX_LABEL_MASK;Mask
TP_RETINEX_LABSPACE;L*a*b*
TP_RETINEX_LOW;Low
TP_RETINEX_MAP;Mask method
@@ -1694,11 +1695,11 @@ TP_RETINEX_MAP_CURV;Curve only
TP_RETINEX_MAP_GAUS;Gaussian mask
TP_RETINEX_MAP_MAPP;Sharp mask (wavelet partial)
TP_RETINEX_MAP_MAPT;Sharp mask (wavelet total)
TP_RETINEX_MAP_METHOD_TOOLTIP;Use the mask generated by the Gaussian function above to reduce halos and artifacts.\n\nCurve only: apply a diagonal contrast curve on the mask.\nBeware of artifacts!\n\nGaussian mask: generate and use a Gaussian blur of the original mask.\nQuick.\n\nSharp mask: generate and use a wavelet on the original mask.\nSlow.
TP_RETINEX_MAP_METHOD_TOOLTIP;Use the mask generated by the Gaussian function above (Radius, Method) to reduce halos and artifacts.\n\nCurve only: apply a diagonal contrast curve on the mask.\nBeware of artifacts!\n\nGaussian mask: generate and use a Gaussian blur of the original mask.\nQuick.\n\nSharp mask: generate and use a wavelet on the original mask.\nSlow.
TP_RETINEX_MAP_NONE;None
TP_RETINEX_MEDIAN;Transmission median filter
TP_RETINEX_METHOD;Method
TP_RETINEX_METHOD_TOOLTIP;Low = Reinforce low light,\nUniform = Equalize action,\nHigh = Reinforce high light,\nHighlights = Remove magenta in highlights.
TP_RETINEX_METHOD_TOOLTIP;Low = Reinforce low light.\nUniform = Equalize action.\nHigh = Reinforce high light.\nHighlights = Remove magenta in highlights.
TP_RETINEX_MLABEL;Restored haze-free Min=%1 Max=%2
TP_RETINEX_MLABEL_TOOLTIP;Should be near min=0 max=32768\nRestored image with no mixture.
TP_RETINEX_NEIGHBOR;Radius
@@ -1706,7 +1707,7 @@ TP_RETINEX_NEUTRAL;Reset
TP_RETINEX_NEUTRAL_TIP;Reset all sliders and curves to their default values.
TP_RETINEX_OFFSET;Brightness
TP_RETINEX_SCALES;Gaussian gradient
TP_RETINEX_SCALES_TOOLTIP;If slider at 0, all iterations are identical.\nIf > 0 Scale and Neighboring pixels are reduced when iterations increase, and conversely.
TP_RETINEX_SCALES_TOOLTIP;If slider at 0, all iterations are identical.\nIf > 0 Scale and radius are reduced when iterations increase, and conversely.
TP_RETINEX_SETTINGS;Settings
TP_RETINEX_SLOPE;Free gamma slope
TP_RETINEX_STRENGTH;Strength
@@ -1714,13 +1715,13 @@ TP_RETINEX_THRESHOLD;Threshold
TP_RETINEX_THRESHOLD_TOOLTIP;Limits in/out.\nIn = image source,\nOut = image gauss.
TP_RETINEX_TLABEL;TM Min=%1 Max=%2 Mean=%3 Sigma=%4
TP_RETINEX_TLABEL2;TM Tm=%1 TM=%2
TP_RETINEX_TLABEL_TOOLTIP;Transmission map result.\nMin and Max are used by Variance.\nMean and Sigma\nTm=Min TM=Max of transmission map.
TP_RETINEX_TLABEL_TOOLTIP;Transmission map result.\nMin and Max are used by Variance.\nMean and Sigma.\nTm=Min TM=Max of transmission map.
TP_RETINEX_TRANSMISSION;Transmission map
TP_RETINEX_TRANSMISSION_TOOLTIP;Transmission according to transmission.\nAbscissa: transmission from negative values (min), mean, and positives values (max).\nOrdinate: amplification or reduction.
TP_RETINEX_UNIFORM;Uniform
TP_RETINEX_VARIANCE;Contrast
TP_RETINEX_VARIANCE_TOOLTIP;Low variance increase local contrast and saturation, but can lead to artifacts.
TP_RETINEX_VIEW;Process (Preview)
TP_RETINEX_VIEW;Process
TP_RETINEX_VIEW_MASK;Mask
TP_RETINEX_VIEW_METHOD_TOOLTIP;Standard - Normal display.\nMask - Displays the mask.\nUnsharp mask - Displays the image with a high radius unsharp mask.\nTransmission - Auto/Fixed - Displays the file transmission-map, before any action on contrast and brightness.\n\nAttention: the mask does not correspond to reality, but is amplified to make it more visible.
TP_RETINEX_VIEW_NONE;Standard

View File

@@ -210,7 +210,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
{
if (deh.enabled) {//enabled
float mean, stddv, maxtr, mintr;
// float mini, delta, maxi;
//float mini, delta, maxi;
float delta;
float eps = 2.f;
bool useHsl = deh.retinexcolorspace == "HSLLOG";
@@ -419,9 +419,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
mapmet = 3;
}
if(deh.mapMethod == "curv") {
/*if(deh.mapMethod == "curv") {
mapmet = 1;
}
}*/
if(deh.mapMethod == "gaus") {
mapmet = 4;
@@ -499,7 +499,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
shradius = 40.;
}
// if(shHighlights > 0 || shShadows > 0) {
//if(shHighlights > 0 || shShadows > 0) {
if(mapmet == 3) if(it == 1) {
shmap->updateL (out, shradius, true, 1); //wav Total
}
@@ -512,7 +512,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
shmap->updateL (out, shradius, false, 1); //gauss
}
// }
//}
if (shmap) {
h_th = shmap->max_f - deh.htonalwidth * (shmap->max_f - shmap->avg) / 100;
s_th = deh.stonalwidth * (shmap->avg - shmap->min_f) / 100;
@@ -544,7 +544,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
}
// if(shHighlights > 0 || shShadows > 0) {
//if(shHighlights > 0 || shShadows > 0) {
if(((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) {
@@ -571,7 +571,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
}
}
// }
//}
#ifdef _OPENMP
#pragma omp for
@@ -616,7 +616,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
shmap = NULL;
delete [] buffer;
// delete [] outBuffer;
//delete [] outBuffer;
delete [] srcBuffer;
mean = 0.f;
@@ -624,9 +624,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
// I call mean_stddv2 instead of mean_stddv ==> logBetaGain
mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
// printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr);
//printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr);
// mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr);
//mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr);
if (dehatransmissionCurve && mean != 0.f && stddv != 0.f) { //if curve
float asig = 0.166666f / stddv;
float bsig = 0.5f - asig * mean;
@@ -707,7 +707,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
}
// I call mean_stddv2 instead of mean_stddv ==> logBetaGain
// mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr);
//mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr);
mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
}
@@ -727,7 +727,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
}
delta = maxi - mini;
// printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr);
//printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr);
if ( !delta ) {
delta = 1.0f;
@@ -756,7 +756,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
for ( int i = 0; i < H_L; i ++ )
for (int j = 0; j < W_L; j++) {
// float cd = cdfactor * ( luminance[i][j] * logBetaGain - mini ) + offse;
//float cd = cdfactor * ( luminance[i][j] * logBetaGain - mini ) + offse;
float cd = cdfactor * ( luminance[i][j] - mini ) + offse;
if(cd > cdmax) {
@@ -825,7 +825,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
}
delete [] outBuffer;
outBuffer = NULL;
// printf("cdmin=%f cdmax=%f\n",minCD, maxCD);
//printf("cdmin=%f cdmax=%f\n",minCD, maxCD);
Tmean = mean;
Tsigma = stddv;
Tmin = mintr;

View File

@@ -95,7 +95,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
ALLNORAW, // EvHREnabled,
ALLNORAW, // EvHRAmount,
ALLNORAW, // EvHRMethod,
ALLNORAW, // EvWProfile,
DEMOSAIC, // EvWProfile,
OUTPUTPROFILE, // EvOProfile,
ALLNORAW, // EvIProfile,
TRANSFORM, // EvVignettingAmount,

View File

@@ -505,6 +505,7 @@ void PartialPasteDlg::basicToggled ()
gradientConn.block (true);
labcurveConn.block (true);
colorappearanceConn.block (true);
retinexConn.block (true);
basic->set_inconsistent (false);
@@ -514,6 +515,7 @@ void PartialPasteDlg::basicToggled ()
epd->set_active (basic->get_active ());
pcvignette->set_active (basic->get_active ());
gradient->set_active (basic->get_active ());
retinex->set_active (basic->get_active ());
labcurve->set_active (basic->get_active ());
colorappearance->set_active (basic->get_active ());
@@ -523,6 +525,8 @@ void PartialPasteDlg::basicToggled ()
epdConn.block (false);
pcvignetteConn.block (false);
gradientConn.block (false);
retinexConn.block (false);
labcurveConn.block (false);
colorappearanceConn.block (false);
}

View File

@@ -175,6 +175,15 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
limd->set_tooltip_markup (M("TP_RETINEX_THRESHOLD_TOOLTIP"));
baselog->set_tooltip_markup (M("TP_RETINEX_BASELOG_TOOLTIP"));
Gtk::Frame *p1Frame;
p1Frame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_LABEL_MASK")) );
p1Frame->set_border_width(0);
p1Frame->set_label_align(0.025, 0.5);
Gtk::VBox *p1VBox;
p1VBox = Gtk::manage ( new Gtk::VBox());
p1VBox->set_border_width(4);
p1VBox->set_spacing(2);
mapbox = Gtk::manage (new Gtk::HBox ());
labmap = Gtk::manage (new Gtk::Label (M("TP_RETINEX_MAP") + ":"));
@@ -182,7 +191,7 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
mapMethod = Gtk::manage (new MyComboBoxText ());
mapMethod->append_text (M("TP_RETINEX_MAP_NONE"));
mapMethod->append_text (M("TP_RETINEX_MAP_CURV"));
// mapMethod->append_text (M("TP_RETINEX_MAP_CURV"));
mapMethod->append_text (M("TP_RETINEX_MAP_GAUS"));
mapMethod->append_text (M("TP_RETINEX_MAP_MAPP"));
mapMethod->append_text (M("TP_RETINEX_MAP_MAPT"));
@@ -202,8 +211,8 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
viewMethod = Gtk::manage (new MyComboBoxText ());
viewMethod->append_text (M("TP_RETINEX_VIEW_NONE"));
viewMethod->append_text (M("TP_RETINEX_VIEW_MASK"));
viewMethod->append_text (M("TP_RETINEX_VIEW_UNSHARP"));
viewMethod->append_text (M("TP_RETINEX_VIEW_MASK"));
viewMethod->append_text (M("TP_RETINEX_VIEW_TRAN"));
viewMethod->append_text (M("TP_RETINEX_VIEW_TRAN2"));
viewMethod->set_active(0);
@@ -288,30 +297,33 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
settingsVBox->pack_start (*limd);
limd->show ();
settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
mapbox->pack_start(*mapMethod);
settingsVBox->pack_start(*mapbox);
settingsVBox->pack_start (*curveEditormap, Gtk::PACK_SHRINK, 4);
curveEditormap->show();
settingsVBox->pack_start (*highlights);
highlights->show();
settingsVBox->pack_start (*h_tonalwidth);
h_tonalwidth->show();
settingsVBox->pack_start (*shadows);
shadows->show();
settingsVBox->pack_start (*s_tonalwidth);
s_tonalwidth->show();
settingsVBox->pack_start (*radius);
radius->show();
// settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
viewbox->pack_start(*viewMethod);
settingsVBox->pack_start(*viewbox);
// settingsVBox->pack_start(*viewbox);
retinexVBox->pack_start(*viewbox);
//settingsVBox->pack_start (*viewMethod);
mapbox->pack_start(*mapMethod);
// settingsVBox->pack_start(*mapbox);
p1VBox->pack_start(*mapbox);
p1VBox->pack_start (*curveEditormap, Gtk::PACK_SHRINK, 4);
curveEditormap->show();
p1VBox->pack_start (*highlights);
highlights->show();
p1VBox->pack_start (*h_tonalwidth);
h_tonalwidth->show();
p1VBox->pack_start (*shadows);
shadows->show();
p1VBox->pack_start (*s_tonalwidth);
s_tonalwidth->show();
p1VBox->pack_start (*radius);
radius->show();
// settingsVBox->pack_start (*highl);
// highl->show ();
@@ -320,7 +332,7 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
// settingsVBox->pack_start (*grbl);
// grbl->show ();
settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
// settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
settingsVBox->pack_start( *transmissionCurveEditorG, Gtk::PACK_SHRINK, 2);
transmissionCurveEditorG->show();
@@ -428,26 +440,31 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
radius->setAdjusterListener (this);
if (radius->delay < 200) {
radius->delay = 200;
}
highlights->setAdjusterListener (this);
if (highlights->delay < 200) {
highlights->delay = 200;
}
h_tonalwidth->setAdjusterListener (this);
if (h_tonalwidth->delay < 200) {
h_tonalwidth->delay = 200;
}
shadows->setAdjusterListener (this);
if (shadows->delay < 200) {
shadows->delay = 200;
}
s_tonalwidth->setAdjusterListener (this);
if (s_tonalwidth->delay < 200) {
s_tonalwidth->delay = 200;
}
@@ -459,6 +476,9 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
}
*/
pack_start (*retinexVBox);
p1Frame->add(*p1VBox);
pack_start (*p1Frame, Gtk::PACK_EXPAND_WIDGET, 4);
pack_start (*expsettings);
pack_start (*neutrHBox);
@@ -701,8 +721,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
grad->set_sensitive(false);
scal->set_sensitive(false);
grads->set_sensitive(false);
}
else {
} else {
grad->set_sensitive(true);
scal->set_sensitive(true);
grads->set_sensitive(true);
@@ -728,21 +747,21 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
if (pp->retinex.mapMethod == "none") {
mapMethod->set_active (0);
} else if (pp->retinex.mapMethod == "curv") {
mapMethod->set_active (1);
// } else if (pp->retinex.mapMethod == "curv") {
// mapMethod->set_active (1);
} else if (pp->retinex.mapMethod == "gaus") {
mapMethod->set_active (2);
mapMethod->set_active (1);
} else if (pp->retinex.mapMethod == "map") {
mapMethod->set_active (3);
mapMethod->set_active (2);
} else if (pp->retinex.mapMethod == "mapT") {
mapMethod->set_active (4);
mapMethod->set_active (3);
}
if (pp->retinex.viewMethod == "none") {
viewMethod->set_active (0);
} else if (pp->retinex.viewMethod == "mask") {
viewMethod->set_active (1);
} else if (pp->retinex.viewMethod == "unsharp") {
viewMethod->set_active (1);
} else if (pp->retinex.viewMethod == "mask") {
viewMethod->set_active (2);
} else if (pp->retinex.viewMethod == "tran") {
viewMethod->set_active (3);
@@ -883,22 +902,22 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
if (mapMethod->get_active_row_number() == 0) {
pp->retinex.mapMethod = "none";
// } else if (mapMethod->get_active_row_number() == 1) {
// pp->retinex.mapMethod = "curv";
} else if (mapMethod->get_active_row_number() == 1) {
pp->retinex.mapMethod = "curv";
} else if (mapMethod->get_active_row_number() == 2) {
pp->retinex.mapMethod = "gaus";
} else if (mapMethod->get_active_row_number() == 3) {
} else if (mapMethod->get_active_row_number() == 2) {
pp->retinex.mapMethod = "map";
} else if (mapMethod->get_active_row_number() == 4) {
} else if (mapMethod->get_active_row_number() == 3) {
pp->retinex.mapMethod = "mapT";
}
if (viewMethod->get_active_row_number() == 0) {
pp->retinex.viewMethod = "none";
} else if (viewMethod->get_active_row_number() == 1) {
pp->retinex.viewMethod = "mask";
} else if (viewMethod->get_active_row_number() == 2) {
pp->retinex.viewMethod = "unsharp";
} else if (viewMethod->get_active_row_number() == 2) {
pp->retinex.viewMethod = "mask";
} else if (viewMethod->get_active_row_number() == 3) {
pp->retinex.viewMethod = "tran";
} else if (viewMethod->get_active_row_number() == 4) {
@@ -946,14 +965,14 @@ void Retinex::retinexMethodChanged()
void Retinex::mapMethodChanged()
{
if(mapMethod->get_active_row_number() == 1 || mapMethod->get_active_row_number() == 2) {
if(mapMethod->get_active_row_number() == 1 /*|| mapMethod->get_active_row_number() == 2*/) {
curveEditormap->show();
highlights->show();
h_tonalwidth->show();
shadows->show();
s_tonalwidth->show();
radius->show();
} else if(mapMethod->get_active_row_number() == 3 || mapMethod->get_active_row_number() == 4) {
} else if(mapMethod->get_active_row_number() == 2 || mapMethod->get_active_row_number() == 3) {
curveEditormap->show();
highlights->show();
h_tonalwidth->show();
@@ -978,7 +997,7 @@ void Retinex::mapMethodChanged()
void Retinex::viewMethodChanged()
{
if(viewMethod->get_active_row_number() == 1 || viewMethod->get_active_row_number() == 2) {
vart->hide();
// vart->hide();
gain->hide();
offs->hide();
limd->hide();
@@ -989,14 +1008,12 @@ void Retinex::viewMethodChanged()
grad->hide();
grads->hide();
curveEditorGH->hide();
}
else if(viewMethod->get_active_row_number() == 3 || viewMethod->get_active_row_number() == 4) {
} else if(viewMethod->get_active_row_number() == 3 || viewMethod->get_active_row_number() == 4) {
gain->hide();
offs->hide();
vart->hide();
// vart->hide();
curveEditorGH->hide();
}
else {
} else {
vart->show();
neigh->show();
gain->show();
@@ -1191,12 +1208,12 @@ void Retinex::adjusterChanged (Adjuster* a, double newval)
if (!listener || !getEnabled()) {
return;
}
if(iter->getTextValue() > "1") {
scal->set_sensitive(true);
grad->set_sensitive(true);
grads->set_sensitive(true);
}
else {
} else {
scal->set_sensitive(false);
grad->set_sensitive(false);
grads->set_sensitive(false);