"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "operations/common-cxx/distance-transform.cc" between
gegl-0.4.18.tar.xz and gegl-0.4.20.tar.xz

About: GEGL (Generic Graphics Library) is a graph based image processing framework (mainly developed for GIMP).

distance-transform.cc  (gegl-0.4.18.tar.xz):distance-transform.cc  (gegl-0.4.20.tar.xz)
skipping to change at line 191 skipping to change at line 191
} }
/* Parallelize the loop. We don't even need a mutex as we edit data per /* Parallelize the loop. We don't even need a mutex as we edit data per
* lines (i.e. each thread will work on a given range of lines without * lines (i.e. each thread will work on a given range of lines without
* needing to read data updated by other threads). * needing to read data updated by other threads).
*/ */
gegl_parallel_distribute_range ( gegl_parallel_distribute_range (
height, gegl_operation_get_pixels_per_thread (operation) / width, height, gegl_operation_get_pixels_per_thread (operation) / width,
[&] (gint y0, gint size) [&] (gint y0, gint size)
{ {
gfloat *g, *row_copy; gfloat *g, *dest_row;
gint q, w, *t, *s; gint q, w, *t, *s;
gint u, y; gint u, y;
/* sorry for the variable naming, they are taken from the paper */ /* sorry for the variable naming, they are taken from the paper */
s = (gint *) gegl_calloc (sizeof (gint), width); s = (gint *) gegl_calloc (sizeof (gint), width + 1);
t = (gint *) gegl_calloc (sizeof (gint), width); t = (gint *) gegl_calloc (sizeof (gint), width + 1);
row_copy = (gfloat *) gegl_calloc (sizeof (gfloat), width); g = (gfloat *) gegl_calloc (sizeof (gfloat), width + 2);
for (y = y0; y < y0 + size; y++) for (y = y0; y < y0 + size; y++)
{ {
dest_row = &dest[0 + y * width];
/* Use a copy of the dest row, lined with a zero on either side.
Mind the offset and difference in width when working between g
and the dest row. */
memcpy (&g[1], dest_row, width * sizeof (gfloat));
q = 0; q = 0;
s[0] = 0; s[0] = 0;
t[0] = 0; t[0] = 0;
g = dest + y * width;
dest[0 + y * width] = MIN (dest[0 + y * width], 1.0); for (u = 1; u < width + 2; u++)
dest[width - 1 + y * width] = MIN (dest[width - 1 + y * width], 1.0);
for (u = 1; u < width; u++)
{ {
while (q >= 0 && while (q >= 0 &&
dt_f (t[q], s[q], g[s[q]]) >= dt_f (t[q], u, g[u]) + EPSILO N) dt_f (t[q], s[q], g[s[q]]) >= dt_f (t[q], u, g[u]) + EPSILO N)
{ {
q --; q --;
} }
if (q < 0) if (q < 0)
{ {
q = 0; q = 0;
s[0] = u; s[0] = u;
} }
else else
{ {
/* function Sep from paper */ /* function Sep from paper */
w = dt_sep (s[q], u, g[s[q]], g[u]); w = dt_sep (s[q], u, g[s[q]], g[u]);
w += 1; w += 1;
if (w < width) if (w < width + 1)
{ {
q ++; q ++;
s[q] = u; s[q] = u;
t[q] = w; t[q] = w;
} }
} }
} }
memcpy (row_copy, g, width * sizeof (gfloat)); for (u = width; u >= 1; u--)
for (u = width - 1; u >= 0; u--)
{ {
if (u == s[q]) if (u == s[q])
g[u] = row_copy[u]; dest_row[u - 1] = g[u];
else else
g[u] = dt_f (u, s[q], row_copy[s[q]]); dest_row[u - 1] = dt_f (u, s[q], g[s[q]]);
if (q > 0 && u == t[q]) if (q > 0 && u == t[q])
{ {
q--; q--;
} }
} }
} }
gegl_free (t); gegl_free (t);
gegl_free (s); gegl_free (s);
gegl_free (row_copy); gegl_free (g);
}); });
} }
static void static void
binary_dt_1st_pass (GeglOperation *operation, binary_dt_1st_pass (GeglOperation *operation,
gint width, gint width,
gint height, gint height,
gfloat thres_lo, gfloat thres_lo,
gfloat *src, gfloat *src,
gfloat *dest) gfloat *dest)
 End of changes. 10 change blocks. 
16 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)