66#define DT_DISTANCE_TRANSFORM_MAX (1e20)
74 for(
int q = 1; q <=
n-1; q++)
76 float s = (
f[q] +
sqf((
float)q)) - (
f[
v[k]] +
sqf((
float)
v[k]));
77 while(s <= z[k] * (
float)(2*q - 2*
v[k]))
80 s = (
f[q] +
sqf((
float)q)) - (
f[
v[k]] +
sqf((
float)
v[k]));
82 s /= (float)(2*q - 2*
v[k]);
90 for(
int q = 0; q <=
n-1; q++)
92 while(z[k+1] < (
float)q)
94 d[q] =
sqf((
float)(q-
v[k])) +
f[
v[k]];
106 #pragma omp parallel for simd default(none) \
107 dt_omp_firstprivate(src, out) \
108 dt_omp_sharedconst(clip, width, height) \
109 schedule(static) aligned(src, out : 64)
116 fprintf(stderr,
"[dt_image_distance_transform] called with unsupported mode %i\n", mode);
121 float max_distance = 0.0f;
123 #pragma omp parallel \
124 reduction(max : max_distance) \
125 dt_omp_firstprivate(out) \
126 dt_omp_sharedconst(maxdim, width, height)
136 #pragma omp for schedule(simd:static)
140 for(
size_t y = 0; y <
height; y++)
143 for(
size_t y = 0; y <
height; y++)
149 #pragma omp for schedule(simd:static) nowait
151 for(
size_t y = 0; y <
height; y++)
156 const float val = sqrtf(
d[
x]);
158 max_distance = fmaxf(max_distance, val);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
const float i
Definition colorspaces_inline_conversions.h:669
const dt_aligned_pixel_t f
Definition colorspaces_inline_conversions.h:256
const float d
Definition colorspaces_inline_conversions.h:931
static const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:184
const float n
Definition colorspaces_inline_conversions.h:929
#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id)
Definition darktable.h:371
#define dt_pixelpipe_cache_alloc_align_cache(size, id)
Definition darktable.h:357
#define dt_pixelpipe_cache_free_align(mem)
Definition darktable.h:377
__DT_CLONE_TARGETS__ 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:216
static const float x
Definition iop_profile.h:239
static const float v
Definition iop_profile.h:223
static float sqf(const float x)
Definition math.h:223
#define MAX(a, b)
Definition thinplate.c:29