Commit 910d7934 authored by Jehan's avatar Jehan

app: fix stroke labels in gimp_lineart_estimate_stroke_width().

I must make sure that stroke pixels are labelled 0 and non-stroke other
than 0.
parent 1822ea39
......@@ -1715,26 +1715,6 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
labels = gimp_lineart_get_labels (mask, TRUE);
gi = gegl_buffer_iterator_new (mask, NULL, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 2);
gegl_buffer_iterator_add (gi, labels, NULL, 0,
babl_format_n (babl_type ("u32"), 1),
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (gi))
{
guint8 *m = (guint8*) gi->items[0].data;
guint32 *l = (guint32*) gi->items[1].data;
gint k;
for (k = 0; k < gi->length; k++)
{
if (! *m)
*l = 0;
m++;
l++;
}
}
/* Check biggest label. */
gi = gegl_buffer_iterator_new (labels, NULL, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
......@@ -1749,7 +1729,6 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
data++;
}
}
if (label_max == 0)
{
g_object_unref (labels);
......@@ -1757,6 +1736,30 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
return 0.0;
}
/* Make sure that stroke pixels are label 0. */
label_max++;
gi = gegl_buffer_iterator_new (mask, NULL, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 2);
gegl_buffer_iterator_add (gi, labels, NULL, 0,
babl_format_n (babl_type ("u32"), 1),
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (gi))
{
guint8 *m = (guint8*) gi->items[0].data;
guint32 *l = (guint32*) gi->items[1].data;
gint k;
for (k = 0; k < gi->length; k++)
{
if (! *m)
*l = 0;
else if (*l == 0)
*l = label_max;
m++;
l++;
}
}
/* Create an array of max distance per label */
dmax = g_array_sized_new (FALSE, TRUE, sizeof (gfloat), label_max);
g_array_set_size (dmax, label_max);
......@@ -1778,7 +1781,8 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
for (k = 0; k < gi->length; k++)
{
gimp_assert (*m == 0 || *l > 0);
gimp_assert (*m == 0 || *l);
if (*m && *d > dmax_data[*l - 1])
dmax_data[*l - 1] = *d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment