[gegl] wellish working inplace for small spots



commit 95874c0fa8cf1ea34aa45fd7c76ce38973c16864
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Jun 27 17:46:03 2019 +0200

    wellish working inplace for small spots

 operations/workshop/enlarge.c      | 11 ++++----
 operations/workshop/inpaint.c      |  6 ++---
 operations/workshop/pixel-duster.h | 51 ++++++++++++++------------------------
 3 files changed, 28 insertions(+), 40 deletions(-)
---
diff --git a/operations/workshop/enlarge.c b/operations/workshop/enlarge.c
index 93348a847..b2526bf64 100644
--- a/operations/workshop/enlarge.c
+++ b/operations/workshop/enlarge.c
@@ -140,7 +140,6 @@ static void remove_checker (GeglBuffer  *out,
   }
 }
 
-
 static void improve (PixelDuster *duster,
                      GeglBuffer *in,
                      GeglBuffer *out,
@@ -241,9 +240,9 @@ process (GeglOperation       *operation,
                               o->seek_distance,
                               o->max_k,
                               1, // min neighbors
-                              20, // min iterations
-                              0.25, // try chance
-                              0.5, // re-try chance
+                              100, // min iterations
+                              1.0, // try chance
+                              0.8, // re-try chance
                               o->scale,
                               o->scale,
                               NULL);
@@ -254,12 +253,14 @@ process (GeglOperation       *operation,
   seed_db (duster);
   pixel_duster_add_probes_for_transparent (duster);
   pixel_duster_fill (duster);
+#if 0
   //improve (duster, input, output, o->scale);
   remove_checker (output, 1);
   pixel_duster_add_probes_for_transparent (duster);
   pixel_duster_fill (duster);
+#endif
 
-#if 1
+#if 0
   remove_checker (output, 0);
   pixel_duster_add_probes_for_transparent (duster);
   pixel_duster_fill (duster);
diff --git a/operations/workshop/inpaint.c b/operations/workshop/inpaint.c
index f9ae8fbe5..8700430f3 100644
--- a/operations/workshop/inpaint.c
+++ b/operations/workshop/inpaint.c
@@ -32,13 +32,13 @@ property_int (seek_distance, "seek radius", 30)
 property_int (min_neigh, "min neigh", 4)
   value_range (1, 10)
 
-property_int (min_iter, "min iter", 15)
+property_int (min_iter, "min iter", 100)
   value_range (1, 512)
 
-property_double (chance_try, "try chance", 0.9)
+property_double (chance_try, "try chance", 1.0)
   value_range (0.0, 1.0)
 
-property_double (chance_retry, "retry chance", 1.0)
+property_double (chance_retry, "retry chance", 0.75)
   value_range (0.0, 1.0)
 
 #else
diff --git a/operations/workshop/pixel-duster.h b/operations/workshop/pixel-duster.h
index a8ff3ffd2..d3f517a23 100644
--- a/operations/workshop/pixel-duster.h
+++ b/operations/workshop/pixel-duster.h
@@ -66,6 +66,7 @@ typedef struct
   int            seek_radius;
   int            minimum_neighbors;
   int            minimum_iterations;
+  int            max_age;
   float          try_chance;
   float          retry_chance;
   float          scale_x;
@@ -178,7 +179,7 @@ static void init_order(PixelDuster *duster)
         {
           duster->order[i][0] = y;
           duster->order[i][1] = x;
-          duster->order[i][2] = sqrt(1.0 / sqrt (POW2(x)+POW2(y)));
+          duster->order[i][2] = pow (1.0 / (POW2(x)+POW2(y)), 0.8);
         }
       }
 }
@@ -254,6 +255,7 @@ static PixelDuster * pixel_duster_new (GeglBuffer *reference,
   ret->max_y = 0;
   ret->min_x = 10000;
   ret->min_y = 10000;
+  ret->max_age = 5;
 
   if (max_k < 1) max_k = 1;
   if (max_k > MAX_K) max_k = MAX_K;
@@ -712,6 +714,7 @@ static int probe_improve (PixelDuster *duster,
                           Probe       *probe)
 {
   gfloat needle[4 * NEIGHBORHOOD + 8];
+
   gint  dst_x  = probe->target_x;
   gint  dst_y  = probe->target_y;
   void *ptr[3] = {duster, probe, &needle[0]};
@@ -722,37 +725,14 @@ static int probe_improve (PixelDuster *duster,
     format = babl_format ("RGBA float");
 
   extract_site (duster, duster->output, dst_x, dst_y, 1.0, &needle[0]);
-  //site_subset2 (&needle[0], set_start, set_end);
   g_hash_table_foreach (duster->ht[0], compare_needle, ptr);
 
-#if 0
-  if (set_end[0] == set_start[0] &&
-      set_end[1] == set_start[1] &&
-      set_end[2] == set_start[2])
-  {
-    int subset = set_start[0] + set_start[1] * 16 + set_start[2] * 16 * 16;
-    g_hash_table_foreach (duster->ht[subset], compare_needle, ptr);
-  }
-  else
-  {
-    int i[3];
-    for (i[0]=0;i[0]<3;i[0]++)
-    if (set_start[i[0]] < 0)
-      set_start[i[0]] = 0;
-    for (i[0]=0;i[0]<3;i[0]++)
-    if (set_end[i[0]] > 15)
-      set_end[i[0]] = 15;
-
-
-    for (i[0] = set_start[0]; i[0] <= set_end[0]; i[0]++)
-    for (i[1] = set_start[1]; i[1] <= set_end[1]; i[1]++)
-    for (i[2] = set_start[2]; i[2] <= set_end[2]; i[2]++)
-    {
-      int subset = i[0] + i[1] * 16 + i[2] * 16 * 16;
-      g_hash_table_foreach (duster->ht[subset], compare_needle, ptr);
-    }
-  }
-#endif
+  extract_site (duster, duster->output, dst_x, dst_y, 1.2, &needle[0]);
+  g_hash_table_foreach (duster->ht[0], compare_needle, ptr);
+
+  extract_site (duster, duster->output, dst_x, dst_y, 0.83, &needle[0]);
+  g_hash_table_foreach (duster->ht[0], compare_needle, ptr);
+
   probe->age++;
 
 #if 0
@@ -763,7 +743,7 @@ static int probe_improve (PixelDuster *duster,
   spread_relative (duster, probe,  0, 1);
 #endif
 
-  if (probe->age > 5)
+  if (probe->age > duster->max_age)
     {
       g_hash_table_remove (duster->probes_ht, xy2offset(probe->target_x, probe->target_y));
     }
@@ -922,12 +902,19 @@ static void seed_db (PixelDuster *duster)
     fprintf (stderr, "ing");
     for (gint y = duster->min_y - duster->seek_radius;
               y < duster->max_y + duster->seek_radius; y++)
+    {
       for (gint x = duster->min_x - duster->seek_radius;
                 x < duster->max_x + duster->seek_radius; x++)
       {
         ensure_hay (duster, x, y, -1);
       }
-    fprintf (stderr, "\rdb seeded\n");
+      if (y % 13 == 0)
+      {
+      fprintf (stderr, "\rdb seeding %s (%.2f%%)", y%4==0?"-":y%4==1?"/":y%4==2?"\\":"|",
+     (y - duster->min_y + duster->seek_radius) * 100.0 / (duster->seek_radius * 2 + 
duster->max_y-duster->min_y));
+      }
+    }
+    fprintf (stderr, "\rdb seeded                   \n");
   }
   else
   {


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