62#define DT_DISTANCE_TRANSFORM_MAX (1e20)
70 for(
int q = 1; q <= n-1; q++)
72 float s = (
f[q] +
sqf((
float)q)) - (
f[v[k]] +
sqf((
float)v[k]));
73 while(s <= z[k] * (
float)(2*q - 2*v[k]))
76 s = (
f[q] +
sqf((
float)q)) - (
f[v[k]] +
sqf((
float)v[k]));
78 s /= (float)(2*q - 2*v[k]);
86 for(
int q = 0; q <= n-1; q++)
88 while(z[k+1] < (
float)q)
90 d[q] =
sqf((
float)(q-v[k])) +
f[v[k]];
102 #pragma omp parallel for simd default(none) \
103 dt_omp_firstprivate(src, out) \
104 dt_omp_sharedconst(clip, width, height) \
105 schedule(static) aligned(src, out : 64)
112 fprintf(stderr,
"[dt_image_distance_transform] called with unsupported mode %i\n", mode);
117 float max_distance = 0.0f;
119 #pragma omp parallel \
120 reduction(max : max_distance) \
121 dt_omp_firstprivate(out) \
122 dt_omp_sharedconst(maxdim, width, height)
132 #pragma omp for schedule(simd:static)
134 for(
size_t x = 0; x <
width; x++)
136 for(
size_t y = 0; y <
height; y++)
139 for(
size_t y = 0; y <
height; y++)
140 out[y*
width + x] = d[y];
145 #pragma omp for schedule(simd:static) nowait
147 for(
size_t y = 0; y <
height; y++)
150 for(
size_t x = 0; x <
width; x++)
152 const float val = sqrtf(d[x]);
153 out[y*
width + x] = val;
154 max_distance = fmaxf(max_distance, val);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
static float * dt_alloc_align_float(size_t pixels)
Definition darktable.h:345
#define dt_free_align(A)
Definition darktable.h:334
static float f(const float t, const float c, const float x)
Definition graduatednd.c:173
void dt_iop_image_fill(float *const buf, const float fill_value, const size_t width, const size_t height, const size_t ch)
Definition imagebuf.c:210
static float sqf(const float x)
Definition math.h:215
#define dt_alloc_align(B)
Definition tests/cache.c:22
#define MAX(a, b)
Definition thinplate.c:20