[gegl] spherize: reduce sphere radius to avoid out-of-bounds sampling
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] spherize: reduce sphere radius to avoid out-of-bounds sampling
- Date: Wed, 11 Oct 2017 16:16:23 +0000 (UTC)
commit 3f5dafe1e6b7fc5f4ff45baa58ebdcd004f38cb6
Author: Ell <ell_se yahoo com>
Date: Wed Oct 11 12:03:42 2017 -0400
spherize: reduce sphere radius to avoid out-of-bounds sampling
Use (width-1)/2 and (height-1)/2 as the radii, rather than width/2
and height/2, to avoid sampling beyond the center of the outermost
pixels of the input buffer, so that the abyss color doesn't leak
in.
operations/workshop/spherize.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/operations/workshop/spherize.c b/operations/workshop/spherize.c
index 05e1cd8..342addb 100644
--- a/operations/workshop/spherize.c
+++ b/operations/workshop/spherize.c
@@ -73,8 +73,26 @@ static gboolean
is_nop (GeglOperation *operation)
{
GeglProperties *o = GEGL_PROPERTIES (operation);
+ GeglRectangle *in_rect;
- return fabs (o->curvature) < EPSILON || fabs (o->amount) < EPSILON;
+ if (fabs (o->curvature) < EPSILON || fabs (o->amount) < EPSILON)
+ return TRUE;
+
+ in_rect = gegl_operation_source_get_bounding_box (operation, "input");
+
+ switch (o->mode)
+ {
+ case GEGL_SPHERIZE_MODE_RADIAL:
+ return in_rect->width < 1 || in_rect->height < 1;
+
+ case GEGL_SPHERIZE_MODE_HORIZONTAL:
+ return in_rect->width < 1;
+
+ case GEGL_SPHERIZE_MODE_VERTICAL:
+ return in_rect->height < 1;
+ }
+
+ g_return_val_if_reached (TRUE);
}
static void
@@ -187,12 +205,12 @@ process (GeglOperation *operation,
if (o->mode == GEGL_SPHERIZE_MODE_RADIAL ||
o->mode == GEGL_SPHERIZE_MODE_HORIZONTAL)
{
- dx = 2.0 / in_extent->width;
+ dx = 2.0 / (in_extent->width - 1);
}
if (o->mode == GEGL_SPHERIZE_MODE_RADIAL ||
o->mode == GEGL_SPHERIZE_MODE_VERTICAL)
{
- dy = 2.0 / in_extent->height;
+ dy = 2.0 / (in_extent->height - 1);
}
coangle_of_view_2 = MAX (180.0 - o->angle_of_view, 0.01) * G_PI / 360.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]