gegl r2552 - in branches/branch2_zhangjb: examples operations/frequency operations/frequency/tools



Author: zhangjb
Date: Sat Aug  2 02:00:02 2008
New Revision: 2552
URL: http://svn.gnome.org/viewvc/gegl?rev=2552&view=rev

Log:


Added:
   branches/branch2_zhangjb/examples/glpf_save.c
   branches/branch2_zhangjb/examples/glpf_show.c
Modified:
   branches/branch2_zhangjb/operations/frequency/homo-dft.c
   branches/branch2_zhangjb/operations/frequency/homo-idft.c
   branches/branch2_zhangjb/operations/frequency/tools/filters.c

Added: branches/branch2_zhangjb/examples/glpf_save.c
==============================================================================
--- (empty file)
+++ branches/branch2_zhangjb/examples/glpf_save.c	Sat Aug  2 02:00:02 2008
@@ -0,0 +1,65 @@
+#include "gegl.h"
+
+gint main(gint argc, gchar **argv)
+{
+  gegl_init(&argc, &argv); /* initialize the GEGL library */
+/*
+This is the graph we're going to construct:
+ 
+.-----------.
+| display   |
+`-----------'
+   |
+.-------.
+| idft  |
+`-------'
+   |   
+.-------.
+|filter |
+`-------'
+   |
+.-------.
+|  dft  |
+`-------'
+   |
+.-------.
+| image |
+`-------.
+
+*/
+ {
+   GeglNode *gegl = gegl_node_new();
+
+   /*load the image to be filtered*/
+   GeglNode *image = gegl_node_new_child(gegl,
+                                         "operation",
+                                         "load",
+                                         "path",
+                                         "data/surfer.png",
+                                         NULL);
+   GeglNode *dft = gegl_node_new_child(gegl, "operation", "dft", NULL);
+   GeglNode *glpf_filter = gegl_node_new_child(gegl,"operation",
+                                               "lowpass-gaussian","cutoff",30,"flag",14,NULL);
+   GeglNode *idft = gegl_node_new_child(gegl,"operation","idft", NULL);
+   
+   GeglNode *save = gegl_node_new_child(gegl,
+                                        "operation",
+                                        "png-save",
+                                        "path",
+                                        "test_result.png",
+                                        NULL);
+   
+   gegl_node_link_many(image,dft,glpf_filter,idft,save,NULL);
+
+   /* request that the save node is processed, all dependencies will
+    * be processed as well
+    */
+   gegl_node_process(save);
+   
+   g_object_unref(gegl);
+ } 
+
+ gegl_exit();
+ return 0;
+}
+

Added: branches/branch2_zhangjb/examples/glpf_show.c
==============================================================================
--- (empty file)
+++ branches/branch2_zhangjb/examples/glpf_show.c	Sat Aug  2 02:00:02 2008
@@ -0,0 +1,60 @@
+#include "gegl.h"
+
+gint main(gint argc, gchar **argv)
+{
+  gegl_init(&argc, &argv); /* initialize the GEGL library */
+/*
+This is the graph we're going to construct:
+ 
+.-----------.
+| display   |
+`-----------'
+   |
+.-------.
+| idft  |
+`-------'
+   |   
+.-------.
+|filter |
+`-------'
+   |
+.-------.
+|  dft  |
+`-------'
+   |
+.-------.
+| image |
+`-------.
+
+*/
+ {
+
+    GeglNode *gegl = gegl_node_new();
+    gint frame;
+    gint x, y;
+
+
+    GeglNode *image = gegl_node_new_child(gegl,
+                                            "operation",
+                                            "load",
+                                            "path",
+                                            "data/surfer.png",
+                                            NULL);
+    GeglNode *dft = gegl_node_new_child(gegl, "operation", "dft", NULL);
+    GeglNode *idft = gegl_node_new_child(gegl,"operation","idft", NULL);
+    GeglNode *glpf_filter = gegl_node_new_child(gegl,"operation",
+                                             "lowpass-gaussian","cutoff",30,"flag",14,NULL);
+
+    GeglNode *display    = gegl_node_create_child (gegl, "display");
+
+    gegl_node_link_many (image, dft, glpf_filter, idft, display, NULL);
+
+    gegl_node_process(display);
+
+    g_object_unref(gegl);
+ } 
+
+  gegl_exit();
+  return 0;
+}
+

Modified: branches/branch2_zhangjb/operations/frequency/homo-dft.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/homo-dft.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/homo-dft.c	Sat Aug  2 02:00:02 2008
@@ -74,8 +74,8 @@
 
   src_buf = g_new0(gdouble, 4*width*height);
   tmp_src_buf = g_new0(gdouble, width*height);
-  dst_buf = g_new0(gdouble, 8*height*width);
-  tmp_dst_buf = g_new0(gdouble, 2*height*FFT_HALF(width));
+  dst_buf = g_new0(gdouble, 8*height*(width));
+  tmp_dst_buf = g_new0(gdouble, 2*height*(width));
 
   gegl_buffer_get(input, 1.0, NULL, babl_format ("RGBA double"), src_buf,
                   GEGL_AUTO_ROWSTRIDE);
@@ -84,7 +84,7 @@
     {
       get_rgba_component(src_buf, tmp_src_buf, i, width*height);
       homo_dft(tmp_src_buf, (fftw_complex *)tmp_dst_buf, width, height);
-      set_rgba_component(tmp_dst_buf, dst_buf, i, 2*FFT_HALF(width)*height);
+      set_complex_component(tmp_dst_buf, dst_buf, i, FFT_HALF(width)*height);
     }
   
   gegl_buffer_set(output, NULL, babl_format ("frequency double"), dst_buf,
@@ -95,6 +95,7 @@
   g_free(tmp_src_buf);
   g_free(tmp_dst_buf);
   return TRUE;
+
 }
 
 static void

Modified: branches/branch2_zhangjb/operations/frequency/homo-idft.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/homo-idft.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/homo-idft.c	Sat Aug  2 02:00:02 2008
@@ -81,7 +81,7 @@
                   (gdouble *)src_buf, GEGL_AUTO_ROWSTRIDE);
   for (i=0; i<4; i++)
     {
-      get_rgba_component(src_buf, tmp_src_buf, i, 2*height*FFT_HALF(width));
+      get_complex_component(src_buf, tmp_src_buf, i, height*FFT_HALF(width));
       homo_idft((fftw_complex *)tmp_src_buf, tmp_dst_buf, width, height);
       set_rgba_component(tmp_dst_buf, dst_buf, i, width*height);
     }
@@ -94,6 +94,7 @@
   g_free(tmp_src_buf);
   g_free(tmp_dst_buf);
   return TRUE;
+
 }
 
 static void

Modified: branches/branch2_zhangjb/operations/frequency/tools/filters.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/filters.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/tools/filters.c	Sat Aug  2 02:00:02 2008
@@ -33,9 +33,10 @@
   gint x, y;
   gdouble Yr,Yi;
   gint index;
+  gint max_x = FFT_HALF(x);
   
   for(y=0;y<height;y++)
-    for(x=0;x<(width/2+1);x++)
+    for(x=0;x<max_x;x++)
       {
         index = ELEM_ID_HALF_MATRIX(x, y, width);
         Yr= Xr[index]*Hr[index] - Xi[index]*Hi[index];



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