Merge pull request #4292 from Beep6581/colortoning-rgb-speedup
Speedup for Colour Toning Methods 'RGB sliders' and 'RGB curves'
This commit is contained in:
@@ -4168,29 +4168,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
||||
|
||||
// Luminance = (0.299f*r + 0.587f*g + 0.114f*b)
|
||||
|
||||
float h, s, l;
|
||||
Color::rgb2hsl (r, g, b, h, s, l);
|
||||
float s, l;
|
||||
Color::rgb2slfloat (r, g, b, s, l);
|
||||
|
||||
float l_ = Color::gamma_srgb (l * 65535.f) / 65535.f;
|
||||
float l_ = Color::gammatab_srgb1[l * 65535.f];
|
||||
|
||||
// get the opacity and tweak it to preserve saturated colors
|
||||
float opacity;
|
||||
float opacity = 0.f;
|
||||
|
||||
if (ctOpacityCurve) {
|
||||
opacity = (1.f - min<float> (s / satLimit, 1.f) * (1.f - satLimitOpacity)) * ctOpacityCurve.lutOpacityCurve[l_ * 500.f];
|
||||
}
|
||||
|
||||
if (!ctOpacityCurve) {
|
||||
opacity = 0.f;
|
||||
}
|
||||
|
||||
float r2, g2, b2;
|
||||
ctColorCurve.getVal (l_, r2, g2, b2); // get the color from the color curve
|
||||
|
||||
float h2, s2, l2;
|
||||
Color::rgb2hsl (r2, g2, b2, h2, s2, l2); // transform this new color to hsl
|
||||
Color::rgb2hslfloat (r2, g2, b2, h2, s2, l2); // transform this new color to hsl
|
||||
|
||||
Color::hsl2rgb (h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2);
|
||||
Color::hsl2rgbfloat (h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2);
|
||||
|
||||
rtemp[ti * TS + tj] = r + (r2 - r) * opacity; // merge the color to the old color, depending on the opacity
|
||||
gtemp[ti * TS + tj] = g + (g2 - g) * opacity;
|
||||
@@ -4869,31 +4865,31 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
||||
|
||||
for (int i = 0; i < tH; i++) {
|
||||
for (int j = 0; j < tW; j++) {
|
||||
float r = tmpImage->r (i, j);
|
||||
float g = tmpImage->g (i, j);
|
||||
float b = tmpImage->b (i, j);
|
||||
float r = tmpImage->r(i, j);
|
||||
float g = tmpImage->g(i, j);
|
||||
float b = tmpImage->b(i, j);
|
||||
|
||||
// Luminance = (0.299f*r + 0.587f*g + 0.114f*b)
|
||||
|
||||
float h, s, l;
|
||||
Color::rgb2hsl (r, g, b, h, s, l);
|
||||
float s, l;
|
||||
Color::rgb2slfloat(r, g, b, s, l);
|
||||
|
||||
float l_ = Color::gamma_srgb (l * 65535.f) / 65535.f;
|
||||
float l_ = Color::gammatab_srgb1[l * 65535.f];
|
||||
|
||||
// get the opacity and tweak it to preserve saturated colors
|
||||
// get the opacity and tweak it to preserve saturated colours
|
||||
float opacity = ctOpacityCurve.lutOpacityCurve[l_ * 500.f] / 4.f;
|
||||
|
||||
float r2, g2, b2;
|
||||
ctColorCurve.getVal (l_, r2, g2, b2); // get the color from the color curve
|
||||
ctColorCurve.getVal(l_, r2, g2, b2); // get the colour from the colour curve
|
||||
|
||||
float h2, s2, l2;
|
||||
Color::rgb2hsl (r2, g2, b2, h2, s2, l2); // transform this new color to hsl
|
||||
Color::rgb2hslfloat(r2, g2, b2, h2, s2, l2); // transform this new colour to hsl
|
||||
|
||||
Color::hsl2rgb (h2, s2, l, r2, g2, b2);
|
||||
Color::hsl2rgbfloat(h2, s2, l, r2, g2, b2);
|
||||
|
||||
tmpImage->r (i, j) = r + (r2 - r) * opacity;
|
||||
tmpImage->g (i, j) = g + (g2 - g) * opacity;
|
||||
tmpImage->b (i, j) = b + (b2 - b) * opacity;
|
||||
tmpImage->r(i, j) = intp(opacity, r2, r);
|
||||
tmpImage->g(i, j) = intp(opacity, g2, g);
|
||||
tmpImage->b(i, j) = intp(opacity, b2, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user