[gegl] buffer: more improvements to sampler box-filter criterion
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: more improvements to sampler box-filter criterion
- Date: Thu, 15 Nov 2018 22:07:15 +0000 (UTC)
commit 662b9c35f5e052f94268ea0aea59923ed23b10bb
Author: Ell <ell_se yahoo com>
Date: Thu Nov 15 17:01:33 2018 -0500
buffer: more improvements to sampler box-filter criterion
Don't perform box filtering in the linear/cubic samplers if any of
the transformed basis vectors are scaled down, that is, if the
image is upscaled in either direction, since the box filter would
effectively be performing nearest-neighbor sampling in this
direction -- it's better to let the non box-filtered sampler do its
thing.
gegl/buffer/gegl-sampler.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 54d2724fc..40091eae8 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -237,7 +237,8 @@ _gegl_sampler_box_get (GeglSampler* restrict self,
const gdouble v_norm2 = scale->coeff[0][1] * scale->coeff[0][1] +
scale->coeff[1][1] * scale->coeff[1][1];
- if (u_norm2 >= 4.0 || v_norm2 >= 4.0)
+ if ((u_norm2 >= 4.0 && v_norm2 >= 1.0) ||
+ (v_norm2 >= 4.0 && u_norm2 >= 1.0))
{
gfloat result[channels];
gdouble uv_samples_inv;
@@ -260,8 +261,8 @@ _gegl_sampler_box_get (GeglSampler* restrict self,
const gdouble v_norm = fabs (scale->coeff[1][1]);
const gint u_norm_i = ceil (u_norm);
const gint v_norm_i = ceil (v_norm);
- const gint u_samples = CLAMP (u_norm_i, 1, n_samples);
- const gint v_samples = CLAMP (v_norm_i, 1, n_samples);
+ const gint u_samples = MIN (u_norm_i, n_samples);
+ const gint v_samples = MIN (v_norm_i, n_samples);
const gdouble u_samples_inv = 1.0 / u_samples;
const gdouble v_samples_inv = 1.0 / v_samples;
const gdouble u_dx = scale->coeff[0][0] * u_samples_inv;
@@ -301,8 +302,8 @@ _gegl_sampler_box_get (GeglSampler* restrict self,
const gdouble v_norm = sqrt (v_norm2);
const gint u_norm_i = ceil (u_norm);
const gint v_norm_i = ceil (v_norm);
- const gint u_samples = CLAMP (u_norm_i, 1, n_samples);
- const gint v_samples = CLAMP (v_norm_i, 1, n_samples);
+ const gint u_samples = MIN (u_norm_i, n_samples);
+ const gint v_samples = MIN (v_norm_i, n_samples);
const gdouble u_samples_inv = 1.0 / u_samples;
const gdouble v_samples_inv = 1.0 / v_samples;
const gdouble u_dx = scale->coeff[0][0] * u_samples_inv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]