[gegl] workshop: add saturation-yuv for experimenting with saturation



commit 913400ee84720878715b8633950fb67ec5d54609
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jun 30 10:20:04 2019 +0200

    workshop: add saturation-yuv for experimenting with saturation
    
    A test for issue #171 using CIE Yuv alpha float for saturation, though this
    space has the same hue shifts as CIE Lab.

 operations/workshop/Makefile.am      |  1 +
 operations/workshop/saturation-yuv.c | 96 ++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)
---
diff --git a/operations/workshop/Makefile.am b/operations/workshop/Makefile.am
index 60ee21296..ec0f7b341 100644
--- a/operations/workshop/Makefile.am
+++ b/operations/workshop/Makefile.am
@@ -26,6 +26,7 @@ ops = \
        rawbayer-load.la  \
        segment-kmeans.la \
        saturation-hue-constant.la \
+       saturation-yuv.la \
        selective-hue-saturation.la
 
 if HAVE_CXX14
diff --git a/operations/workshop/saturation-yuv.c b/operations/workshop/saturation-yuv.c
new file mode 100644
index 000000000..58fade752
--- /dev/null
+++ b/operations/workshop/saturation-yuv.c
@@ -0,0 +1,96 @@
+/* This file is an image processing operation for GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
+ *
+ * Copyright 2019 Øyvind Kolås
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#ifdef GEGL_PROPERTIES
+
+property_double (scale, "Scale", 1.0)
+    description("Scale, strength of effect")
+    value_range (0.0, 10.0)
+    ui_range (0.0, 2.0)
+
+#else
+
+#define GEGL_OP_POINT_FILTER
+#define GEGL_OP_NAME     saturation_hue_constant2
+#define GEGL_OP_C_SOURCE saturation-foo.c
+
+#include "gegl-op.h"
+
+static void prepare (GeglOperation *operation)
+{
+  const Babl *space = gegl_operation_get_source_space (operation, "input");
+  const Babl *format;
+
+  format = babl_format_with_space ("CIE Yuv alpha float", space);
+
+  gegl_operation_set_format (operation, "input", format);
+  gegl_operation_set_format (operation, "output", format);
+}
+
+static gboolean
+process (GeglOperation       *operation,
+         void                *in_buf,
+         void                *out_buf,
+         glong                n_pixels,
+         const GeglRectangle *roi,
+         gint                 level)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+  gfloat *in = in_buf;
+  gfloat *out = out_buf;
+  glong i;
+  float scale = o->scale;
+
+  for (i = 0; i < n_pixels; i++)
+    {
+      out[0] = in[0];
+      out[1] = in[1] * scale;
+      out[2] = in[2] * scale;
+      out[3] = in[3] * scale;
+
+      in += 4;
+      out += 4;
+    }
+
+  return TRUE;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+  GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+  GeglOperationPointFilterClass *point_filter_class =
+    GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+  operation_class->prepare = prepare;
+  operation_class->opencl_support = FALSE;
+
+  point_filter_class->process = process;
+
+  gegl_operation_class_set_keys (operation_class,
+    "name"       , "gegl:saturation-foo",
+    "title",       "Saturation with attempt at constant hue",
+    "categories" , "color",
+    "description", "Changes the saturation",
+    NULL);
+}
+
+#endif


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