[gegl] pixel-duster:



commit 82acf54c9a4a7bb772d32bd3cfcfbaf169ec2590
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Apr 11 22:17:21 2018 +0200

    pixel-duster:
    
    make max_k a parameter of pixel duster set it for enlarge, but not
    in-paint op, also use random spray neighborhood rather than ordered.

 operations/workshop/enlarge.c      |    6 +++++-
 operations/workshop/enlarge2.c     |    6 +++++-
 operations/workshop/inpaint.c      |    3 ++-
 operations/workshop/pixel-duster.h |   26 ++++++++++++++++++++------
 4 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/operations/workshop/enlarge.c b/operations/workshop/enlarge.c
index c7eb59f..8ae84c2 100644
--- a/operations/workshop/enlarge.c
+++ b/operations/workshop/enlarge.c
@@ -25,9 +25,12 @@
 
 /* most of these should go away - here for ease of algorithm experimentation */
 
-property_int (seek_distance, "seek radius", 48)
+property_int (seek_distance, "seek radius", 128)
   value_range (4, 512)
 
+property_int (max_k, "max k", 4)
+  value_range (1, 4)
+
 property_double (scale, "scale", 2.0)
   value_range (0.01, 16.0)
 
@@ -177,6 +180,7 @@ process (GeglOperation       *operation,
   duster  = pixel_duster_new (input, output,
                               &in_rect, &out_rect,
                               o->seek_distance,
+                              o->max_k,
                               1, 1, 1.0, 0.3,
                               o->scale,
                               o->scale,
diff --git a/operations/workshop/enlarge2.c b/operations/workshop/enlarge2.c
index 8bd6c1b..3d1e2e8 100644
--- a/operations/workshop/enlarge2.c
+++ b/operations/workshop/enlarge2.c
@@ -23,9 +23,12 @@
 
 #ifdef GEGL_PROPERTIES
 
-property_int (seek_distance, "seek radius", 8)
+property_int (seek_distance, "seek radius", 256)
   value_range (4, 512)
 
+property_int (max_k, "max k", 4)
+  value_range (1, 4)
+
 property_double (scale, "scale", 2.0)
   value_range (0.1, 20.0)
 
@@ -159,6 +162,7 @@ process (GeglOperation       *operation,
   duster  = pixel_duster_new (input, output,
                               &in_rect, &out_rect,
                               o->seek_distance,
+                              o->max_k,
                               o->min_neigh,
                               o->min_iter,
                               o->chance_try,
diff --git a/operations/workshop/inpaint.c b/operations/workshop/inpaint.c
index 250eb01..cabc084 100644
--- a/operations/workshop/inpaint.c
+++ b/operations/workshop/inpaint.c
@@ -23,7 +23,7 @@
 
 #ifdef GEGL_PROPERTIES
 
-property_int (seek_distance, "seek radius", 96)
+property_int (seek_distance, "seek radius", 128)
   value_range (4, 512)
 
 property_int (min_neigh, "min neigh", 2)
@@ -81,6 +81,7 @@ process (GeglOperation       *operation,
   GeglRectangle out_rect = *gegl_buffer_get_extent (output);
   PixelDuster    *duster = pixel_duster_new (input, output, &in_rect, &out_rect,
                                              o->seek_distance,
+                                             1,
                                              o->min_neigh,
                                              o->min_iter,
                                              o->chance_try,
diff --git a/operations/workshop/pixel-duster.h b/operations/workshop/pixel-duster.h
index c75670f..66b26fa 100644
--- a/operations/workshop/pixel-duster.h
+++ b/operations/workshop/pixel-duster.h
@@ -38,6 +38,7 @@ typedef struct
   GeglBuffer    *output;
   GeglRectangle  in_rect;
   GeglRectangle  out_rect;
+  int            max_k;
   int            seek_radius;
   int            minimum_neighbors;
   int            minimum_iterations;
@@ -54,10 +55,10 @@ typedef struct
 } PixelDuster;
 
 
-#define MAX_K               1
+#define MAX_K               4
 #define PIXDUST_REL_DIGEST  0
-#define NEIGHBORHOOD        33
-#define PIXDUST_ORDERED     1
+#define NEIGHBORHOOD        23
+#define PIXDUST_ORDERED     0
 #define MAX_DIR             4
 
 //#define ONLY_DIR            1
@@ -189,6 +190,7 @@ static PixelDuster * pixel_duster_new (GeglBuffer *input,
                                        const GeglRectangle *in_rect,
                                        const GeglRectangle *out_rect,
                                        int         seek_radius,
+                                       int         max_k,
                                        int         minimum_neighbors,
                                        int         minimum_iterations,
                                        float       try_chance,
@@ -206,6 +208,9 @@ static PixelDuster * pixel_duster_new (GeglBuffer *input,
   ret->try_chance   = try_chance;
   ret->retry_chance = retry_chance;
   ret->op = op;
+  if (max_k < 1) max_k = 1;
+  if (max_k > MAX_K) max_k = MAX_K;
+  ret->max_k = max_k;
   ret->in_rect  = *in_rect;
   ret->out_rect = *out_rect;
   ret->scale_x  = scale_x;
@@ -615,6 +620,15 @@ static void compare_needle (gpointer key, gpointer value, gpointer data)
   gint y = offset / 65536;
   int score;
 
+#if 0
+#define pow2(a)   ((a)*(a))
+  if ( duster->seek_radius > 1 &&
+       pow2 (probe->target_x - x * duster->scale_x) +
+       pow2 (probe->target_y - y * duster->scale_y) >
+       pow2 (duster->seek_radius))
+    return;
+#endif
+
 #if 1
   if (duster->scale_x == 1.0 && x == probe->target_x &&
 -     duster->scale_y == 1.0 && y == probe->target_y )
@@ -626,7 +640,7 @@ static void compare_needle (gpointer key, gpointer value, gpointer data)
   if (score <= probe->score)
     {
       int j;
-      for (j = MAX_K-1; j >= 1; j --)
+      for (j = duster->max_k-1; j >= 1; j --)
       {
         probe->source_x[j] = probe->source_x[j-1];
         probe->source_y[j] = probe->source_y[j-1];
@@ -634,8 +648,8 @@ static void compare_needle (gpointer key, gpointer value, gpointer data)
         probe->k_score[j] = probe->k_score[j-1];
       }
       probe->k++;
-      if (probe->k > MAX_K)
-        probe->k = MAX_K;
+      if (probe->k > duster->max_k)
+        probe->k = duster->max_k;
       probe->source_x[0] = x;
       probe->source_y[0] = y;
       probe->hay[0] = hay;


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