[gegl] alpha-inpaint: only count energy of non transparent pixels for rays



commit a04429f14b1543d9800b5f469af032f741fbaf77
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Jul 2 23:43:30 2019 +0200

    alpha-inpaint: only count energy of non transparent pixels for rays

 operations/workshop/inpaint.c      |  4 ++--
 operations/workshop/pixel-duster.h | 13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/operations/workshop/inpaint.c b/operations/workshop/inpaint.c
index 0b65af19c..a3a6b486a 100644
--- a/operations/workshop/inpaint.c
+++ b/operations/workshop/inpaint.c
@@ -41,8 +41,8 @@ property_int (max_iter, "max iter", 2000)
 
 property_int (improvement_iters, "improvement iters", 2)
 
-property_int (k, "k", 1)
-  value_range (1, 5)
+property_int (k, "k", 3)
+  value_range (1, 8)
 
 property_double (chance_try, "try chance", 0.33)
   value_range (0.0, 1.0)
diff --git a/operations/workshop/pixel-duster.h b/operations/workshop/pixel-duster.h
index bdfb7bdc6..068732620 100644
--- a/operations/workshop/pixel-duster.h
+++ b/operations/workshop/pixel-duster.h
@@ -86,7 +86,7 @@ typedef struct
 } PixelDuster;
 
 
-#define MAX_K                   4
+#define MAX_K                   8
 
 #define RINGS                   3   // increments works up to 7-8 with no adver
 #define RAYS                    12 // good values for testing 6 8 10 12 16
@@ -318,9 +318,16 @@ static void extract_site (PixelDuster *duster, GeglBuffer *buffer, double x, dou
     for (int ray = 0; ray < RAYS; ray ++)
     {
       float energy = 0.0;
+      int count = 0;
       for (int circle = 0; circle < RINGS; circle++)
-        for (int c = 0; c < 3; c++)
-          energy += dst[ ( circle * RAYS  + ray )*4 + c];
+        if (dst[ ( circle * RAYS  + ray )*4 + 3] > 0.01)
+        {
+          for (int c = 0; c < 3; c++)
+            energy += dst[ ( circle * RAYS  + ray )*4 + c];
+          count ++;
+        }
+      if (count)
+        energy/=count;
       if (energy > warmest_ray_energy)
       {
         warmest_ray = ray;


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