Skip to content

Commit 1c287d3

Browse files
Color equalizer simplifications
Don't interpolate/mix where simpler maths will do it.
1 parent 1d0cd9b commit 1c287d3

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

data/kernels/colorequal.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef enum dt_iop_colorequal_channel_t
3737

3838
static inline float _get_satweight(const float sat, global float *weights)
3939
{
40-
const float isat = SATSIZE * (1.0f + clamp(sat, -1.0f, 1.0f - (1.0f / SATSIZE)));
40+
const float isat = (float)SATSIZE * (1.0f + clamp(sat, -1.0f, 1.0f - (1.0f / SATSIZE)));
4141
const float base = floor(isat);
4242
const int i = (int)base;
4343
return weights[i] + (isat - base) * (weights[i+1] - weights[i]);
@@ -247,9 +247,9 @@ __kernel void apply_guided(global float2 *uv,
247247
const float2 CV = { a[k].x * uv[k].x + a[k].y * uv[k].y + b[k].x,
248248
a[k].z * uv[k].x + a[k].w * uv[k].y + b[k].y };
249249

250-
corrections[k].y = mix(1.0f, CV.x, _get_satweight(saturation[k] - sat_shift, weights));
250+
corrections[k].y = 1.0f + (CV.x - 1.0f) * _get_satweight(saturation[k] - sat_shift, weights);
251251
const float gradient_weight = 1.0f - clipf(scharr[k]);
252-
b_corrections[k] = mix(0.0f, CV.y, gradient_weight * _get_satweight(saturation[k] - bright_shift, weights));
252+
b_corrections[k] = CV.y * gradient_weight * _get_satweight(saturation[k] - bright_shift, weights);
253253
}
254254

255255
__kernel void sample_input(__read_only image2d_t dev_in,

src/iop/colorequal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,9 @@ static void _guide_with_chromaticity(float *const restrict UV,
896896
const float uv[2] = { UV[2 * k + 0], UV[2 * k + 1] };
897897
const float cv[2] = { a[4 * k + 0] * uv[0] + a[4 * k + 1] * uv[1] + b[2 * k + 0],
898898
a[4 * k + 2] * uv[0] + a[4 * k + 3] * uv[1] + b[2 * k + 1] };
899-
corrections[2 * k + 1] = interpolatef(_get_satweight(saturation[k] - sat_shift), cv[0], 1.0f);
899+
corrections[2 * k + 1] = 1.0f + (cv[0] - 1.0f) * _get_satweight(saturation[k] - sat_shift);
900900
const float gradient_weight = 1.0f - CLIP(gradients[k]);
901-
b_corrections[k] = interpolatef(gradient_weight * _get_satweight(saturation[k] - bright_shift), cv[1], 0.0f);
901+
b_corrections[k] = cv[1] * gradient_weight * _get_satweight(saturation[k] - bright_shift);
902902
}
903903
dt_free_align(a);
904904
dt_free_align(b);

0 commit comments

Comments
 (0)