Merge pull request #4885 from Beep6581/softlight-later-pipeline
moved softlight later in the pipeline
This commit is contained in:
commit
b651cdd40b
@ -1011,6 +1011,8 @@ void Crop::update(int todo)
|
|||||||
parent->ipf.ip_wavelet(labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, skip);
|
parent->ipf.ip_wavelet(labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent->ipf.softLight(labnCrop);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@ -792,7 +792,8 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipf.softLight(nprevl);
|
||||||
|
|
||||||
if (params.colorappearance.enabled) {
|
if (params.colorappearance.enabled) {
|
||||||
//L histo and Chroma histo for ciecam
|
//L histo and Chroma histo for ciecam
|
||||||
// histogram well be for Lab (Lch) values, because very difficult to do with J,Q, M, s, C
|
// histogram well be for Lab (Lch) values, because very difficult to do with J,Q, M, s, C
|
||||||
|
@ -3186,7 +3186,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
softLight(rtemp, gtemp, btemp, istart, jstart, tW, tH, TS);
|
//softLight(rtemp, gtemp, btemp, istart, jstart, tW, tH, TS);
|
||||||
|
|
||||||
if (!blackwhite) {
|
if (!blackwhite) {
|
||||||
if (editImgFloat || editWhatever) {
|
if (editImgFloat || editWhatever) {
|
||||||
|
@ -343,7 +343,7 @@ public:
|
|||||||
void localContrast(LabImage *lab);
|
void localContrast(LabImage *lab);
|
||||||
void colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread);
|
void colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread);
|
||||||
void shadowsHighlights(LabImage *lab);
|
void shadowsHighlights(LabImage *lab);
|
||||||
void softLight(float *red, float *green, float *blue, int istart, int jstart, int tW, int tH, int TS);
|
void softLight(LabImage *lab);
|
||||||
|
|
||||||
Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true);
|
Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true);
|
||||||
Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm);
|
Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm);
|
||||||
|
@ -26,48 +26,49 @@
|
|||||||
|
|
||||||
namespace rtengine {
|
namespace rtengine {
|
||||||
|
|
||||||
void ImProcFunctions::softLight(float *red, float *green, float *blue, int istart, int jstart, int tW, int tH, int TS)
|
namespace {
|
||||||
|
|
||||||
|
inline float sl(float blend, float x)
|
||||||
|
{
|
||||||
|
if (!OOG(x)) {
|
||||||
|
const float orig = 1.f - blend;
|
||||||
|
float v = Color::gamma_srgb(x) / MAXVALF;
|
||||||
|
// Pegtop's formula from
|
||||||
|
// https://en.wikipedia.org/wiki/Blend_modes#Soft_Light
|
||||||
|
float v2 = v * v;
|
||||||
|
float v22 = v2 * 2.f;
|
||||||
|
v = v2 + v22 - v22 * v;
|
||||||
|
x = blend * Color::igamma_srgb(v * MAXVALF) + orig * x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
void ImProcFunctions::softLight(LabImage *lab)
|
||||||
{
|
{
|
||||||
if (!params->softlight.enabled || !params->softlight.strength) {
|
if (!params->softlight.enabled || !params->softlight.strength) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Imagefloat working(lab->W, lab->H);
|
||||||
|
lab2rgb(*lab, working, params->icm.workingProfile);
|
||||||
|
|
||||||
const float blend = params->softlight.strength / 100.f;
|
const float blend = params->softlight.strength / 100.f;
|
||||||
const float orig = 1.f - blend;
|
|
||||||
|
|
||||||
const auto apply =
|
|
||||||
[=](float x) -> float
|
|
||||||
{
|
|
||||||
if (!OOG(x)) {
|
|
||||||
float v = Color::gamma_srgb(x) / MAXVALF;
|
|
||||||
// Pegtop's formula from
|
|
||||||
// https://en.wikipedia.org/wiki/Blend_modes#Soft_Light
|
|
||||||
float v2 = v * v;
|
|
||||||
float v22 = v2 * 2.f;
|
|
||||||
v = v2 + v22 - v22 * v;
|
|
||||||
x = blend * Color::igamma_srgb(v * MAXVALF) + orig * x;
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel if (multiThread)
|
#pragma omp parallel for
|
||||||
#endif
|
#endif
|
||||||
{
|
for (int y = 0; y < working.getHeight(); ++y) {
|
||||||
int ti = 0;
|
for (int x = 0; x < working.getWidth(); ++x) {
|
||||||
#ifdef _OPENMP
|
working.r(y, x) = sl(blend, working.r(y, x));
|
||||||
#pragma omp for
|
working.g(y, x) = sl(blend, working.g(y, x));
|
||||||
#endif
|
working.b(y, x) = sl(blend, working.b(y, x));
|
||||||
for (int i = istart; i < tH; i++) {
|
|
||||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
|
||||||
const int idx = ti * TS + tj;
|
|
||||||
red[idx] = apply(red[idx]);
|
|
||||||
green[idx] = apply(green[idx]);
|
|
||||||
blue[idx] = apply(blue[idx]);
|
|
||||||
}
|
|
||||||
++ti;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgb2lab(working, *lab, params->icm.workingProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rtengine
|
} // namespace rtengine
|
||||||
|
@ -1368,6 +1368,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
|
|||||||
ipf.EPDToneMap (labView, 5, 6);
|
ipf.EPDToneMap (labView, 5, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipf.softLight(labView);
|
||||||
|
|
||||||
if (params.colorappearance.enabled) {
|
if (params.colorappearance.enabled) {
|
||||||
CurveFactory::curveLightBrightColor (
|
CurveFactory::curveLightBrightColor (
|
||||||
params.colorappearance.curve,
|
params.colorappearance.curve,
|
||||||
|
@ -1135,6 +1135,8 @@ private:
|
|||||||
|
|
||||||
wavCLVCurve.Reset();
|
wavCLVCurve.Reset();
|
||||||
|
|
||||||
|
ipf.softLight(labView);
|
||||||
|
|
||||||
//Colorappearance and tone-mapping associated
|
//Colorappearance and tone-mapping associated
|
||||||
|
|
||||||
int f_w = 1, f_h = 1;
|
int f_w = 1, f_h = 1;
|
||||||
|
@ -28,8 +28,8 @@ using namespace rtengine::procparams;
|
|||||||
SoftLight::SoftLight(): FoldableToolPanel(this, "softlight", M("TP_SOFTLIGHT_LABEL"), false, true)
|
SoftLight::SoftLight(): FoldableToolPanel(this, "softlight", M("TP_SOFTLIGHT_LABEL"), false, true)
|
||||||
{
|
{
|
||||||
auto m = ProcEventMapper::getInstance();
|
auto m = ProcEventMapper::getInstance();
|
||||||
EvSoftLightEnabled = m->newEvent(RGBCURVE, "HISTORY_MSG_SOFTLIGHT_ENABLED");
|
EvSoftLightEnabled = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_SOFTLIGHT_ENABLED");
|
||||||
EvSoftLightStrength = m->newEvent(RGBCURVE, "HISTORY_MSG_SOFTLIGHT_STRENGTH");
|
EvSoftLightStrength = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_SOFTLIGHT_STRENGTH");
|
||||||
|
|
||||||
strength = Gtk::manage(new Adjuster(M("TP_SOFTLIGHT_STRENGTH"), 0., 100., 1., 30.));
|
strength = Gtk::manage(new Adjuster(M("TP_SOFTLIGHT_STRENGTH"), 0., 100., 1., 30.));
|
||||||
strength->setAdjusterListener(this);
|
strength->setAdjusterListener(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user