[gegl] alpha-inpaint: parametrize number of scale needles
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] alpha-inpaint: parametrize number of scale needles
- Date: Sun, 14 Jul 2019 19:38:30 +0000 (UTC)
commit 81210225224a965e5ecf1ea855b57cebb634f829
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Jul 10 03:33:33 2019 +0200
alpha-inpaint: parametrize number of scale needles
Also coefficient optimizations.
operations/workshop/alpha-inpaint.c | 119 ++++++++++++++++++++++--------------
1 file changed, 72 insertions(+), 47 deletions(-)
---
diff --git a/operations/workshop/alpha-inpaint.c b/operations/workshop/alpha-inpaint.c
index 7cbfdbb42..24dc954e3 100644
--- a/operations/workshop/alpha-inpaint.c
+++ b/operations/workshop/alpha-inpaint.c
@@ -25,7 +25,7 @@
#ifdef GEGL_PROPERTIES
-property_int (seek_distance, "seek radius", 16)
+property_int (seek_distance, "seek radius", 10)
description ("Maximum distance in neighborhood we look for better candidates per improvement.")
value_range (1, 512)
@@ -37,11 +37,11 @@ property_int (min_iter, "min rounds", 20)
description ("Ensuring that we get results even with low retry chance")
value_range (1, 512)
-property_int (min_neighbors, "min neighbors", 3)
+property_int (min_neighbors, "min neighbors", 1)
description ("minimum neighbors that must be set before we consider setting")
value_range (0, 4)
-property_int (max_iter, "max rounds", 600)
+property_int (max_iter, "max rounds", 800)
description ("Mostly a saftey valve, so that we terminate")
value_range (1, 40000)
@@ -49,35 +49,64 @@ property_int (iterations, "iterations per round per probe", 16)
description ("number of improvement iterations, after initial search - that each probe gets.")
value_range (1, 1000)
-property_int (rounds, "rounds", 64)
+
+property_double (ring_gap1, "ring gap1", 1.1)
+ description ("radius, in pixels of nearest to pixel circle of neighborhood metric")
+ value_range (0.0, 16.0)
+ ui_steps (0.25, 0.25)
+
+property_double (ring_gap2, "ring gap2", 1.75)
+ description ("radius, in pixels of second nearest to pixel circle")
+ value_range (0.0, 16.0)
+ ui_steps (0.25, 0.25)
+
+property_double (ring_gap3, "ring gap3", 2.9)
+ description ("radius, in pixels of third pixel circle")
+ value_range (0.0, 16.0)
+ ui_steps (0.25, 0.25)
+
+property_double (ring_gap4, "ring gap4", 4.0)
+ description ("radius, in pixels of fourth pixel circle (not always in use)")
+ value_range (0.0, 16.0)
+ ui_steps (0.25, 0.25)
+
+property_int (scale_needles, "scale needles", 5)
+ value_range (1, 7)
+
+property_int (rounds, "rounds", 8)
description ("number of improvement iterations, after initial search - that each probe gets.")
value_range (0, 1000)
-property_double (chance_try, "try probability", 0.25)
+property_double (chance_try, "try probability", 0.07)
description ("The chance that a candidate pixel probe will start being filled in")
value_range (0.0, 1.0)
ui_steps (0.01, 0.1)
-property_double (chance_retry, "retry probability", 0.5)
+property_double (chance_retry, "retry probability", 0.9)
description ("The chance that a pixel probe gets an improvement in an iteration")
value_range (0.0, 1.0)
ui_steps (0.01, 0.1)
-property_double (metric_dist_powk, "metric dist powk", 1.5)
+property_double (chance_neighbor, "chance neighbor", 1.0)
+ description ("The chance of trying to find neighbor improvements")
+ value_range (0.0, 1.0)
+ ui_steps (0.01, 0.1)
+
+property_double (metric_dist_powk, "dist powk", 2.8)
description ("influences the (lack of) importance of further away pixels")
value_range (0.0, 10.0)
ui_steps (0.1, 1.0)
-property_double (metric_empty_hay_score, "metric empty hay score", 0.42)
+property_double (metric_empty_hay_score, "empty hay score", 0.38)
description ("score given to pixels that are empty, in the search neighborhood of pixel, this being at
default or higher value sometimes discourages some of the good very nearby matches")
value_range (0.001, 100.0)
ui_steps (0.05, 0.1)
-property_double (metric_empty_needle_score, "metric empty needle score", 0.2)
+property_double (metric_empty_needle_score, "empty needle score", 0.18)
description ("the score given in the metric to an empty spot")
value_range (0.001, 100.0)
ui_steps (0.05, 0.1)
-property_double (metric_cohesion, "metric cohesion", 0.10)
+property_double (metric_cohesion, "metric cohesion", 0.5)
description ("influences the importance of probe spatial proximity")
value_range (0.0, 100.0)
ui_steps (0.2, 0.2)
@@ -87,30 +116,11 @@ property_double (ring_twist, "ring twist", 0.0)
value_range (0.0, 1.0)
ui_steps (0.01, 0.2)
-property_double (ring_gap1, "ring gap1", 1.1)
- description ("radius, in pixels of nearest to pixel circle of neighborhood metric")
- value_range (0.0, 16.0)
- ui_steps (0.25, 0.25)
-
-property_double (ring_gap2, "ring gap2", 1.75)
- description ("radius, in pixels of second nearest to pixel circle")
- value_range (0.0, 16.0)
- ui_steps (0.25, 0.25)
-
-property_double (ring_gap3, "ring gap3", 2.9)
- description ("radius, in pixels of third pixel circle")
- value_range (0.0, 16.0)
- ui_steps (0.25, 0.25)
-
-property_double (ring_gap4, "ring gap4", 4.6)
- description ("radius, in pixels of fourth pixel circle (not always in use)")
- value_range (0.0, 16.0)
- ui_steps (0.25, 0.25)
property_boolean (direction_invariant, "direction invariant", TRUE)
description ("wheter we normalize feature vector to start with highest energy ray")
-property_int (muses, "neighbors to get inspired by", 4)
+property_int (source_neighbors, "source neighbors", 4)
description ("pick neighbor of neighbors as starting point if good, 4connected 8conntected or 12/16 with
longer teleport")
value_range (0, 16)
@@ -131,7 +141,7 @@ property_int (muses, "neighbors to get inspired by", 4)
*/
#define RINGS 3 // increments works up to 7-8 with no adver
-#define RAYS 12 // good values for testing 6 8 10 12 16
+#define RAYS 12 // good values for testing 6 8 10 12 16
#define NEIGHBORHOOD (RINGS*RAYS+1)
/* The pattern of the sampling neighborhood is RAYS of samples radiating out
@@ -141,7 +151,7 @@ property_int (muses, "neighbors to get inspired by", 4)
* is how we achieve orientation invariance.
*/
-#define N_SCALE_NEEDLES 5
+#define N_SCALE_NEEDLES 7
/* Before comparing with a candidate extracted hay-feature, we prepare
* ourselves with N_SCALE_NEEDLES independent scaled versions of the
@@ -650,18 +660,18 @@ probe_prep (PixelDuster *duster,
gint dst_x = probe->target_x;
gint dst_y = probe->target_y;
extract_site (duster, duster->output, dst_x, dst_y, 1.0, &needles[0][0]);
- if (N_SCALE_NEEDLES > 1)
- extract_site (duster, duster->output, dst_x, dst_y, 0.8333, &needles[1][0]);
- if (N_SCALE_NEEDLES > 2)
- extract_site (duster, duster->output, dst_x, dst_y, 1.2, &needles[2][0]);
- if (N_SCALE_NEEDLES > 3)
- extract_site (duster, duster->output, dst_x, dst_y, 0.7, &needles[3][0]);
- if (N_SCALE_NEEDLES > 4)
- extract_site (duster, duster->output, dst_x, dst_y, 1.4, &needles[4][0]);
- if (N_SCALE_NEEDLES > 5)
- extract_site (duster, duster->output, dst_x, dst_y, 0.66667,&needles[5][0]);
- if (N_SCALE_NEEDLES > 6)
- extract_site (duster, duster->output, dst_x, dst_y, 1.5, &needles[6][0]);
+ if (duster->o->scale_needles > 1)
+ extract_site (duster, duster->output, dst_x, dst_y, 1.2, &needles[1][0]);
+ if (duster->o->scale_needles > 2)
+ extract_site (duster, duster->output, dst_x, dst_y, 0.8333, &needles[2][0]);
+ if (duster->o->scale_needles > 3)
+ extract_site (duster, duster->output, dst_x, dst_y, 1.4, &needles[3][0]);
+ if (duster->o->scale_needles > 4)
+ extract_site (duster, duster->output, dst_x, dst_y, 0.7, &needles[4][0]);
+ if (duster->o->scale_needles > 5)
+ extract_site (duster, duster->output, dst_x, dst_y, 1.5, &needles[5][0]);
+ if (duster->o->scale_needles > 6)
+ extract_site (duster, duster->output, dst_x, dst_y, 0.66667,&needles[6][0]);
/* find neighbors */
{
@@ -675,7 +685,9 @@ probe_prep (PixelDuster *duster,
}
}
- for (int i = 0; i < duster->o->muses; i++)
+ //if (((rand()%100)/100.0) < duster->o->chance_neighbor)
+ for (int j = 0; j < 3; j++)
+ for (int i = 0; i < duster->o->source_neighbors; i++)
{
if (neighbors[i])
{
@@ -686,7 +698,7 @@ probe_prep (PixelDuster *duster,
float test_y = oprobe->source_y + coords[c][1];
float *hay = ensure_hay (duster, test_x, test_y);
float score = probe_score (duster, probe, neighbors, needles, test_x, test_y, hay, probe->score);
- if (score < probe->score)
+ if (score <= probe->score)
{
probe->source_x = test_x;
probe->source_y = test_y;
@@ -716,7 +728,7 @@ probe_score (PixelDuster *duster,
return INITIAL_SCORE;
}
- for (int n = 0; n < N_SCALE_NEEDLES; n++)
+ for (int n = 0; n < duster->o->scale_needles; n++)
{
float score = score_site (duster, probe, neighbors, x, y, &needles[n][0], hay, bail);
if (score < best_score)
@@ -829,6 +841,17 @@ pixel_duster_trim (PixelDuster *duster)
}
+static int random_compare (gconstpointer a,
+ gconstpointer b)
+{
+ return g_random_int_range (-1, 1);
+}
+
+static GList *list_randomize (GList *input)
+{
+ return g_list_sort (input, random_compare);
+}
+
static inline void pixel_duster_fill (PixelDuster *duster)
{
GeglProperties *o = duster->o;
@@ -854,6 +877,8 @@ static inline void pixel_duster_fill (PixelDuster *duster)
values = g_hash_table_get_values (duster->probes_ht);
+ values = list_randomize (values);
+
for (GList *p= values; p; p= p->next)
{
Probe *probe = p->data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]