gaussian-blur-iir.c 4.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* 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 <http://www.gnu.org/licenses/>.
 *
 * Copyright 2013 Massimo Valentini <mvalentini@src.gnome.org>
 */

#include "config.h"
#include <glib/gi18n-lib.h>
#include <math.h>

22
#ifdef GEGL_PROPERTIES
23

24
enum_start (gegl_gaussian_blur_filter2)
25 26 27
   enum_value (GEGL_GAUSSIAN_BLUR_FILTER2_AUTO, "auto", N_("Auto"))
   enum_value (GEGL_GAUSSIAN_BLUR_FILTER2_FIR,  "fir",  N_("FIR"))
   enum_value (GEGL_GAUSSIAN_BLUR_FILTER2_IIR,  "iir",  N_("IIR"))
28
enum_end (GeglGaussianBlurFilter2)
29

30
enum_start (gegl_gaussian_blur_policy)
31 32 33 34
   enum_value (GEGL_GAUSSIAN_BLUR_ABYSS_NONE,  "none",   N_("None"))
   enum_value (GEGL_GAUSSIAN_BLUR_ABYSS_CLAMP, "clamp",  N_("Clamp"))
   enum_value (GEGL_GAUSSIAN_BLUR_ABYSS_BLACK, "black",  N_("Black"))
   enum_value (GEGL_GAUSSIAN_BLUR_ABYSS_WHITE, "white",  N_("White"))
35
enum_end (GeglGaussianBlurPolicy)
36

37 38
property_double (std_dev_x, _("Size X"), 1.5)
   description (_("Standard deviation for the horizontal axis"))
39
   value_range (0.0, 1500.0)
40 41 42 43
   ui_range    (0.24, 100.0)
   ui_gamma    (3.0)
   ui_meta     ("unit", "pixel-distance")
   ui_meta     ("axis", "x")
44

45
property_double (std_dev_y, _("Size Y"), 1.5)
46 47
   description (_("Standard deviation (spatial scale factor)"))
   value_range (0.0, 1500.0)
48 49 50 51
   ui_range    (0.24, 100.0)
   ui_gamma    (3.0)
   ui_meta     ("unit", "pixel-distance")
   ui_meta     ("axis", "y")
52

53 54 55
property_enum (filter, _("Filter"),
               GeglGaussianBlurFilter2, gegl_gaussian_blur_filter2,
               GEGL_GAUSSIAN_BLUR_FILTER2_AUTO)
56 57
   description (_("How the gaussian kernel is discretized"))

58
property_enum (abyss_policy, _("Abyss policy"), GeglGaussianBlurPolicy,
59
               gegl_gaussian_blur_policy, GEGL_GAUSSIAN_BLUR_ABYSS_CLAMP)
60 61
   description (_("How image edges are handled"))

62
property_boolean (clip_extent, _("Clip to the input extent"), TRUE)
63
   description (_("Should the output extent be clipped to the input extent"))
64 65 66

#else

67
#define GEGL_OP_META
68
#define GEGL_OP_NAME     gaussian_blur_iir
69
#define GEGL_OP_C_SOURCE gaussian-blur-iir.c
70

71
#include "gegl-op.h"
72 73 74 75

static void
attach (GeglOperation *operation)
{
76
  GeglNode *gegl   = operation->node;
77
  GeglNode *output = gegl_node_get_output_proxy (gegl, "output");
78 79 80 81 82 83 84 85 86 87 88 89

  GeglNode *vblur  = gegl_node_new_child (gegl,
                                          "operation", "gegl:gblur-1d",
                                          "orientation", 1,
                                          NULL);

  GeglNode *hblur  = gegl_node_new_child (gegl,
                                          "operation", "gegl:gblur-1d",
                                          "orientation", 0,
                                          NULL);

  GeglNode *input  = gegl_node_get_input_proxy (gegl, "input");
90 91

  gegl_node_link_many (input, hblur, vblur, output, NULL);
92 93

  gegl_operation_meta_redirect (operation, "std-dev-x",    hblur, "std-dev");
94
  gegl_operation_meta_redirect (operation, "abyss-policy", hblur, "abyss-policy");
95
  gegl_operation_meta_redirect (operation, "filter",       hblur, "filter");
96
  gegl_operation_meta_redirect (operation, "clip-extent",  hblur, "clip-extent");
97 98

  gegl_operation_meta_redirect (operation, "std-dev-y",    vblur, "std-dev");
99
  gegl_operation_meta_redirect (operation, "abyss-policy", vblur, "abyss-policy");
100
  gegl_operation_meta_redirect (operation, "filter",       vblur, "filter");
101
  gegl_operation_meta_redirect (operation, "clip-extent",  vblur, "clip-extent");
102 103

  gegl_operation_meta_watch_nodes (operation, hblur, vblur, NULL);
104 105 106
}

static void
107
gegl_op_class_init (GeglOpClass *klass)
108 109 110 111 112 113
{
  GeglOperationClass *operation_class;

  operation_class = GEGL_OPERATION_CLASS (klass);

  operation_class->attach = attach;
114
  operation_class->threaded = FALSE;
115 116

  gegl_operation_class_set_keys (operation_class,
117
    "name",        "gegl:gaussian-blur",
118 119 120 121 122 123 124
    "categories",  "blur",
    "description", _("Performs an averaging of neighboring pixels with the "
                     "normal distribution as weighting"),
                                 NULL);
}

#endif