labgrid: work on [0,1] values
This commit is contained in:
parent
fb44445f2a
commit
74a467fb4e
@ -5782,8 +5782,8 @@ void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib:
|
|||||||
*/
|
*/
|
||||||
void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread)
|
void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread)
|
||||||
{
|
{
|
||||||
const float factor = ColorToningParams::LABGRID_CORR_MAX * 3.f;
|
const float factor = 3.f;
|
||||||
const float scaling = ColorToningParams::LABGRID_CORR_SCALE;
|
const float scaling = 3.f;
|
||||||
float a_scale = (params->colorToning.labgridAHigh - params->colorToning.labgridALow) / factor / scaling;
|
float a_scale = (params->colorToning.labgridAHigh - params->colorToning.labgridALow) / factor / scaling;
|
||||||
float a_base = params->colorToning.labgridALow / scaling;
|
float a_base = params->colorToning.labgridALow / scaling;
|
||||||
float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling;
|
float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling;
|
||||||
|
@ -33,7 +33,7 @@ void ImProcFunctions::labColorCorrectionRegions(LabImage *lab)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float factor = ColorToningParams::LABGRID_CORR_MAX * 3.f;
|
const float factor = 3.f;
|
||||||
const float scaling = 1.f;
|
const float scaling = 1.f;
|
||||||
|
|
||||||
int n = params->colorToning.labregions.size();
|
int n = params->colorToning.labregions.size();
|
||||||
|
@ -596,7 +596,7 @@ void ColorToning::read (const ProcParams* pp, const ParamsEdited* pedited)
|
|||||||
|
|
||||||
lastLumamode = pp->colorToning.lumamode;
|
lastLumamode = pp->colorToning.lumamode;
|
||||||
|
|
||||||
labgrid->setParams(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh, false);
|
labgrid->setParams(pp->colorToning.labgridALow / ColorToningParams::LABGRID_CORR_MAX, pp->colorToning.labgridBLow / ColorToningParams::LABGRID_CORR_MAX, pp->colorToning.labgridAHigh / ColorToningParams::LABGRID_CORR_MAX, pp->colorToning.labgridBHigh / ColorToningParams::LABGRID_CORR_MAX, false);
|
||||||
|
|
||||||
if (pedited && !pedited->colorToning.method) {
|
if (pedited && !pedited->colorToning.method) {
|
||||||
method->set_active (5);
|
method->set_active (5);
|
||||||
@ -667,6 +667,10 @@ void ColorToning::write (ProcParams* pp, ParamsEdited* pedited)
|
|||||||
pp->colorToning.strength = strength->getIntValue();
|
pp->colorToning.strength = strength->getIntValue();
|
||||||
|
|
||||||
labgrid->getParams(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh);
|
labgrid->getParams(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh);
|
||||||
|
pp->colorToning.labgridALow *= ColorToningParams::LABGRID_CORR_MAX;
|
||||||
|
pp->colorToning.labgridAHigh *= ColorToningParams::LABGRID_CORR_MAX;
|
||||||
|
pp->colorToning.labgridBLow *= ColorToningParams::LABGRID_CORR_MAX;
|
||||||
|
pp->colorToning.labgridBHigh *= ColorToningParams::LABGRID_CORR_MAX;
|
||||||
|
|
||||||
labRegionGet(labRegionSelected);
|
labRegionGet(labRegionSelected);
|
||||||
labRegionShow(labRegionSelected, true);
|
labRegionShow(labRegionSelected, true);
|
||||||
@ -778,7 +782,7 @@ void ColorToning::setDefaults (const ProcParams* defParams, const ParamsEdited*
|
|||||||
hlColSat->setDefault<int> (defParams->colorToning.hlColSat);
|
hlColSat->setDefault<int> (defParams->colorToning.hlColSat);
|
||||||
shadowsColSat->setDefault<int> (defParams->colorToning.shadowsColSat);
|
shadowsColSat->setDefault<int> (defParams->colorToning.shadowsColSat);
|
||||||
strength->setDefault (defParams->colorToning.strength);
|
strength->setDefault (defParams->colorToning.strength);
|
||||||
labgrid->setDefault(defParams->colorToning.labgridALow, defParams->colorToning.labgridBLow, defParams->colorToning.labgridAHigh, defParams->colorToning.labgridBHigh);
|
labgrid->setDefault(defParams->colorToning.labgridALow / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridBLow / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridAHigh / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridBHigh / ColorToningParams::LABGRID_CORR_MAX);
|
||||||
|
|
||||||
|
|
||||||
if (pedited) {
|
if (pedited) {
|
||||||
|
@ -44,7 +44,12 @@ using rtengine::Color;
|
|||||||
bool LabGrid::notifyListener()
|
bool LabGrid::notifyListener()
|
||||||
{
|
{
|
||||||
if (listener) {
|
if (listener) {
|
||||||
listener->panelChanged(evt, Glib::ustring::compose(evtMsg, int(high_a), int(high_b), int(low_a), int(low_b)));
|
const auto round =
|
||||||
|
[](float v) -> float
|
||||||
|
{
|
||||||
|
return int(v * 1000) / 1000.f;
|
||||||
|
};
|
||||||
|
listener->panelChanged(evt, Glib::ustring::compose(evtMsg, round(high_a), round(high_b), round(low_a), round(low_b)));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,8 +81,8 @@ void LabGrid::getParams(double &la, double &lb, double &ha, double &hb) const
|
|||||||
|
|
||||||
void LabGrid::setParams(double la, double lb, double ha, double hb, bool notify)
|
void LabGrid::setParams(double la, double lb, double ha, double hb, bool notify)
|
||||||
{
|
{
|
||||||
const double lo = -rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
const double lo = -1.0;
|
||||||
const double hi = rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
const double hi = 1.0;
|
||||||
low_a = rtengine::LIM(la, lo, hi);
|
low_a = rtengine::LIM(la, lo, hi);
|
||||||
low_b = rtengine::LIM(lb, lo, hi);
|
low_b = rtengine::LIM(lb, lo, hi);
|
||||||
high_a = rtengine::LIM(ha, lo, hi);
|
high_a = rtengine::LIM(ha, lo, hi);
|
||||||
@ -172,7 +177,7 @@ bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
|||||||
cr->translate(0, height);
|
cr->translate(0, height);
|
||||||
cr->scale(1., -1.);
|
cr->scale(1., -1.);
|
||||||
const int cells = 8;
|
const int cells = 8;
|
||||||
float step = rtengine::ColorToningParams::LABGRID_CORR_MAX / float(cells/2);
|
float step = 1.f / float(cells/2);
|
||||||
for (int j = 0; j < cells; j++) {
|
for (int j = 0; j < cells; j++) {
|
||||||
for (int i = 0; i < cells; i++) {
|
for (int i = 0; i < cells; i++) {
|
||||||
float R, G, B;
|
float R, G, B;
|
||||||
@ -192,10 +197,10 @@ bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
|||||||
// drawing the connection line
|
// drawing the connection line
|
||||||
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
|
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
|
||||||
float loa, hia, lob, hib;
|
float loa, hia, lob, hib;
|
||||||
loa = .5f * (width + width * low_a / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
loa = .5f * (width + width * low_a);
|
||||||
hia = .5f * (width + width * high_a / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
hia = .5f * (width + width * high_a);
|
||||||
lob = .5f * (height + height * low_b / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
lob = .5f * (height + height * low_b);
|
||||||
hib = .5f * (height + height * high_b / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
hib = .5f * (height + height * high_b);
|
||||||
cr->set_line_width(2.);
|
cr->set_line_width(2.);
|
||||||
cr->set_source_rgb(0.6, 0.6, 0.6);
|
cr->set_source_rgb(0.6, 0.6, 0.6);
|
||||||
cr->move_to(loa, lob);
|
cr->move_to(loa, lob);
|
||||||
@ -279,11 +284,11 @@ bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
|||||||
const float mb = (2.0 * mouse_y - height) / (float)height;
|
const float mb = (2.0 * mouse_y - height) / (float)height;
|
||||||
if (isDragged) {
|
if (isDragged) {
|
||||||
if (litPoint == LOW) {
|
if (litPoint == LOW) {
|
||||||
low_a = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
low_a = ma;
|
||||||
low_b = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
low_b = mb;
|
||||||
} else if (litPoint == HIGH) {
|
} else if (litPoint == HIGH) {
|
||||||
high_a = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
high_a = ma;
|
||||||
high_b = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
high_b = mb;
|
||||||
}
|
}
|
||||||
edited = true;
|
edited = true;
|
||||||
grab_focus();
|
grab_focus();
|
||||||
@ -295,10 +300,10 @@ bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
|||||||
queue_draw();
|
queue_draw();
|
||||||
} else {
|
} else {
|
||||||
litPoint = NONE;
|
litPoint = NONE;
|
||||||
float la = low_a / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float la = low_a;
|
||||||
float lb = low_b / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float lb = low_b;
|
||||||
float ha = high_a / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float ha = high_a;
|
||||||
float hb = high_b / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float hb = high_b;
|
||||||
const float thrs = 0.05f;
|
const float thrs = 0.05f;
|
||||||
const float distlo = (la - ma) * (la - ma) + (lb - mb) * (lb - mb);
|
const float distlo = (la - ma) * (la - ma) + (lb - mb) * (lb - mb);
|
||||||
const float disthi = (ha - ma) * (ha - ma) + (hb - mb) * (hb - mb);
|
const float disthi = (ha - ma) * (ha - ma) + (hb - mb) * (hb - mb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user