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.
(cherry picked from commit 910d7934f5)
This commit is contained in:
parent
b1a3792aae
commit
71ec6a9849
1 changed files with 27 additions and 23 deletions
|
|
@ -1715,6 +1715,29 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
|
|||
|
||||
labels = gimp_lineart_get_labels (mask, TRUE);
|
||||
|
||||
/* Check biggest label. */
|
||||
gi = gegl_buffer_iterator_new (labels, NULL, 0, NULL,
|
||||
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
|
||||
while (gegl_buffer_iterator_next (gi))
|
||||
{
|
||||
guint32 *data = (guint32*) gi->items[0].data;
|
||||
gint k;
|
||||
|
||||
for (k = 0; k < gi->length; k++)
|
||||
{
|
||||
label_max = MAX (*data, label_max);
|
||||
data++;
|
||||
}
|
||||
}
|
||||
if (label_max == 0)
|
||||
{
|
||||
g_object_unref (labels);
|
||||
g_object_unref (distmap);
|
||||
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,
|
||||
|
|
@ -1730,33 +1753,13 @@ gimp_lineart_estimate_stroke_width (GeglBuffer* mask)
|
|||
{
|
||||
if (! *m)
|
||||
*l = 0;
|
||||
else if (*l == 0)
|
||||
*l = label_max;
|
||||
m++;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check biggest label. */
|
||||
gi = gegl_buffer_iterator_new (labels, NULL, 0, NULL,
|
||||
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
|
||||
while (gegl_buffer_iterator_next (gi))
|
||||
{
|
||||
guint32 *data = (guint32*) gi->items[0].data;
|
||||
gint k;
|
||||
|
||||
for (k = 0; k < gi->length; k++)
|
||||
{
|
||||
label_max = MAX (*data, label_max);
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
||||
if (label_max == 0)
|
||||
{
|
||||
g_object_unref (labels);
|
||||
g_object_unref (distmap);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue