34#define MIN_FLOAT exp2f(-16.0f)
76static
void pixel_rgb_mean(const float *const restrict image,
78 const size_t
k, const size_t
ch,
86 for(int c = 0; c < 3; ++c)
94static
void pixel_rgb_value(const float *const restrict image,
96 const size_t
k, const size_t
ch,
102 const float lum =
exposure_boost * fmaxf(fmaxf(image[
k], image[
k + 1]), image[
k + 2]);
108static
void pixel_rgb_lightness(const float *const restrict image,
110 const size_t
k, const size_t
ch,
116 const float max_rgb = fmaxf(fmaxf(image[
k], image[
k + 1]), image[
k + 2]);
117 const float min_rgb = fminf(fminf(image[
k], image[
k + 1]), image[
k + 2]);
122static
void pixel_rgb_norm_1(const float *const restrict image,
124 const size_t
k, const size_t
ch,
132 for(int
c = 0;
c < 3; ++
c)
133 lum += fabsf(image[
k + c]);
140static
void pixel_rgb_norm_2(const float *const restrict image,
142 const size_t
k, const size_t
ch,
150 for(int
c = 0;
c < 3; ++
c) result += image[
k + c] * image[
k + c];
157static
void pixel_rgb_norm_power(const float *const restrict image,
159 const size_t
k, const size_t
ch,
165 float numerator = 0.0f;
166 float denominator = 0.0f;
167 __OMP_SIMD__(aligned(image:64) reduction(+:numerator, denominator))
168 for(int
c = 0;
c < 3; ++
c)
170 const float value = fabsf(image[
k + c]);
172 const float RGB_cubic = RGB_square *
value;
173 numerator += RGB_cubic;
174 denominator += RGB_square;
181static
void pixel_rgb_geomean(const float *const restrict image,
183 const size_t
k, const size_t
ch,
191 for(int
c = 0;
c < 3; ++
c)
193 lum *= fabsf(image[
k + c]);
206 _Pragma ("omp parallel for simd default(firstprivate) \
207 aligned(in, out:64)" ) \
208 for(size_t k = 0; k < num_elem; k += ch) \
210 fn(in, out, k, ch, exposure_boost, fulcrum, contrast_boost); \
217 for(size_t k = 0; k < num_elem; k += ch) \
219 fn(in, out, k, ch, exposure_boost, fulcrum, contrast_boost); \
227static inline void luminance_mask(
const float *
const restrict in,
float *
const restrict
out,
237 LOOP(pixel_rgb_mean);
240 LOOP(pixel_rgb_lightness);
243 LOOP(pixel_rgb_value);
246 LOOP(pixel_rgb_norm_1);
249 LOOP(pixel_rgb_norm_2);
252 LOOP(pixel_rgb_norm_power);
255 LOOP(pixel_rgb_geomean);
const dt_colormatrix_t dt_aligned_pixel_t out
for(size_t c=0;c< 3;c++) sRGB[c]
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
#define __OMP_SIMD__(...)
#define __OMP_DECLARE_SIMD__(...)
#define __DT_CLONE_TARGETS__
static const dt_aligned_pixel_simd_t value
float *const restrict const size_t const size_t const float const float fulcrum
float *const restrict const size_t const size_t const float exposure_boost
dt_iop_luminance_mask_method_t
float *const restrict luminance
static float linear_contrast(const float pixel, const float fulcrum, const float contrast)
float *const restrict const size_t const size_t const float const float const float contrast_boost
float *const restrict const size_t k
float *const restrict const size_t const size_t ch