95 if(border <= 0)
return;
96 const int max_col =
width - border - 1;
98 #pragma omp parallel for simd default(none) \
99 dt_omp_firstprivate(mask, width, height, border, max_col) \
100 schedule(simd:static) aligned(mask : 64) if((size_t)width * height > 10000)
104 float *
const rowptr = mask + (size_t)(
row *
width);
105 for(
int i = 0;
i < border;
i++)
107 rowptr[
i] = rowptr[border];
108 rowptr[
width -
i - 1] = rowptr[max_col];
111 const float *
const top_row = mask + (size_t)(border *
width);
112 const float *
const bot_row = mask + (size_t)(
height - border - 1) *
width;
114 #pragma omp parallel for simd default(none) \
115 dt_omp_firstprivate(mask, width, height, border, max_col, top_row, bot_row) \
116 schedule(simd:static) aligned(mask : 64) if((size_t)width * height > 10000)
118 for(
int col = 0; col <
width; col++)
120 const int c =
MIN(max_col,
MAX(col, border));
121 const float top = top_row[
c];
122 const float bot = bot_row[
c];
123 for(
int i = 0;
i < border;
i++)
134 const float temp = -2.0f *
sqf(sigma);
135 const float range =
sqf(3.0f * 0.84f);
137 for(
int k = -2; k <= 2; k++)
139 for(
int j = -2; j <= 2; j++)
141 if((
sqf(k) +
sqf(j)) <= range)
144 sum +=
kernel[k + 2][j + 2];
147 kernel[k + 2][j + 2] = 0.0f;
150 for(
int i = 0;
i < 5;
i++)
155 for(
int j = 0; j < 5; j++)
164#define FAST_BLUR_5 ( \
165 blurmat[0] * ((src[i - w2 - 1] + src[i - w2 + 1]) + (src[i - w1 - 2] + src[i - w1 + 2]) + (src[i + w1 - 2] + src[i + w1 + 2]) + (src[i + w2 - 1] + src[i + w2 + 1])) + \
166 blurmat[1] * (src[i - w2] + src[i - 2] + src[i + 2] + src[i + w2]) + \
167 blurmat[2] * (src[i - w1 - 1] + src[i - w1 + 1] + src[i + w1 - 1] + src[i + w1 + 1]) + \
168 blurmat[3] * (src[i - w1] + src[i - 1] + src[i + 1] + src[i + w1]) + \
169 blurmat[4] * src[i] )
174 const float temp = -2.0f *
sqf(sigma);
175 const float range =
sqf(3.0f * 1.5f);
177 for(
int k = -4; k <= 4; k++)
179 for(
int j = -4; j <= 4; j++)
181 if((
sqf(k) +
sqf(j)) <= range)
184 sum +=
kernel[k + 4][j + 4];
187 kernel[k + 4][j + 4] = 0.0f;
190 for(
int i = 0;
i < 9;
i++)
195 for(
int j = 0; j < 9; j++)
213#define FAST_BLUR_9 ( \
214 blurmat[12] * (src[i - w4 - 2] + src[i - w4 + 2] + src[i - w2 - 4] + src[i - w2 + 4] + src[i + w2 - 4] + src[i + w2 + 4] + src[i + w4 - 2] + src[i + w4 + 2]) + \
215 blurmat[11] * (src[i - w4 - 1] + src[i - w4 + 1] + src[i - w1 - 4] + src[i - w1 + 4] + src[i + w1 - 4] + src[i + w1 + 4] + src[i + w4 - 1] + src[i + w4 + 1]) + \
216 blurmat[10] * (src[i - w4] + src[i - 4] + src[i + 4] + src[i + w4]) + \
217 blurmat[9] * (src[i - w3 - 3] + src[i - w3 + 3] + src[i + w3 - 3] + src[i + w3 + 3]) + \
218 blurmat[8] * (src[i - w3 - 2] + src[i - w3 + 2] + src[i - w2 - 3] + src[i - w2 + 3] + src[i + w2 - 3] + src[i + w2 + 3] + src[i + w3 - 2] + src[i + w3 + 2]) + \
219 blurmat[7] * (src[i - w3 - 1] + src[i - w3 + 1] + src[i - w1 - 3] + src[i - w1 + 3] + src[i + w1 - 3] + src[i + w1 + 3] + src[i + w3 - 1] + src[i + w3 + 1]) + \
220 blurmat[6] * (src[i - w3] + src[i - 3] + src[i + 3] + src[i + w3]) + \
221 blurmat[5] * (src[i - w2 - 2] + src[i - w2 + 2] + src[i + w2 - 2] + src[i + w2 + 2]) + \
222 blurmat[4] * (src[i - w2 - 1] + src[i - w2 + 1] + src[i - w1 - 2] + src[i - w1 + 2] + src[i + w1 - 2] + src[i + w1 + 2] + src[i + w2 - 1] + src[i + w2 + 1]) + \
223 blurmat[3] * (src[i - w2] + src[i - 2] + src[i + 2] + src[i + w2]) + \
224 blurmat[2] * (src[i - w1 - 1] + src[i - w1 + 1] + src[i + w1 - 1] + src[i + w1 + 1]) + \
225 blurmat[1] * (src[i - w1] + src[i - 1] + src[i + 1] + src[i + w1]) + \
226 blurmat[0] * src[i] )
238 #pragma omp parallel for simd default(none) \
239 dt_omp_firstprivate(blurmat, src, out, width, height, w1, w2, w3, w4) \
240 schedule(simd:static) aligned(src, out : 64) if((size_t)width * height > 50000)
245 for(
int col = 4; col <
width - 4; col++)
247 const int i = row_off + col;
257 const float temp = -2.0f *
sqf(sigma);
258 const float range =
sqf(3.0f * 2.0f);
260 for(
int k = -6; k <= 6; k++)
262 for(
int j = -6; j <= 6; j++)
264 if((
sqf(k) +
sqf(j)) <= range)
267 sum +=
kernel[k + 6][j + 6];
270 kernel[k + 6][j + 6] = 0.0f;
273 for(
int i = 0;
i < 13;
i++)
278 for(
int j = 0; j < 13; j++)
304 const int width,
const int height,
const dt_aligned_pixel_t wb)
308 #pragma omp parallel for simd default(none) \
309 dt_omp_firstprivate(tmp, src, msize, wb) \
310 schedule(simd:static) aligned(tmp, src : 64) if(msize > 50000)
312 for(
int idx =0; idx < msize; idx++)
314 const float val = 0.333333333f * (fmaxf(src[4 * idx], 0.0f) / wb[0] + fmaxf(src[4 * idx + 1], 0.0f) / wb[1] + fmaxf(src[4 * idx + 2], 0.0f) / wb[2]);
315 tmp[idx] = sqrtf(val);
318 const float scale = 1.0f / 16.0f;
320 #pragma omp parallel for simd default(none) \
321 dt_omp_firstprivate(mask, tmp, width, height, scale) \
322 schedule(simd:static) aligned(mask, tmp : 64) if((size_t)width * height > 50000)
326 for(
int col = 1, idx =
row *
width + col; col <
width - 1; col++, idx++)
329 const float gx = 47.0f * (tmp[idx-
width-1] - tmp[idx-
width+1])
330 + 162.0f * (tmp[idx-1] - tmp[idx+1])
331 + 47.0f * (tmp[idx+
width-1] - tmp[idx+
width+1]);
332 const float gy = 47.0f * (tmp[idx-
width-1] - tmp[idx+
width-1])
334 + 47.0f * (tmp[idx-
width+1] - tmp[idx+
width+1]);
335 const float gradient_magnitude = sqrtf(
sqf(gx / 256.0f) +
sqf(gy / 256.0f));
336 mask[idx] = scale * gradient_magnitude;
357 #pragma omp parallel for simd default(none) \
358 dt_omp_firstprivate(src, tmp, msize, threshold, detail, out) \
359 schedule(simd:static) aligned(src, tmp, out : 64) if(msize > 50000)
361 for(
int idx = 0; idx < msize; idx++)
364 tmp[idx] = detail ? blend : 1.0f - blend;
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
static float kernel(const float *x, const float *y)
Definition colorchecker.c:469
const float i
Definition colorspaces_inline_conversions.h:669
const float c
Definition colorspaces_inline_conversions.h:1365
const float threshold
Definition colorspaces_inline_conversions.h:340
static const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:184
const float top
Definition colorspaces_inline_conversions.h:672
static const int row
Definition colorspaces_inline_conversions.h:175
void dt_masks_blur_9x9_coeff(float *c, const float sigma)
Definition detail.c:171
void dt_masks_blur_9x9(float *const restrict src, float *const restrict out, const int width, const int height, const float sigma)
Definition detail.c:228
void _masks_blur_13x13_coeff(float *c, const float sigma)
Definition detail.c:254
void dt_masks_extend_border(float *const restrict mask, const int width, const int height, const int border)
Definition detail.c:93
void dt_masks_calc_detail_mask(float *const restrict src, float *const restrict out, float *const restrict tmp, const int width, const int height, const float threshold, const gboolean detail)
Definition detail.c:353
static float calcBlendFactor(float val, float threshold)
Definition detail.c:345
void _masks_blur_5x5_coeff(float *c, const float sigma)
Definition detail.c:131
#define FAST_BLUR_9
Definition detail.c:213
void dt_masks_calc_rawdetail_mask(float *const restrict src, float *const restrict mask, float *const restrict tmp, const int width, const int height, const dt_aligned_pixel_t wb)
Definition detail.c:303
#define w2
Definition lmmse.c:65
#define w1
Definition lmmse.c:64
#define w4
Definition lmmse.c:67
#define w3
Definition lmmse.c:66
static float sqf(const float x)
Definition math.h:223
static float dt_fast_expf(const float x)
Definition math.h:290
#define MIN(a, b)
Definition thinplate.c:32
#define MAX(a, b)
Definition thinplate.c:29