Commit 4fe5dc5d authored by Jehan's avatar Jehan

app: radius map actually not useful during smart colorization grow step.

The distance map has all the information we need already. Also we will
actually grow up to the max radius pixel (middle pixel of a stroke).
After discussing with Aryeom, we realized it was better to fill a stroke
fully (for cases of overflowing, I already added the "Maximum growing
size" property anyway).

(cherry picked from commit 6bec0bc8)
parent c4988efd
......@@ -516,7 +516,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
pickable = GIMP_PICKABLE (drawable);
add_on = gimp_pickable_contiguous_region_by_seed (pickable,
NULL, NULL, NULL,
NULL, NULL,
antialias,
threshold,
select_transparent,
......
......@@ -51,7 +51,6 @@ void
gimp_drawable_bucket_fill (GimpDrawable *drawable,
GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap,
GimpFillOptions *options,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
......@@ -76,7 +75,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
image = gimp_item_get_image (GIMP_ITEM (drawable));
gimp_set_busy (image->gimp);
buffer = gimp_drawable_get_bucket_fill_buffer (drawable, line_art,
distmap, thickmap, options,
distmap, options,
fill_transparent, fill_criterion,
threshold, sample_merged,
diagonal_neighbors,
......@@ -140,7 +139,6 @@ GeglBuffer *
gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap,
GimpFillOptions *options,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
......@@ -204,7 +202,7 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
* contiguous region.
*/
new_mask = gimp_pickable_contiguous_region_by_seed (pickable,
line_art, distmap, thickmap,
line_art, distmap,
antialias,
threshold,
fill_transparent,
......
......@@ -22,7 +22,6 @@
void gimp_drawable_bucket_fill (GimpDrawable *drawable,
GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap,
GimpFillOptions *options,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
......@@ -36,7 +35,6 @@ void gimp_drawable_bucket_fill (GimpDrawable *drawabl
GeglBuffer * gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap,
GimpFillOptions *options,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
......
......@@ -188,7 +188,6 @@ static void gimp_edgelset_next8 (const GeglBuffer *buffer,
* between end points. Unlike splines, segments
* are straight lines.
* @closed_distmap: a distance map of the closed line art pixels.
* @lineart_radii: a map of estimated radii of line art border pixels.
*
* Creates a binarized version of the strokes of @buffer, detected either
* with luminosity (light means background) or alpha values depending on
......@@ -203,9 +202,9 @@ static void gimp_edgelset_next8 (const GeglBuffer *buffer,
* Fourey, David Tschumperlé, David Revoy.
*
* Returns: a new #GeglBuffer of format "Y u8" representing the
* binarized @line_art. If @lineart_radii and @lineart_distmap
* are not #NULL, newly allocated float buffer are returned,
* which can be used for overflowing created masks later.
* binarized @line_art. If @lineart_distmap is not #NULL, a
* newly allocated float buffer is returned, which can be used
* for overflowing created masks later.
*/
GeglBuffer *
gimp_lineart_close (GeglBuffer *buffer,
......@@ -223,8 +222,7 @@ gimp_lineart_close (GeglBuffer *buffer,
gint created_regions_minimum_area,
gboolean small_segments_from_spline_sources,
gint segments_max_length,
gfloat **closed_distmap,
gfloat **lineart_radii)
gfloat **closed_distmap)
{
const Babl *gray_format;
gfloat *normals;
......@@ -327,10 +325,7 @@ gimp_lineart_close (GeglBuffer *buffer,
curvatures[i + j * width] = 0.0;
}
}
if (lineart_radii)
*lineart_radii = radii;
else
g_free (radii);
g_free (radii);
keypoints = gimp_lineart_curvature_extremums (curvatures, smoothed_curvatures,
width, height);
......
......@@ -37,8 +37,7 @@ GeglBuffer * gimp_lineart_close (GeglBuffer *buffer,
gint created_regions_minimum_area,
gboolean small_segments_from_spline_sources,
gint segments_max_length,
gfloat **lineart_distmap,
gfloat **lineart_radii);
gfloat **lineart_distmap);
#endif /* __GIMP_LINEART__ */
......@@ -49,7 +49,6 @@ typedef struct
{
gint x;
gint y;
gfloat radius;
gint level;
} BorderPixel;
......@@ -119,14 +118,12 @@ static LineArtData * line_art_data_new (GeglBuffer *buffer,
static void line_art_data_free (LineArtData *data);
static GimpPickableLineArtAsyncResult *
line_art_result_new (GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap);
gfloat *distmap);
static void line_art_result_free (GimpPickableLineArtAsyncResult
*data);
static void line_art_queue_pixel (GQueue *queue,
gint x,
gint y,
gfloat radius,
gint level);
......@@ -138,7 +135,6 @@ gimp_pickable_contiguous_region_prepare_line_art_async_func (GimpAsync *async,
{
GeglBuffer *lineart;
gfloat *distmap;
gfloat *thickmap;
gboolean has_alpha;
gboolean select_transparent = FALSE;
......@@ -222,12 +218,12 @@ gimp_pickable_contiguous_region_prepare_line_art_async_func (GimpAsync *async,
TRUE,
/*segments_max_length*/
20,
&distmap, &thickmap);
&distmap);
GIMP_TIMER_END("close line-art");
gimp_async_finish_full (async,
line_art_result_new (lineart, distmap, thickmap),
line_art_result_new (lineart, distmap),
(GDestroyNotify) line_art_result_free);
line_art_data_free (data);
......@@ -237,8 +233,7 @@ GeglBuffer *
gimp_pickable_contiguous_region_prepare_line_art (GimpPickable *pickable,
gboolean select_transparent,
gfloat stroke_threshold,
gfloat **distmap,
gfloat **thickmap)
gfloat **distmap)
{
GimpAsync *async;
LineArtData *data;
......@@ -260,9 +255,7 @@ gimp_pickable_contiguous_region_prepare_line_art (GimpPickable *pickable,
lineart = g_object_ref (result->line_art);
*distmap = result->distmap;
*thickmap = result->thickmap;
result->distmap = NULL;
result->thickmap = NULL;
g_object_unref (async);
......@@ -305,7 +298,6 @@ GeglBuffer *
gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap,
gboolean antialias,
gfloat threshold,
gboolean select_transparent,
......@@ -330,8 +322,8 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
if (select_criterion == GIMP_SELECT_CRITERION_LINE_ART)
{
g_return_val_if_fail ((line_art && distmap && thickmap) ||
(! line_art && ! distmap && ! thickmap),
g_return_val_if_fail ((line_art && distmap) ||
(! line_art && ! distmap),
NULL);
if (line_art == NULL)
{
......@@ -341,7 +333,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
*/
line_art = gimp_pickable_contiguous_region_prepare_line_art (pickable, select_transparent,
stroke_threshold,
&distmap, &thickmap);
&distmap);
free_line_art = TRUE;
}
......@@ -441,8 +433,6 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
{
if (distmap[x + y * width] == 1.0)
{
gfloat thickness = thickmap[x + y * width];
if (x > 0)
{
nx = x - 1;
......@@ -451,14 +441,14 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
ny = y;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
if (y < height - 1)
......@@ -466,7 +456,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
......@@ -479,14 +469,14 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
ny = y;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
if (y < height - 1)
......@@ -494,7 +484,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
......@@ -505,7 +495,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y - 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
......@@ -514,7 +504,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
ny = y + 1;
if (mask[nx + ny * width] != 0.0)
{
line_art_queue_pixel (queue, x, y, thickness, 1);
line_art_queue_pixel (queue, x, y, 1);
continue;
}
}
......@@ -538,22 +528,19 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
ny = c->y;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
if (c->y < height - 1)
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
}
if (c->x < width - 1)
......@@ -563,22 +550,19 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
ny = c->y;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
if (c->y < height - 1)
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
}
nx = c->x;
......@@ -586,17 +570,15 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
{
ny = c->y - 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
if (c->y < height - 1)
{
ny = c->y + 1;
if (mask[nx + ny * width] == 0.0 &&
distmap[nx + ny * width] > distmap[c->x + c->y * width] &&
distmap[nx + ny * width] < c->radius)
line_art_queue_pixel (queue, nx, ny, c->radius, c->level + 1);
distmap[nx + ny * width] > distmap[c->x + c->y * width])
line_art_queue_pixel (queue, nx, ny, c->level + 1);
}
}
g_free (c);
......@@ -612,7 +594,6 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
{
g_object_unref (src_buffer);
g_free (distmap);
g_free (thickmap);
}
}
......@@ -1183,15 +1164,13 @@ line_art_data_free (LineArtData *data)
static GimpPickableLineArtAsyncResult *
line_art_result_new (GeglBuffer *line_art,
gfloat *distmap,
gfloat *thickmap)
gfloat *distmap)
{
GimpPickableLineArtAsyncResult *data;
data = g_slice_new (GimpPickableLineArtAsyncResult);
data->line_art = line_art;
data->distmap = distmap;
data->thickmap = thickmap;
return data;
}
......@@ -1201,7 +1180,6 @@ line_art_result_free (GimpPickableLineArtAsyncResult *data)
{
g_object_unref (data->line_art);
g_clear_pointer (&data->distmap, g_free);
g_clear_pointer (&data->thickmap, g_free);
g_slice_free (GimpPickableLineArtAsyncResult, data);
}
......@@ -1210,14 +1188,12 @@ static void
line_art_queue_pixel (GQueue *queue,
gint x,
gint y,
gfloat radius,
gint level)
{
BorderPixel *p = g_new (BorderPixel, 1);
p->x = x;
p->y = y;
p->radius = radius;
p->level = level;
g_queue_push_head (queue, p);
......
......@@ -22,14 +22,12 @@ typedef struct
{
GeglBuffer *line_art;
gfloat *distmap;
gfloat *thickmap;
} GimpPickableLineArtAsyncResult;
GeglBuffer * gimp_pickable_contiguous_region_prepare_line_art (GimpPickable *pickable,
gboolean select_transparent,
gfloat stroke_threshold,
gfloat **distmap,
gfloat **thickmap);
gfloat **distmap);
GimpAsync * gimp_pickable_contiguous_region_prepare_line_art_async (GimpPickable *pickable,
gboolean select_transparent,
gfloat stroke_threshold,
......@@ -38,7 +36,6 @@ GimpAsync * gimp_pickable_contiguous_region_prepare_line_art_async (GimpPickabl
GeglBuffer * gimp_pickable_contiguous_region_by_seed (GimpPickable *pickable,
GeglBuffer *line_art,
gfloat *line_art_distmap,
gfloat *line_art_thickmap,
gboolean antialias,
gfloat threshold,
gboolean select_transparent,
......
......@@ -165,7 +165,7 @@ drawable_edit_bucket_fill_invoker (GimpProcedure *procedure,
if (gimp_fill_options_set_by_fill_type (options, context,
fill_type, error))
{
gimp_drawable_bucket_fill (drawable, NULL, NULL, NULL, options,
gimp_drawable_bucket_fill (drawable, NULL, NULL, options,
GIMP_PDB_CONTEXT (context)->sample_transparent,
GIMP_PDB_CONTEXT (context)->sample_criterion,
GIMP_PDB_CONTEXT (context)->sample_threshold,
......
......@@ -63,7 +63,6 @@ struct _GimpBucketFillToolPrivate
GimpAsync *async;
GeglBuffer *line_art;
gfloat *distmap;
gfloat *thickmap;
GWeakRef cached_image;
GWeakRef cached_drawable;
......@@ -247,7 +246,6 @@ gimp_bucket_fill_tool_finalize (GObject *object)
g_clear_object (&tool->priv->line_art);
g_clear_pointer (&tool->priv->distmap, g_free);
g_clear_pointer (&tool->priv->thickmap, g_free);
if (image)
{
......@@ -371,7 +369,6 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
GeglBuffer *fill = NULL;
GeglBuffer *line_art = NULL;
gfloat *distmap = NULL;
gfloat *thickmap = NULL;
gdouble x = coords->x;
gdouble y = coords->y;
......@@ -389,11 +386,10 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
{
line_art = g_object_ref (tool->priv->line_art);
distmap = tool->priv->distmap;
thickmap = tool->priv->thickmap;
}
fill = gimp_drawable_get_bucket_fill_buffer (drawable,
line_art, distmap, thickmap,
line_art, distmap,
fill_options,
options->fill_transparent,
options->fill_criterion,
......@@ -717,9 +713,7 @@ gimp_bucket_fill_compute_line_art_cb (GimpAsync *async,
tool->priv->line_art = g_object_ref (result->line_art);
tool->priv->distmap = result->distmap;
tool->priv->thickmap = result->thickmap;
result->distmap = NULL;
result->thickmap = NULL;
}
g_clear_object (&tool->priv->async);
......@@ -744,7 +738,6 @@ gimp_bucket_fill_compute_line_art (GimpBucketFillTool *tool)
g_clear_object (&tool->priv->line_art);
g_clear_pointer (&tool->priv->distmap, g_free);
g_clear_pointer (&tool->priv->thickmap, g_free);
if (options->fill_criterion == GIMP_SELECT_CRITERION_LINE_ART)
{
......@@ -850,7 +843,6 @@ gimp_bucket_fill_tool_image_changed (GimpContext *context,
g_clear_object (&tool->priv->line_art);
g_clear_pointer (&tool->priv->distmap, g_free);
g_clear_pointer (&tool->priv->thickmap, g_free);
if (prev_image)
{
......
......@@ -122,7 +122,7 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
pickable = GIMP_PICKABLE (image);
}
return gimp_pickable_contiguous_region_by_seed (pickable, NULL, NULL, NULL,
return gimp_pickable_contiguous_region_by_seed (pickable, NULL, NULL,
sel_options->antialias,
options->threshold / 255.0,
options->select_transparent,
......
......@@ -169,7 +169,7 @@ HELP
if (gimp_fill_options_set_by_fill_type (options, context,
fill_type, error))
{
gimp_drawable_bucket_fill (drawable, NULL, NULL, NULL, options,
gimp_drawable_bucket_fill (drawable, NULL, NULL, options,
GIMP_PDB_CONTEXT (context)->sample_transparent,
GIMP_PDB_CONTEXT (context)->sample_criterion,
GIMP_PDB_CONTEXT (context)->sample_threshold,
......
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