Blame operations/common/unsharp-mask.c

Packit bc1512
/* This file is an image processing operation for GEGL
Packit bc1512
 *
Packit bc1512
 * GEGL is free software; you can redistribute it and/or
Packit bc1512
 * modify it under the terms of the GNU Lesser General Public
Packit bc1512
 * License as published by the Free Software Foundation; either
Packit bc1512
 * version 3 of the License, or (at your option) any later version.
Packit bc1512
 *
Packit bc1512
 * GEGL is distributed in the hope that it will be useful,
Packit bc1512
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit bc1512
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit bc1512
 * Lesser General Public License for more details.
Packit bc1512
 *
Packit bc1512
 * You should have received a copy of the GNU Lesser General Public
Packit bc1512
 * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
Packit bc1512
 *
Packit bc1512
 * Copyright 2006, 2010 Øyvind Kolås <pippin@gimp.org>
Packit bc1512
 */
Packit bc1512
Packit bc1512
#include "config.h"
Packit bc1512
#include <glib/gi18n-lib.h>
Packit bc1512
Packit bc1512
#ifdef GEGL_CHANT_PROPERTIES
Packit bc1512
Packit bc1512
gegl_chant_double_ui (std_dev, _("Std. Dev."), 0.0, 500.0, 1.0, 0.0, 200.0, 1.5,
Packit bc1512
                  _("Standard deviation (spatial scale factor)"))
Packit bc1512
gegl_chant_double_ui (scale,  _("Scale"), 0.0, 100.0, 1.0, 0.0, 100.0, 1.5,
Packit bc1512
                  _("Scale, strength of effect"))
Packit bc1512
Packit bc1512
#else
Packit bc1512
Packit bc1512
#define GEGL_CHANT_TYPE_META
Packit bc1512
#define GEGL_CHANT_C_FILE       "unsharp-mask.c"
Packit bc1512
Packit bc1512
#include "gegl-chant.h"
Packit bc1512
Packit bc1512
static void attach (GeglOperation *operation)
Packit bc1512
{
Packit bc1512
  GeglNode *gegl, *input, *output, *add, *multiply, *subtract, *blur;
Packit bc1512
Packit bc1512
  gegl = operation->node;
Packit bc1512
Packit bc1512
  input    = gegl_node_get_input_proxy (gegl, "input");
Packit bc1512
  output   = gegl_node_get_output_proxy (gegl, "output");
Packit bc1512
  add      = gegl_node_new_child (gegl, "operation", "gegl:add", NULL);
Packit bc1512
  multiply = gegl_node_new_child (gegl, "operation", "gegl:multiply", NULL);
Packit bc1512
  subtract = gegl_node_new_child (gegl, "operation", "gegl:subtract", NULL);
Packit bc1512
  blur     = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur",NULL);
Packit bc1512
Packit bc1512
  gegl_node_link_many (input, subtract, multiply, NULL);
Packit bc1512
  gegl_node_link (input, blur);
Packit bc1512
  gegl_node_link_many (multiply, add, output, NULL);
Packit bc1512
Packit bc1512
  gegl_node_connect_from (subtract, "aux",   blur,     "output");
Packit bc1512
  gegl_node_connect_from (add,      "aux",   input, "output");
Packit bc1512
Packit bc1512
  gegl_operation_meta_redirect (operation, "scale", multiply, "value");
Packit bc1512
  gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-x");
Packit bc1512
  gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-y");
Packit bc1512
}
Packit bc1512
Packit bc1512
static void
Packit bc1512
gegl_chant_class_init (GeglChantClass *klass)
Packit bc1512
{
Packit bc1512
  GeglOperationClass *operation_class;
Packit bc1512
Packit bc1512
  operation_class = GEGL_OPERATION_CLASS (klass);
Packit bc1512
  operation_class->attach = attach;
Packit bc1512
Packit bc1512
  gegl_operation_class_set_keys (operation_class,
Packit bc1512
  "name"       , "gegl:unsharp-mask",
Packit bc1512
  "categories" , "meta:enhance",
Packit bc1512
  "description",
Packit bc1512
        _("Performs an unsharp mask on the input buffer (sharpens an image by "
Packit bc1512
          "adding false mach-bands around edges)"),
Packit bc1512
        NULL);
Packit bc1512
}
Packit bc1512
Packit bc1512
#endif