[gegl] workshop: add empty score tunable to properties



commit b310ae50796d4a1386ec5fea0570ac7abe25551c
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Jun 29 17:28:33 2019 +0200

    workshop: add empty score tunable to properties

 operations/workshop/inpaint.c      | 15 ++++++++++++++-
 operations/workshop/pixel-duster.h | 22 ++++++++++++++++------
 2 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/operations/workshop/inpaint.c b/operations/workshop/inpaint.c
index 57f6ee6d6..38a1c4b25 100644
--- a/operations/workshop/inpaint.c
+++ b/operations/workshop/inpaint.c
@@ -40,17 +40,28 @@ property_int (improvement_iters, "improvement iters", 1)
 
 property_double (chance_try, "try chance", 0.75)
   value_range (0.0, 1.0)
+  ui_steps    (0.01, 0.1)
 property_double (chance_retry, "retry chance", 0.8)
   value_range (0.0, 1.0)
+  ui_steps    (0.01, 0.1)
 
-property_double (ring_gap,    "ring gap", 1.5)
+property_double (ring_gap,    "ring gap", 1.25)
   value_range (0.0, 4.0)
+  ui_steps    (0.1, 0.2)
 property_double (ring_gamma, "ring gamma", 1.2)
   value_range (0.0, 4.0)
+  ui_steps    (0.1, 0.2)
 property_double (ring_twist, "ring twist", 0.040)
   value_range (0.0, 1.0)
+  ui_steps    (0.01, 0.2)
 
+property_double (metric_dist_powk, "metric dist powk", 1.35)
+  value_range (0.0, 10.0)
+  ui_steps    (0.1, 1.0)
 
+property_double (metric_empty_score, "metric empty score", 0.25)
+  value_range (0.0, 100.0)
+  ui_steps    (0.25, 1.0)
 
 #else
 
@@ -106,6 +117,8 @@ process (GeglOperation       *operation,
                                              o->ring_gap,
                                              o->ring_gamma,
                                              o->ring_twist,
+                                             o->metric_dist_powk,
+                                             o->metric_empty_score,
                                              operation);
   gegl_buffer_copy (input, NULL, GEGL_ABYSS_NONE, output, NULL);
   pixel_duster_add_probes_for_transparent (duster);
diff --git a/operations/workshop/pixel-duster.h b/operations/workshop/pixel-duster.h
index b1bc6f830..0e5e84c86 100644
--- a/operations/workshop/pixel-duster.h
+++ b/operations/workshop/pixel-duster.h
@@ -64,6 +64,9 @@ typedef struct
   float          ring_gamma;
   float          ring_twist;
 
+  float          metric_dist_powk;
+  float          metric_empty_score;
+
   GHashTable    *ht[1];
 
   GHashTable    *probes_ht;
@@ -134,7 +137,7 @@ static void init_order(PixelDuster *duster)
     float y = sinf ((angleno / RAYS + duster->ring_twist*circleno) * M_PI * 2) * mag;
     duster->order[i][0] = x;
     duster->order[i][1] = y;
-    duster->order[i][2] = powf (1.0 / (POW2(x)+POW2(y)), 1.0);
+    duster->order[i][2] = powf (1.0 / (POW2(x)+POW2(y)), duster->metric_dist_powk);
     i++;
   }
 }
@@ -164,6 +167,8 @@ static PixelDuster * pixel_duster_new (GeglBuffer *reference,
                                        float       ring_gap,
                                        float       ring_gamma,
                                        float       ring_twist,
+                                       float       metric_dist_powk,
+                                       float       metric_empty_score,
                                        GeglOperation *op)
 {
   PixelDuster *ret = g_malloc0 (sizeof (PixelDuster));
@@ -192,6 +197,8 @@ static PixelDuster * pixel_duster_new (GeglBuffer *reference,
   ret->out_rect = *out_rect;
   ret->scale_x  = scale_x;
   ret->scale_y  = scale_y;
+  ret->metric_dist_powk = metric_dist_powk;
+  ret->metric_empty_score = metric_empty_score;
 
   ret->in_sampler_f = gegl_buffer_sampler_new (input,
                                                babl_format ("RGBA float"),
@@ -346,8 +353,7 @@ score_site (PixelDuster *duster,
     }
     else
     {
-      /* transparent hay or needle - give bad score */
-      score += 5;
+      score += duster->metric_empty_score * duster->order[i][2];
     }
   }
   return score;
@@ -564,7 +570,6 @@ static int probe_improve (PixelDuster *duster,
   if (!format)
     format = babl_format ("RGBA float");
 
-
   extract_site (duster, duster->output, dst_x, dst_y, 1.0, &probe->needles[0][0]);
   if (N_SCALE_NEEDLES > 1)
     extract_site (duster, duster->output, dst_x, dst_y, 0.9, &probe->needles[1][0]);
@@ -592,6 +597,7 @@ static int probe_improve (PixelDuster *duster,
   return 0;
 }
 
+#if 0
 static inline int probes_improve (PixelDuster *duster)
 {
   int ret = -1;
@@ -605,7 +611,7 @@ static inline int probes_improve (PixelDuster *duster)
   }
   return ret;
 }
-
+#endif
 
 static inline void pixel_duster_add_probes_for_transparent (PixelDuster *duster)
 {
@@ -672,9 +678,13 @@ static inline void pixel_duster_fill (PixelDuster *duster)
       try_replace = ((rand()%100)/100.0) < duster->retry_chance;
     }
     total ++;
+
+#if 0 // can be useful for enlarge ? then needs scale factor
     if ((probe->source_x[0] == probe->target_x &&
-        probe->source_y[0] == probe->target_y))
+         probe->source_y[0] == probe->target_y))
       try_replace = 0;
+#endif
+
 
     if (probe->score == INITIAL_SCORE || try_replace)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]