24#ifndef DT_PIXEL_LUMINANCE_MASK_H
25#define DT_PIXEL_LUMINANCE_MASK_H
37#define MIN_FLOAT exp2f(-16.0f)
79static
void pixel_rgb_mean(const float *const restrict image,
81 const size_t
k, const size_t
ch,
89 for(int c = 0; c < 3; ++c)
97static
void pixel_rgb_value(const float *const restrict image,
99 const size_t
k, const size_t
ch,
105 const float lum =
exposure_boost * fmaxf(fmaxf(image[
k], image[
k + 1]), image[
k + 2]);
111static
void pixel_rgb_lightness(const float *const restrict image,
113 const size_t
k, const size_t
ch,
119 const float max_rgb = fmaxf(fmaxf(image[
k], image[
k + 1]), image[
k + 2]);
120 const float min_rgb = fminf(fminf(image[
k], image[
k + 1]), image[
k + 2]);
125static
void pixel_rgb_norm_1(const float *const restrict image,
127 const size_t
k, const size_t
ch,
135 for(int
c = 0;
c < 3; ++
c)
136 lum += fabsf(image[
k + c]);
143static
void pixel_rgb_norm_2(const float *const restrict image,
145 const size_t
k, const size_t
ch,
153 for(int
c = 0;
c < 3; ++
c) result += image[
k + c] * image[
k + c];
160static
void pixel_rgb_norm_power(const float *const restrict image,
162 const size_t
k, const size_t
ch,
168 float numerator = 0.0f;
169 float denominator = 0.0f;
170 __OMP_SIMD__(aligned(image:64) reduction(+:numerator, denominator))
171 for(int
c = 0;
c < 3; ++
c)
173 const float value = fabsf(image[
k + c]);
175 const float RGB_cubic = RGB_square *
value;
176 numerator += RGB_cubic;
177 denominator += RGB_square;
184static
void pixel_rgb_geomean(const float *const restrict image,
186 const size_t
k, const size_t
ch,
194 for(int
c = 0;
c < 3; ++
c)
196 lum *= fabsf(image[
k + c]);
209 _Pragma ("omp parallel for simd default(firstprivate) \
210 aligned(in, out:64)" ) \
211 for(size_t k = 0; k < num_elem; k += ch) \
213 fn(in, out, k, ch, exposure_boost, fulcrum, contrast_boost); \
220 for(size_t k = 0; k < num_elem; k += ch) \
222 fn(in, out, k, ch, exposure_boost, fulcrum, contrast_boost); \
230static inline void luminance_mask(
const float *
const restrict in,
float *
const restrict
out,
240 LOOP(pixel_rgb_mean);
243 LOOP(pixel_rgb_lightness);
246 LOOP(pixel_rgb_value);
249 LOOP(pixel_rgb_norm_1);
252 LOOP(pixel_rgb_norm_2);
255 LOOP(pixel_rgb_norm_power);
258 LOOP(pixel_rgb_geomean);
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_colormatrix_t dt_aligned_pixel_t out
for(size_t c=0;c< 3;c++) sRGB[c]
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
#define __OMP_SIMD__(...)
#define __OMP_DECLARE_SIMD__(...)
static const dt_aligned_pixel_simd_t value
#define __DT_CLONE_TARGETS__