[gegl] median-blur: change bin distribution; perform in perceptual
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] median-blur: change bin distribution; perform in perceptual
- Date: Thu, 14 Sep 2017 13:40:19 +0000 (UTC)
commit acf896712606de88504d8ea553ac532ba4c689f0
Author: Ell <ell_se yahoo com>
Date: Thu Sep 14 09:12:51 2017 -0400
median-blur: change bin distribution; perform in perceptual
Change the histogram bin distribution such that, for an n-bin
histogram, the bins are centered around multiples of 1 / (n - 1).
This means that the width of the lowest and highest bins is half of
that of the rest of the bins, but also that they result in 0 and 1,
respectively, exactly.
Change the working space of the op from RGB(A) to R'G'B'(A). Note
that, ideally, since the median depends only on the relative order
of the values, this is insignificant. However, since we quantize
the value range into bins, this affects the distribution of the
bins, and, in particular, creates visible banding when done in RGB,
given the current bin count (even when the op in a nop, i.e., when
radius == 0).
operations/workshop/median-blur.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/operations/workshop/median-blur.c b/operations/workshop/median-blur.c
index 30eb12b..a756295 100644
--- a/operations/workshop/median-blur.c
+++ b/operations/workshop/median-blur.c
@@ -111,7 +111,7 @@ histogram_get_median (Histogram *hist,
comp->last_median = i;
comp->last_median_sum = sum;
- return ((gfloat) i + .5f) / (gfloat) N_BINS;
+ return (gfloat) i / (gfloat) (N_BINS - 1);
}
static inline void
@@ -398,8 +398,8 @@ convert_values_to_bins (gint32 *src,
gfloat value = ((gfloat *) src)[c];
gint bin;
- bin = (gint) (CLAMP (value, 0.0f, 1.0f) * N_BINS);
- bin = MIN (bin, N_BINS - 1);
+ bin = (gint) (value * (N_BINS - 1) + 0.5f);
+ bin = CLAMP (bin, 0, N_BINS - 1);
src[c] = bin;
}
@@ -414,7 +414,7 @@ prepare (GeglOperation *operation)
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglProperties *o = GEGL_PROPERTIES (operation);
const Babl *in_format = gegl_operation_get_source_format (operation, "input");
- const Babl *format = babl_format ("RGB float");
+ const Babl *format = babl_format ("R'G'B' float");
area->left =
area->right =
@@ -427,7 +427,7 @@ prepare (GeglOperation *operation)
if (in_format)
{
if (babl_format_has_alpha (in_format))
- format = babl_format ("RGBA float");
+ format = babl_format ("R'G'B'A float");
}
gegl_operation_set_format (operation, "input", format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]