Blame operations/common/difference-of-gaussians.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 Ø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
Packit bc1512
#ifdef GEGL_CHANT_PROPERTIES
Packit bc1512
Packit bc1512
gegl_chant_double_ui (radius1, _("Radius 1"), 0.0, 1000.0, 1.0, 0.0, 10.0, 1.5,
Packit bc1512
                     _("Radius"))
Packit bc1512
gegl_chant_double_ui (radius2, _("Radius 2"), 0.0, 1000.0, 2.0, 0.0, 10.0, 1.5,
Packit bc1512
                     _("Radius"))
Packit bc1512
Packit bc1512
#else
Packit bc1512
Packit bc1512
#define GEGL_CHANT_TYPE_META
Packit bc1512
#define GEGL_CHANT_C_FILE       "difference-of-gaussians.c"
Packit bc1512
Packit bc1512
#include "gegl-chant.h"
Packit bc1512
Packit bc1512
typedef struct _Priv Priv;
Packit bc1512
struct _Priv
Packit bc1512
{
Packit bc1512
  GeglNode *self;
Packit bc1512
  GeglNode *input;
Packit bc1512
  GeglNode *output;
Packit bc1512
Packit bc1512
  GeglNode *multiply;
Packit bc1512
  GeglNode *subtract;
Packit bc1512
  GeglNode *blur1;
Packit bc1512
  GeglNode *blur2;
Packit bc1512
};
Packit bc1512
Packit bc1512
static void attach (GeglOperation *operation)
Packit bc1512
{
Packit bc1512
  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
Packit bc1512
  Priv       *priv = g_new0 (Priv, 1);
Packit bc1512
Packit bc1512
  o->chant_data = (void*) priv;
Packit bc1512
Packit bc1512
  if (!priv->blur1)
Packit bc1512
    {
Packit bc1512
      GeglNode      *gegl;
Packit bc1512
      gegl = operation->node;
Packit bc1512
Packit bc1512
      priv->input    = gegl_node_get_input_proxy (gegl, "input");
Packit bc1512
      priv->output   = gegl_node_get_output_proxy (gegl, "output");
Packit bc1512
Packit bc1512
      priv->subtract = gegl_node_new_child (gegl,
Packit bc1512
                                            "operation", "gegl:subtract",
Packit bc1512
                                            NULL);
Packit bc1512
Packit bc1512
      priv->blur1    = gegl_node_new_child (gegl,
Packit bc1512
                                            "operation", "gegl:gaussian-blur",
Packit bc1512
                                            NULL);
Packit bc1512
Packit bc1512
      priv->blur2    = gegl_node_new_child (gegl,
Packit bc1512
                                            "operation", "gegl:gaussian-blur",
Packit bc1512
                                            NULL);
Packit bc1512
Packit bc1512
      gegl_node_link_many (priv->input, priv->blur1, priv->subtract, priv->output, NULL);
Packit bc1512
      gegl_node_link (priv->input, priv->blur2);
Packit bc1512
Packit bc1512
      gegl_node_connect_from (priv->subtract, "aux",   priv->blur2,     "output");
Packit bc1512
Packit bc1512
      gegl_operation_meta_redirect (operation, "radius1", priv->blur1, "std-dev-x");
Packit bc1512
      gegl_operation_meta_redirect (operation, "radius1", priv->blur1, "std-dev-y");
Packit bc1512
      gegl_operation_meta_redirect (operation, "radius2", priv->blur2, "std-dev-x");
Packit bc1512
      gegl_operation_meta_redirect (operation, "radius2", priv->blur2, "std-dev-y");
Packit bc1512
    }
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:difference-of-gaussians",
Packit bc1512
    "categories" , "meta:edge",
Packit bc1512
    "description",
Packit bc1512
        _("Does an edge detection based on the difference of two gaussian blurs."),
Packit bc1512
        NULL);
Packit bc1512
}
Packit bc1512
Packit bc1512
#endif