[gegl] displace: fix off-by-half sampling causing blurry results



commit 7d51d5b9d214cadfca5e61b7f2726d0b5870c9f0
Author: Ell <ell_se yahoo com>
Date:   Tue Jan 7 21:47:04 2020 +0200

    displace: fix off-by-half sampling causing blurry results
    
    In gegl:displace, make sure that a (0,0) displacement corresponds
    to pixel centers, rather than corners.

 operations/common-gpl3+/displace.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/operations/common-gpl3+/displace.c b/operations/common-gpl3+/displace.c
index f0758014c..053e8ae68 100644
--- a/operations/common-gpl3+/displace.c
+++ b/operations/common-gpl3+/displace.c
@@ -109,8 +109,8 @@ get_base_displacement (gdouble  amount,
 }
 
 static inline void
-get_input_cartesian_coordinates (gint     x,
-                                 gint     y,
+get_input_cartesian_coordinates (gdouble  x,
+                                 gdouble  y,
                                  gdouble  x_amount,
                                  gdouble  y_amount,
                                  gfloat  *xmap_pixel,
@@ -133,8 +133,8 @@ get_input_cartesian_coordinates (gint     x,
 }
 
 static inline void
-get_input_polar_coordinates (gint     x,
-                             gint     y,
+get_input_polar_coordinates (gdouble  x,
+                             gdouble  y,
                              gdouble  x_amount,
                              gdouble  y_amount,
                              gfloat  *xmap_pixel,
@@ -386,13 +386,15 @@ process (GeglOperation       *operation,
 
             if (o->displace_mode == GEGL_DISPLACE_MODE_POLAR)
               {
-                get_input_polar_coordinates (x, y, o->amount_x, o->amount_y,
+                get_input_polar_coordinates (x + 0.5, y + 0.5,
+                                             o->amount_x, o->amount_y,
                                              aux_pixel, aux2_pixel, cx, cy,
                                              &src_x, &src_y);
               }
             else
               {
-                get_input_cartesian_coordinates (x, y, o->amount_x, o->amount_y,
+                get_input_cartesian_coordinates (x + 0.5, y + 0.5,
+                                                 o->amount_x, o->amount_y,
                                                  aux_pixel, aux2_pixel,
                                                  &src_x, &src_y);
               }


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