Enhanced version of the "L*a*b* regions" color toning, adding mask blur and ASC-CDL controls
This commit is contained in:
@@ -733,13 +733,18 @@ HISTORY_MSG_493;L*a*b* Adjustments
|
||||
HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors
|
||||
HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction
|
||||
HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction
|
||||
HISTORY_MSG_COLORTONING_LABREGION_CHROMATICITYMASK;CT - C mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_CHANNEL;CT - Channel
|
||||
HISTORY_MSG_COLORTONING_LABREGION_CHROMATICITYMASK;CT - region C mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_HUEMASK;CT - H mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_LIGHTNESS;CT - Lightness
|
||||
HISTORY_MSG_COLORTONING_LABREGION_LIGHTNESSMASK;CT - L mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_SHOWMASK;CT - region show mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_LIST;CT - List
|
||||
HISTORY_MSG_COLORTONING_LABREGION_SATURATION;CT - Saturation
|
||||
HISTORY_MSG_COLORTONING_LABREGION_SHOWMASK;CT - Show mask
|
||||
HISTORY_MSG_COLORTONING_LABREGION_SLOPE;CT - region slope
|
||||
HISTORY_MSG_COLORTONING_LABREGION_OFFSET;CT - region offset
|
||||
HISTORY_MSG_COLORTONING_LABREGION_POWER;CT - region power
|
||||
HISTORY_MSG_COLORTONING_LABREGION_MASKBLUR;CT - region mask blur
|
||||
HISTORY_MSG_DEHAZE_DEPTH;Dehaze - Depth
|
||||
HISTORY_MSG_DEHAZE_ENABLED;Haze Removal
|
||||
HISTORY_MSG_DEHAZE_SHOW_DEPTH_MAP;Dehaze - Show depth map
|
||||
@@ -1465,8 +1470,14 @@ TP_COLORTONING_LAB;L*a*b* blending
|
||||
TP_COLORTONING_LABEL;Color Toning
|
||||
TP_COLORTONING_LABGRID;L*a*b* color correction grid
|
||||
TP_COLORTONING_LABGRID_VALUES;HL: a=%1 b=%2\nS: a=%3 b=%4
|
||||
TP_COLORTONING_LABREGIONS;L*a*b* correction regions
|
||||
TP_COLORTONING_LABREGIONS;Color correction regions
|
||||
TP_COLORTONING_LABREGION_ABVALUES;a=%1 b=%2
|
||||
TP_COLORTONING_LABREGION_MASKBLUR;Mask Blur
|
||||
TP_COLORTONING_LABREGION_CHANNEL;Channel
|
||||
TP_COLORTONING_LABREGION_CHANNEL_ALL;All
|
||||
TP_COLORTONING_LABREGION_CHANNEL_B;Blue
|
||||
TP_COLORTONING_LABREGION_CHANNEL_G;Green
|
||||
TP_COLORTONING_LABREGION_CHANNEL_R;Red
|
||||
TP_COLORTONING_LABREGION_CHROMATICITYMASK;C
|
||||
TP_COLORTONING_LABREGION_HUEMASK;H
|
||||
TP_COLORTONING_LABREGION_LIGHTNESS;Lightness
|
||||
@@ -1475,6 +1486,9 @@ TP_COLORTONING_LABREGION_LIST_TITLE;Correction
|
||||
TP_COLORTONING_LABREGION_MASK;Mask
|
||||
TP_COLORTONING_LABREGION_SATURATION;Saturation
|
||||
TP_COLORTONING_LABREGION_SHOWMASK;Show mask
|
||||
TP_COLORTONING_LABREGION_SLOPE;Slope
|
||||
TP_COLORTONING_LABREGION_OFFSET;Offset
|
||||
TP_COLORTONING_LABREGION_POWER;Power
|
||||
TP_COLORTONING_LUMA;Luminance
|
||||
TP_COLORTONING_LUMAMODE;Preserve luminance
|
||||
TP_COLORTONING_LUMAMODE_TOOLTIP;If enabled, when you change color (red, green, cyan, blue, etc.) the luminance of each pixel is preserved.
|
||||
|
||||
@@ -143,8 +143,12 @@ BENCHFUN
|
||||
}
|
||||
|
||||
for (int i = begin_idx; i < end_idx; ++i) {
|
||||
rtengine::guidedFilter(guide, abmask[i], abmask[i], max(int(4 / scale + 0.5), 1), 0.001, multiThread);
|
||||
rtengine::guidedFilter(guide, Lmask[i], Lmask[i], max(int(25 / scale + 0.5), 1), 0.0001, multiThread);
|
||||
float blur = params->colorToning.labregions[i].maskBlur;
|
||||
blur = blur < 0.f ? -1.f/blur : 1.f + blur;
|
||||
int r1 = max(int(4 / scale * blur + 0.5), 1);
|
||||
int r2 = max(int(25 / scale * blur + 0.5), 1);
|
||||
rtengine::guidedFilter(guide, abmask[i], abmask[i], r1, 0.001, multiThread);
|
||||
rtengine::guidedFilter(guide, Lmask[i], Lmask[i], r2, 0.0001, multiThread);
|
||||
}
|
||||
|
||||
if (show_mask_idx >= 0) {
|
||||
@@ -166,21 +170,115 @@ BENCHFUN
|
||||
const auto abcoord =
|
||||
[](float x) -> float
|
||||
{
|
||||
return 12000.f * SGN(x) * xlog2lin(std::abs(x), 4.f);
|
||||
return /*12000.f **/ SGN(x) * xlog2lin(std::abs(x), 4.f);
|
||||
};
|
||||
|
||||
float abca[n];
|
||||
float abcb[n];
|
||||
float rs[n];
|
||||
float rl[n];
|
||||
float slope[n];
|
||||
float offset[n];
|
||||
float power[n];
|
||||
int channel[n];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto &r = params->colorToning.labregions[i];
|
||||
abca[i] = abcoord(r.a);
|
||||
abcb[i] = abcoord(r.b);
|
||||
rs[i] = 1.f + r.saturation / 100.f;
|
||||
rl[i] = 1.f + r.lightness / 500.f;
|
||||
rs[i] = 1.f + r.saturation / (SGN(r.saturation) > 0 ? 50.f : 100.f);
|
||||
slope[i] = r.slope;
|
||||
offset[i] = r.offset;
|
||||
power[i] = r.power;
|
||||
channel[i] = r.channel;
|
||||
}
|
||||
|
||||
TMatrix ws = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile);
|
||||
TMatrix iws = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.workingProfile);
|
||||
|
||||
const auto CDL =
|
||||
[=](float &l, float &a, float &b, float slope, float offset, float power, float saturation) -> void
|
||||
{
|
||||
if (slope != 1.f || offset != 0.f || power != 1.f || saturation != 1.f) {
|
||||
float rgb[3];
|
||||
float x, y, z;
|
||||
Color::Lab2XYZ(l, a, b, x, y, z);
|
||||
Color::xyz2rgb(x, y, z, rgb[0], rgb[1], rgb[2], iws);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
rgb[i] = (pow_F(max((rgb[i] / 65535.f) * slope + offset, 0.f), power)) * 65535.f;
|
||||
}
|
||||
if (saturation != 1.f) {
|
||||
float Y = Color::rgbLuminance(rgb[0], rgb[1], rgb[2], ws);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
rgb[i] = max(Y + saturation * (rgb[i] - Y), 0.f);
|
||||
}
|
||||
}
|
||||
Color::rgbxyz(rgb[0], rgb[1], rgb[2], x, y, z, ws);
|
||||
Color::XYZ2Lab(x, y, z, l, a, b);
|
||||
}
|
||||
};
|
||||
|
||||
const auto chan =
|
||||
[=](float prev_l, float prev_a, float prev_b, float &l, float &a, float &b, int channel) -> void
|
||||
{
|
||||
if (channel >= 0) {
|
||||
float prev_rgb[3];
|
||||
float rgb[3];
|
||||
float x, y, z;
|
||||
Color::Lab2XYZ(l, a, b, x, y, z);
|
||||
Color::xyz2rgb(x, y, z, rgb[0], rgb[1], rgb[2], iws);
|
||||
Color::Lab2XYZ(prev_l, prev_a, prev_b, x, y, z);
|
||||
Color::xyz2rgb(x, y, z, prev_rgb[0], prev_rgb[1], prev_rgb[2], iws);
|
||||
prev_rgb[channel] = rgb[channel];
|
||||
Color::rgbxyz(prev_rgb[0], prev_rgb[1], prev_rgb[2], x, y, z, ws);
|
||||
Color::XYZ2Lab(x, y, z, l, a, b);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __SSE2__
|
||||
const auto CDL_v =
|
||||
[=](vfloat &l, vfloat &a, vfloat &b, float slope, float offset, float power, float saturation) -> void
|
||||
{
|
||||
if (slope != 1.f || offset != 0.f || power != 1.f || saturation != 1.f) {
|
||||
float ll[4];
|
||||
float aa[4];
|
||||
float bb[4];
|
||||
STVFU(ll[0], l);
|
||||
STVFU(aa[0], a);
|
||||
STVFU(bb[0], b);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
CDL(ll[i], aa[i], bb[i], slope, offset, power, saturation);
|
||||
}
|
||||
l = LVFU(ll[0]);
|
||||
a = LVFU(aa[0]);
|
||||
b = LVFU(bb[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const auto chan_v =
|
||||
[=](vfloat prev_l, vfloat prev_a, vfloat prev_b, vfloat &l, vfloat &a, vfloat &b, int channel) -> void
|
||||
{
|
||||
if (channel >= 0) {
|
||||
float ll[4];
|
||||
float aa[4];
|
||||
float bb[4];
|
||||
STVFU(ll[0], l);
|
||||
STVFU(aa[0], a);
|
||||
STVFU(bb[0], b);
|
||||
float prev_ll[4];
|
||||
float prev_aa[4];
|
||||
float prev_bb[4];
|
||||
STVFU(prev_ll[0], prev_l);
|
||||
STVFU(prev_aa[0], prev_a);
|
||||
STVFU(prev_bb[0], prev_b);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
chan(prev_ll[i], prev_aa[i], prev_bb[i], ll[i], aa[i], bb[i], channel);
|
||||
}
|
||||
l = LVFU(ll[0]);
|
||||
a = LVFU(aa[0]);
|
||||
b = LVFU(bb[0]);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel if (multiThread)
|
||||
#endif
|
||||
@@ -188,7 +286,6 @@ BENCHFUN
|
||||
#ifdef __SSE2__
|
||||
vfloat c42000v = F2V(42000.f);
|
||||
vfloat cm42000v = F2V(-42000.f);
|
||||
vfloat c32768v = F2V(32768.f);
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for
|
||||
@@ -203,10 +300,12 @@ BENCHFUN
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
vfloat blendv = LVFU(abmask[i][y][x]);
|
||||
vfloat sv = F2V(rs[i]);
|
||||
vfloat a_newv = vclampf(sv * (av + F2V(abca[i])), cm42000v, c42000v);
|
||||
vfloat b_newv = vclampf(sv * (bv + F2V(abcb[i])), cm42000v, c42000v);
|
||||
vfloat l_newv = vclampf(lv * F2V(rl[i]), ZEROV, c32768v);
|
||||
vfloat l_newv = lv;
|
||||
vfloat a_newv = vclampf(av + lv * F2V(abca[i]), cm42000v, c42000v);
|
||||
vfloat b_newv = vclampf(bv + lv * F2V(abcb[i]), cm42000v, c42000v);
|
||||
CDL_v(l_newv, a_newv, b_newv, slope[i], offset[i], power[i], rs[i]);
|
||||
l_newv = vmaxf(l_newv, ZEROV);
|
||||
chan_v(lv, av, bv, l_newv, a_newv, b_newv, channel[i]);
|
||||
lv = vintpf(LVFU(Lmask[i][y][x]), l_newv, lv);
|
||||
av = vintpf(blendv, a_newv, av);
|
||||
bv = vintpf(blendv, b_newv, bv);
|
||||
@@ -223,10 +322,12 @@ BENCHFUN
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
float blend = abmask[i][y][x];
|
||||
float s = rs[i];
|
||||
float a_new = LIM(s * (a + abca[i]), -42000.f, 42000.f);
|
||||
float b_new = LIM(s * (b + abcb[i]), -42000.f, 42000.f);
|
||||
float l_new = LIM(l * rl[i], 0.f, 32768.f);
|
||||
float l_new = l;
|
||||
float a_new = LIM(a + l * abca[i], -42000.f, 42000.f);
|
||||
float b_new = LIM(b + l * abcb[i], -42000.f, 42000.f);
|
||||
CDL(l_new, a_new, b_new, slope[i], offset[i], power[i], rs[i]);
|
||||
l_new = max(l_new, 0.f);
|
||||
chan(l, a, b, l_new, a_new, b_new, channel[i]);
|
||||
l = intp(Lmask[i][y][x], l_new, l);
|
||||
a = intp(blend, a_new, a);
|
||||
b = intp(blend, b_new, b);
|
||||
|
||||
@@ -611,7 +611,9 @@ ColorToningParams::LabCorrectionRegion::LabCorrectionRegion():
|
||||
a(0),
|
||||
b(0),
|
||||
saturation(0),
|
||||
lightness(0),
|
||||
slope(1),
|
||||
offset(0),
|
||||
power(1),
|
||||
hueMask{
|
||||
FCT_MinMaxCPoints,
|
||||
0.166666667,
|
||||
@@ -644,7 +646,9 @@ ColorToningParams::LabCorrectionRegion::LabCorrectionRegion():
|
||||
1.,
|
||||
0.35,
|
||||
0.35
|
||||
}
|
||||
},
|
||||
maskBlur(0),
|
||||
channel(ColorToningParams::LabCorrectionRegion::CHAN_ALL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -654,10 +658,14 @@ bool ColorToningParams::LabCorrectionRegion::operator==(const LabCorrectionRegio
|
||||
return a == other.a
|
||||
&& b == other.b
|
||||
&& saturation == other.saturation
|
||||
&& lightness == other.lightness
|
||||
&& slope == other.slope
|
||||
&& offset == other.offset
|
||||
&& power == other.power
|
||||
&& hueMask == other.hueMask
|
||||
&& chromaticityMask == other.chromaticityMask
|
||||
&& lightnessMask == other.lightnessMask;
|
||||
&& lightnessMask == other.lightnessMask
|
||||
&& maskBlur == other.maskBlur
|
||||
&& channel == other.channel;
|
||||
}
|
||||
|
||||
|
||||
@@ -3479,10 +3487,14 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionA_") + n, l.a, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionB_") + n, l.b, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionSaturation_") + n, l.saturation, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionLightness_") + n, l.lightness, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionSlope_") + n, l.slope, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionOffset_") + n, l.offset, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionPower_") + n, l.power, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionHueMask_") + n, l.hueMask, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionChromaticityMask_") + n, l.chromaticityMask, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionLightnessMask_") + n, l.lightnessMask, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionMaskBlur_") + n, l.maskBlur, keyFile);
|
||||
putToKeyfile("ColorToning", Glib::ustring("LabRegionChannel_") + n, l.channel, keyFile);
|
||||
}
|
||||
}
|
||||
saveToKeyfile(!pedited || pedited->colorToning.labregionsShowMask, "ColorToning", "LabRegionsShowMask", colorToning.labregionsShowMask, keyFile);
|
||||
@@ -4869,7 +4881,15 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionLightness_") + n, pedited, cur.lightness, pedited->colorToning.labregions)) {
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionSlope_") + n, pedited, cur.slope, pedited->colorToning.labregions)) {
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionOffset_") + n, pedited, cur.offset, pedited->colorToning.labregions)) {
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionPower_") + n, pedited, cur.power, pedited->colorToning.labregions)) {
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
@@ -4885,6 +4905,14 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionMaskBlur_") + n, pedited, cur.maskBlur, pedited->colorToning.labregions)) {
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (assignFromKeyfile(keyFile, "ColorToning", Glib::ustring("LabRegionChannel_") + n, pedited, cur.channel, pedited->colorToning.labregions)) {
|
||||
found = true;
|
||||
done = false;
|
||||
}
|
||||
if (!done) {
|
||||
lg.emplace_back(cur);
|
||||
}
|
||||
|
||||
@@ -456,13 +456,18 @@ struct ColorToningParams {
|
||||
static const double LABGRID_CORR_SCALE;
|
||||
|
||||
struct LabCorrectionRegion {
|
||||
enum { CHAN_ALL = -1, CHAN_R, CHAN_G, CHAN_B };
|
||||
double a;
|
||||
double b;
|
||||
double saturation;
|
||||
double lightness;
|
||||
double slope;
|
||||
double offset;
|
||||
double power;
|
||||
std::vector<double> hueMask;
|
||||
std::vector<double> chromaticityMask;
|
||||
std::vector<double> lightnessMask;
|
||||
double maskBlur;
|
||||
int channel;
|
||||
|
||||
LabCorrectionRegion();
|
||||
bool operator==(const LabCorrectionRegion &other) const;
|
||||
|
||||
@@ -361,14 +361,19 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
||||
EvLabRegionAB = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_AB");
|
||||
EvLabRegionSaturation = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_SATURATION");
|
||||
EvLabRegionLightness = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_LIGHTNESS");
|
||||
EvLabRegionSlope = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_SLOPE");
|
||||
EvLabRegionOffset = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_OFFSET");
|
||||
EvLabRegionPower = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_POWER");
|
||||
EvLabRegionHueMask = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_HUEMASK");
|
||||
EvLabRegionChromaticityMask = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_CHROMATICITYMASK");
|
||||
EvLabRegionLightnessMask = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_LIGHTNESSMASK");
|
||||
EvLabRegionMaskBlur = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_MASKBLUR");
|
||||
EvLabRegionShowMask = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_SHOWMASK");
|
||||
EvLabRegionChannel = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_CHANNEL");
|
||||
labRegionBox = Gtk::manage(new Gtk::VBox());
|
||||
|
||||
labRegionList = Gtk::manage(new Gtk::ListViewText(3));
|
||||
labRegionList->set_size_request(-1, 100);
|
||||
labRegionList->set_size_request(-1, 150);
|
||||
labRegionList->set_can_focus(false);
|
||||
labRegionList->set_column_title(0, "#");
|
||||
labRegionList->set_column_title(1, M("TP_COLORTONING_LABREGION_LIST_TITLE"));
|
||||
@@ -394,6 +399,10 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
||||
labRegionDown->add(*Gtk::manage(new RTImage("arrow-down-small.png")));
|
||||
labRegionDown->signal_clicked().connect(sigc::mem_fun(*this, &ColorToning::labRegionDownPressed));
|
||||
add_button(labRegionDown, vb);
|
||||
labRegionCopy = Gtk::manage(new Gtk::Button());
|
||||
labRegionCopy->add(*Gtk::manage(new RTImage("arrow-right-small.png")));
|
||||
labRegionCopy->signal_clicked().connect(sigc::mem_fun(*this, &ColorToning::labRegionCopyPressed));
|
||||
add_button(labRegionCopy, vb);
|
||||
hb->pack_start(*vb, Gtk::PACK_SHRINK);
|
||||
labRegionBox->pack_start(*hb, true, true);
|
||||
|
||||
@@ -403,9 +412,33 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
||||
labRegionSaturation = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_SATURATION"), -100, 100, 1, 0));
|
||||
labRegionSaturation->setAdjusterListener(this);
|
||||
labRegionBox->pack_start(*labRegionSaturation);
|
||||
labRegionLightness = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_LIGHTNESS"), -100, 100, 1, 0));
|
||||
labRegionLightness->setAdjusterListener(this);
|
||||
labRegionBox->pack_start(*labRegionLightness);
|
||||
|
||||
labRegionSlope = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_SLOPE"), 0.1, 4.0, 0.001, 1));
|
||||
labRegionSlope->setLogScale(4, 0.1);
|
||||
labRegionSlope->setAdjusterListener(this);
|
||||
labRegionBox->pack_start(*labRegionSlope);
|
||||
labRegionOffset = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_OFFSET"), -0.1, 0.1, 0.001, 0));
|
||||
labRegionOffset->setAdjusterListener(this);
|
||||
labRegionBox->pack_start(*labRegionOffset);
|
||||
labRegionPower = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_POWER"), 0.1, 4.0, 0.001, 1));
|
||||
labRegionPower->setAdjusterListener(this);
|
||||
labRegionPower->setLogScale(4, 0.1);
|
||||
labRegionBox->pack_start(*labRegionPower);
|
||||
|
||||
hb = Gtk::manage(new Gtk::HBox());
|
||||
labRegionChannel = Gtk::manage(new MyComboBoxText());
|
||||
labRegionChannel->append(M("TP_COLORTONING_LABREGION_CHANNEL_ALL"));
|
||||
labRegionChannel->append(M("TP_COLORTONING_LABREGION_CHANNEL_R"));
|
||||
labRegionChannel->append(M("TP_COLORTONING_LABREGION_CHANNEL_G"));
|
||||
labRegionChannel->append(M("TP_COLORTONING_LABREGION_CHANNEL_B"));
|
||||
labRegionChannel->set_active(0);
|
||||
labRegionChannel->signal_changed().connect(sigc::mem_fun(*this, &ColorToning::labRegionChannelChanged));
|
||||
|
||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("TP_COLORTONING_LABREGION_CHANNEL") + ": ")), Gtk::PACK_SHRINK);
|
||||
hb->pack_start(*labRegionChannel);
|
||||
labRegionBox->pack_start(*hb);
|
||||
|
||||
labRegionBox->pack_start(*Gtk::manage(new Gtk::HSeparator()));
|
||||
|
||||
CurveEditorGroup *labRegionEditorG = Gtk::manage(new CurveEditorGroup(options.lastColorToningCurvesDir, M("TP_COLORTONING_LABREGION_MASK")));
|
||||
labRegionEditorG->setCurveListener(this);
|
||||
@@ -440,11 +473,22 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
||||
labRegionEditorG->show();
|
||||
labRegionBox->pack_start(*labRegionEditorG, Gtk::PACK_SHRINK, 2);
|
||||
|
||||
labRegionMaskBlur = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_MASKBLUR"), -10, 100, 0.1, 0));
|
||||
labRegionMaskBlur->setLogScale(10, 0);
|
||||
labRegionMaskBlur->setAdjusterListener(this);
|
||||
labRegionBox->pack_start(*labRegionMaskBlur);
|
||||
|
||||
labRegionShowMask = Gtk::manage(new Gtk::CheckButton(M("TP_COLORTONING_LABREGION_SHOWMASK")));
|
||||
labRegionShowMask->signal_toggled().connect(sigc::mem_fun(*this, &ColorToning::labRegionShowMaskChanged));
|
||||
labRegionBox->pack_start(*labRegionShowMask, Gtk::PACK_SHRINK, 4);
|
||||
|
||||
pack_start(*labRegionBox, Gtk::PACK_EXPAND_WIDGET, 4);
|
||||
|
||||
labRegionSaturation->delay = options.adjusterMaxDelay;
|
||||
labRegionSlope->delay = options.adjusterMaxDelay;
|
||||
labRegionOffset->delay = options.adjusterMaxDelay;
|
||||
labRegionPower->delay = options.adjusterMaxDelay;
|
||||
labRegionMaskBlur->delay = options.adjusterMaxDelay;
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
show_all();
|
||||
@@ -1335,8 +1379,14 @@ void ColorToning::adjusterChanged(Adjuster* a, double newval)
|
||||
listener->panelChanged (EvColorToningStrength, a->getTextValue());
|
||||
} else if (a == labRegionSaturation) {
|
||||
listener->panelChanged(EvLabRegionSaturation, a->getTextValue());
|
||||
} else if (a == labRegionLightness) {
|
||||
listener->panelChanged(EvLabRegionLightness, a->getTextValue());
|
||||
} else if (a == labRegionSlope) {
|
||||
listener->panelChanged(EvLabRegionSlope, a->getTextValue());
|
||||
} else if (a == labRegionOffset) {
|
||||
listener->panelChanged(EvLabRegionOffset, a->getTextValue());
|
||||
} else if (a == labRegionPower) {
|
||||
listener->panelChanged(EvLabRegionPower, a->getTextValue());
|
||||
} else if (a == labRegionMaskBlur) {
|
||||
listener->panelChanged(EvLabRegionMaskBlur, a->getTextValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,10 +1445,14 @@ void ColorToning::labRegionGet(int idx)
|
||||
double la, lb;
|
||||
labRegionAB->getParams(la, lb, r.a, r.b);
|
||||
r.saturation = labRegionSaturation->getValue();
|
||||
r.lightness = labRegionLightness->getValue();
|
||||
r.slope = labRegionSlope->getValue();
|
||||
r.offset = labRegionOffset->getValue();
|
||||
r.power = labRegionPower->getValue();
|
||||
r.hueMask = labRegionHueMask->getCurve();
|
||||
r.chromaticityMask = labRegionChromaticityMask->getCurve();
|
||||
r.lightnessMask = labRegionLightnessMask->getCurve();
|
||||
r.maskBlur = labRegionMaskBlur->getValue();
|
||||
r.channel = labRegionChannel->get_active_row_number() - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,6 +1516,21 @@ void ColorToning::labRegionDownPressed()
|
||||
}
|
||||
|
||||
|
||||
void ColorToning::labRegionCopyPressed()
|
||||
{
|
||||
if (labRegionSelected < int(labRegionData.size())) {
|
||||
auto r = labRegionData[labRegionSelected];
|
||||
labRegionData.push_back(r);
|
||||
labRegionSelected = labRegionData.size()-1;
|
||||
labRegionPopulateList();
|
||||
|
||||
if (listener) {
|
||||
listener->panelChanged(EvLabRegionList, M("HISTORY_CHANGED"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorToning::labRegionShowMaskChanged()
|
||||
{
|
||||
if (listener) {
|
||||
@@ -1479,13 +1548,26 @@ void ColorToning::labRegionPopulateList()
|
||||
for (size_t i = 0; i < labRegionData.size(); ++i) {
|
||||
auto &r = labRegionData[i];
|
||||
auto j = labRegionList->append(std::to_string(i+1));
|
||||
labRegionList->set_text(j, 1, Glib::ustring::compose("a=%1 b=%2 s=%3 l=%4", round_ab(r.a), round_ab(r.b), r.saturation, r.lightness));
|
||||
labRegionList->set_text(j, 1, Glib::ustring::compose("a=%1 b=%2 S=%3\ns=%4 o=%5 p=%6", round_ab(r.a), round_ab(r.b), r.saturation, r.slope, r.offset, r.power));
|
||||
const char *ch = "";
|
||||
switch (r.channel) {
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_R:
|
||||
ch = "\n[Red]"; break;
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_G:
|
||||
ch = "\n[Green]"; break;
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_B:
|
||||
ch = "\n[Blue]"; break;
|
||||
default:
|
||||
ch = "";
|
||||
}
|
||||
labRegionList->set_text(
|
||||
j, 2, Glib::ustring::compose(
|
||||
"%1%2%3",
|
||||
"%1%2%3%4%5",
|
||||
hasMask(dflt.hueMask, r.hueMask) ? "H" : "",
|
||||
hasMask(dflt.chromaticityMask, r.chromaticityMask) ? "C" : "",
|
||||
hasMask(dflt.lightnessMask, r.lightnessMask) ? "L" : ""));
|
||||
hasMask(dflt.lightnessMask, r.lightnessMask) ? "L" : "",
|
||||
r.maskBlur ? Glib::ustring::compose(" b=%1", r.maskBlur) : "",
|
||||
ch));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1501,18 +1583,34 @@ void ColorToning::labRegionShow(int idx, bool list_only)
|
||||
if (!list_only) {
|
||||
labRegionAB->setParams(0, 0, r.a, r.b, false);
|
||||
labRegionSaturation->setValue(r.saturation);
|
||||
labRegionLightness->setValue(r.lightness);
|
||||
labRegionSlope->setValue(r.slope);
|
||||
labRegionOffset->setValue(r.offset);
|
||||
labRegionPower->setValue(r.power);
|
||||
labRegionHueMask->setCurve(r.hueMask);
|
||||
labRegionChromaticityMask->setCurve(r.chromaticityMask);
|
||||
labRegionLightnessMask->setCurve(r.lightnessMask);
|
||||
labRegionMaskBlur->setValue(r.maskBlur);
|
||||
labRegionChannel->set_active(r.channel+1);
|
||||
}
|
||||
labRegionList->set_text(idx, 1, Glib::ustring::compose("a=%1 b=%2 S=%3\ns=%4 o=%5 p=%6", round_ab(r.a), round_ab(r.b), r.saturation, r.slope, r.offset, r.power));
|
||||
const char *ch = "";
|
||||
switch (r.channel) {
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_R:
|
||||
ch = "\n[Red]"; break;
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_G:
|
||||
ch = "\n[Green]"; break;
|
||||
case rtengine::ColorToningParams::LabCorrectionRegion::CHAN_B:
|
||||
ch = "\n[Blue]"; break;
|
||||
default:
|
||||
ch = "";
|
||||
}
|
||||
labRegionList->set_text(idx, 1, Glib::ustring::compose("a=%1 b=%2 s=%3 l=%4", round_ab(r.a), round_ab(r.b), r.saturation, r.lightness));
|
||||
labRegionList->set_text(
|
||||
idx, 2, Glib::ustring::compose(
|
||||
"%1%2%3",
|
||||
"%1%2%3%4%5",
|
||||
hasMask(dflt.hueMask, r.hueMask) ? "H" : "",
|
||||
hasMask(dflt.chromaticityMask, r.chromaticityMask) ? "C" : "",
|
||||
hasMask(dflt.lightnessMask, r.lightnessMask) ? "L" : ""));
|
||||
hasMask(dflt.lightnessMask, r.lightnessMask) ? "L" : "",
|
||||
r.maskBlur ? Glib::ustring::compose(" b=%1", r.maskBlur) : "", ch));
|
||||
Gtk::TreePath pth;
|
||||
pth.push_back(idx);
|
||||
labRegionList->get_selection()->select(pth);
|
||||
@@ -1522,6 +1620,14 @@ void ColorToning::labRegionShow(int idx, bool list_only)
|
||||
}
|
||||
|
||||
|
||||
void ColorToning::labRegionChannelChanged()
|
||||
{
|
||||
if (listener) {
|
||||
listener->panelChanged(EvLabRegionChannel, labRegionChannel->get_active_text());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorToning::setEditProvider(EditDataProvider *provider)
|
||||
{
|
||||
labRegionHueMask->setEditProvider(provider);
|
||||
|
||||
@@ -67,7 +67,9 @@ private:
|
||||
void labRegionRemovePressed();
|
||||
void labRegionUpPressed();
|
||||
void labRegionDownPressed();
|
||||
void labRegionCopyPressed();
|
||||
void labRegionShowMaskChanged();
|
||||
void labRegionChannelChanged();
|
||||
void labRegionPopulateList();
|
||||
void labRegionShow(int idx, bool list_only=false);
|
||||
void labRegionGet(int idx);
|
||||
@@ -130,10 +132,15 @@ private:
|
||||
rtengine::ProcEvent EvLabRegionAB;
|
||||
rtengine::ProcEvent EvLabRegionSaturation;
|
||||
rtengine::ProcEvent EvLabRegionLightness;
|
||||
rtengine::ProcEvent EvLabRegionSlope;
|
||||
rtengine::ProcEvent EvLabRegionOffset;
|
||||
rtengine::ProcEvent EvLabRegionPower;
|
||||
rtengine::ProcEvent EvLabRegionHueMask;
|
||||
rtengine::ProcEvent EvLabRegionChromaticityMask;
|
||||
rtengine::ProcEvent EvLabRegionLightnessMask;
|
||||
rtengine::ProcEvent EvLabRegionMaskBlur;
|
||||
rtengine::ProcEvent EvLabRegionShowMask;
|
||||
rtengine::ProcEvent EvLabRegionChannel;
|
||||
|
||||
Gtk::VBox *labRegionBox;
|
||||
Gtk::ListViewText *labRegionList;
|
||||
@@ -141,12 +148,17 @@ private:
|
||||
Gtk::Button *labRegionRemove;
|
||||
Gtk::Button *labRegionUp;
|
||||
Gtk::Button *labRegionDown;
|
||||
Gtk::Button *labRegionCopy;
|
||||
LabGrid *labRegionAB;
|
||||
Adjuster *labRegionSaturation;
|
||||
Adjuster *labRegionLightness;
|
||||
Adjuster *labRegionSlope;
|
||||
Adjuster *labRegionOffset;
|
||||
Adjuster *labRegionPower;
|
||||
MyComboBoxText *labRegionChannel;
|
||||
FlatCurveEditor *labRegionHueMask;
|
||||
FlatCurveEditor *labRegionChromaticityMask;
|
||||
FlatCurveEditor *labRegionLightnessMask;
|
||||
Adjuster *labRegionMaskBlur;
|
||||
Gtk::CheckButton *labRegionShowMask;
|
||||
std::vector<rtengine::ColorToningParams::LabCorrectionRegion> labRegionData;
|
||||
int labRegionSelected;
|
||||
|
||||
Reference in New Issue
Block a user