[gegl] alpha-inpaint: re-enable early bail
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] alpha-inpaint: re-enable early bail
- Date: Thu, 4 Jul 2019 17:58:21 +0000 (UTC)
commit 44e8ae746988b4afc26054eb8f4d1843aab95664
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Jul 4 15:46:58 2019 +0200
alpha-inpaint: re-enable early bail
operations/workshop/alpha-inpaint.c | 72 +++++++++++++++++--------------------
1 file changed, 32 insertions(+), 40 deletions(-)
---
diff --git a/operations/workshop/alpha-inpaint.c b/operations/workshop/alpha-inpaint.c
index efabd1248..934bd9840 100644
--- a/operations/workshop/alpha-inpaint.c
+++ b/operations/workshop/alpha-inpaint.c
@@ -35,6 +35,7 @@ property_int (max_iter, "max iter", 200)
value_range (1, 40000)
property_int (improvement_iters, "improvement iters", 4)
+ value_range (1, 40)
property_double (chance_try, "try chance", 0.33)
value_range (0.0, 1.0)
@@ -82,6 +83,17 @@ property_double (ring_gap4, "ring gap4", 5.5)
#else
+/* configuration, more rings and more rays mean higher memory consumption
+ for hay and lower performance
+ */
+#define RINGS 4 // increments works up to 7-8 with no adver
+#define RAYS 6 // good values for testing 6 8 10 12 16
+#define NEIGHBORHOOD (RINGS*RAYS+1)
+#define N_SCALE_NEEDLES 3
+#define DIRECTION_INVARIANT // comment out to make search be direction dependent
+
+
+
#define GEGL_OP_FILTER
#define GEGL_OP_NAME alpha_inpaint
#define GEGL_OP_C_SOURCE alpha-inpaint.c
@@ -136,13 +148,6 @@ typedef struct
} PixelDuster;
-#define RINGS 4 // increments works up to 7-8 with no adver
-#define RAYS 6 // good values for testing 6 8 10 12 16
-#define NEIGHBORHOOD (RINGS*RAYS+1)
-
-#define N_SCALE_NEEDLES 3
-
-#define DIRECTION_INVARIANT // uncomment to make search be direction dependent
typedef struct _Probe Probe;
@@ -376,12 +381,6 @@ static void extract_site (PixelDuster *duster, GeglBuffer *buffer, double x, dou
#endif
}
-static inline int u8_rgb_diff (guchar *a, guchar *b)
-{
- return POW2(a[0]-b[0]) * 2 + POW2(a[1]-b[1]) * 3 + POW2(a[2]-b[2]);
-}
-
-
static inline float f_rgb_diff (float *a, float *b)
{
return POW2(a[0]-b[0]) + POW2(a[1]-b[1]) + POW2(a[2]-b[2]);
@@ -406,29 +405,6 @@ score_site (PixelDuster *duster,
return INITIAL_SCORE;
}
- for (i = 1; i < NEIGHBORHOOD /* && score < bail */; i++)
- {
- if (needle[i*4 + 3]>0.001f)
- {
- if (hay[i*4 + 3]>0.001f)
- {
- score += f_rgb_diff (&needle[i*4 + 0], &hay[i*4 + 0]) * duster->order[i][2];
- }
- else
- {
- score += duster->metric_empty_hay_score * duster->order[i][2];
- }
- }
- else
- {
- score += duster->metric_empty_needle_score * duster->order[i][2];
- }
-
- {
- /* both empty in needle and empty in hay get a similar badness score */
- }
- }
-
{
float sum_x = probe->source_x;
float sum_y = probe->source_y;
@@ -445,9 +421,27 @@ score_site (PixelDuster *duster,
score += (POW2(sum_x - probe->source_x) +
POW2(sum_y - probe->source_y)) * duster->metric_cohesion;
+ }
+ for (i = 1; i < NEIGHBORHOOD && score < bail; i++)
+ {
+ if (needle[i*4 + 3]>0.001f)
+ {
+ if (hay[i*4 + 3]>0.001f)
+ {
+ score += f_rgb_diff (&needle[i*4 + 0], &hay[i*4 + 0]) * duster->order[i][2];
+ }
+ else
+ {
+ score += duster->metric_empty_hay_score * duster->order[i][2];
+ }
+ }
+ else
+ {
+ score += duster->metric_empty_needle_score * duster->order[i][2];
+ }
}
- score = sqrtf (score);
+
return score;
}
@@ -566,7 +560,7 @@ probe_prep (PixelDuster *duster,
}
- if(1)for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
if (neighbors[i])
{
@@ -591,7 +585,6 @@ probe_prep (PixelDuster *duster,
probe->source_x = test_x;
probe->source_y = test_y;
probe->score = score;
- //probe_update_target (duster, probe);
}
}
}
@@ -599,7 +592,6 @@ probe_prep (PixelDuster *duster,
}
-
static float
probe_score (PixelDuster *duster,
Probe *probe,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]