gegl r2547 - in branches/branch2_zhangjb: gegl/graph operations/frequency operations/frequency/tools



Author: zhangjb
Date: Fri Aug  1 08:30:16 2008
New Revision: 2547
URL: http://svn.gnome.org/viewvc/gegl?rev=2547&view=rev

Log:


Modified:
   branches/branch2_zhangjb/gegl/graph/gegl-node.c
   branches/branch2_zhangjb/operations/frequency/dft.c
   branches/branch2_zhangjb/operations/frequency/freq-general-filter.c
   branches/branch2_zhangjb/operations/frequency/idft.c
   branches/branch2_zhangjb/operations/frequency/lowpass-gaussian.c
   branches/branch2_zhangjb/operations/frequency/tools/component.c
   branches/branch2_zhangjb/operations/frequency/tools/filters.c
   branches/branch2_zhangjb/operations/frequency/tools/fourier.c

Modified: branches/branch2_zhangjb/gegl/graph/gegl-node.c
==============================================================================
--- branches/branch2_zhangjb/gegl/graph/gegl-node.c	(original)
+++ branches/branch2_zhangjb/gegl/graph/gegl-node.c	Fri Aug  1 08:30:16 2008
@@ -1524,7 +1524,9 @@
 
   processor = gegl_node_new_processor (self, NULL);
 
-  while (gegl_processor_work (processor, NULL)) ;
+  while (gegl_processor_work (processor, NULL))
+    
+;
   gegl_processor_destroy (processor);
 }
 

Modified: branches/branch2_zhangjb/operations/frequency/dft.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/dft.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/dft.c	Fri Aug  1 08:30:16 2008
@@ -25,7 +25,7 @@
 #define GEGL_CHANT_TYPE_FILTER
 #define GEGL_CHANT_C_FILE       "dft.c"
 
-#include "gegl-chant.h"
+#include <gegl-chant.h>
 #include "tools/fourier.c"
 #include "tools/component.c"
 
@@ -40,7 +40,7 @@
                         const gchar *input_pad,
                         const GeglRectangle *roi)
 {
-  return *gegl_operation_source_get_bounding_box(operation, "input");
+  return  *gegl_operation_source_get_bounding_box(operation, "input");
 }
 
 static GeglRectangle
@@ -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);
       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,

Modified: branches/branch2_zhangjb/operations/frequency/freq-general-filter.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/freq-general-filter.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/freq-general-filter.c	Fri Aug  1 08:30:16 2008
@@ -62,7 +62,7 @@
   src_buf = g_new0(gdouble, 8*width*height);
   dst_buf = g_new0(gdouble, 8*width*height);    
   comp_real = g_new0(gdouble, FFT_HALF(width)*height);
-  comp_imag = g_new0(gdouble, FFT_HALF(width)*height);  
+  comp_imag = g_new0(gdouble,FFT_HALF(width)*height);  
   gegl_buffer_get(input, 1.0, NULL, babl_format ("frequency double"), src_buf,
                   GEGL_AUTO_ROWSTRIDE);  
   for (i=0; i<4; i++)

Modified: branches/branch2_zhangjb/operations/frequency/idft.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/idft.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/idft.c	Fri Aug  1 08:30:16 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));
       idft((fftw_complex *)tmp_src_buf, tmp_dst_buf, width, height);
       set_rgba_component(tmp_dst_buf, dst_buf, i, width*height);
     }

Modified: branches/branch2_zhangjb/operations/frequency/lowpass-gaussian.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/lowpass-gaussian.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/lowpass-gaussian.c	Fri Aug  1 08:30:16 2008
@@ -15,7 +15,7 @@
  *
  * Copyright 2008 Zhang Junbo  <zhangjb svn gnome org>
  */
-
+/*
 #ifdef GEGL_CHANT_PROPERTIES
 
 gegl_chant_int(cutoff, "Cutoff", 0, G_MAXINT, 0, "The cut off frequncy.")
@@ -51,8 +51,8 @@
   GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
   gdouble *src_buf;
   gdouble *dst_buf;
-  gdouble *comp_real;The most general filer in frequency domain. What it does is just "
-  "multiplying a matrix on the freqeuncy image.";
+  gdouble *comp_real;//The most general filer in frequency domain. What it does is just "
+  //"multiplying a matrix on the freqeuncy image.";
   gdouble *comp_imag;
   gdouble *Hr_buf;
   gdouble *Hi_buf;
@@ -110,3 +110,4 @@
 }
 
 #endif
+*/
\ No newline at end of file

Modified: branches/branch2_zhangjb/operations/frequency/tools/component.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/component.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/tools/component.c	Fri Aug  1 08:30:16 2008
@@ -16,6 +16,9 @@
  * Copyright 2008 Zhang Junbo  <zhangjb svn gnome org>
  */
 
+#ifndef COMPONENT_H
+#define COMPONENT_H
+
 #ifndef FFT_HALF
 #define FFT_HALF(n) (gint)((n)/2+1)
 #define ELEM_ID_MATRIX(x, y, c) ((y)*(c)+(x)) 
@@ -26,6 +29,9 @@
 gboolean set_rgba_component(gdouble *, gdouble *, gint, glong);
 gboolean get_freq_component(gdouble *, gdouble *, gint, glong);
 gboolean set_freq_component(gdouble *, gdouble *, gint, glong);
+gboolean get_complex_component(gdouble *, gdouble *, gint, glong);
+gboolean set_complex_component(gdouble *, gdouble *, gint, glong);
+
 
 gboolean
 get_rgba_component(gdouble* src_buf, gdouble *comp_buf, gint place,
@@ -39,7 +45,7 @@
     }
   return TRUE;
 }
-  
+
 gboolean
 set_rgba_component(gdouble* comp_buf, gdouble* dst_buf, gint place, glong samples)
 {
@@ -64,7 +70,7 @@
     }
   return TRUE;
 }
-  
+
 gboolean
 set_freq_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
                    glong samples)
@@ -77,3 +83,37 @@
     }
   return TRUE;
 }
+
+gboolean
+set_complex_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
+                      glong samples)
+{
+  dst_buf+=place;
+  while(samples--)
+    {
+      dst_buf[0]=comp_buf[0];
+      dst_buf[4]=comp_buf[1];
+      comp_buf+=2;
+      dst_buf+=8;
+    }
+
+  return TRUE;
+}
+
+gboolean
+get_complex_component(gdouble* src_buf, gdouble* comp_buf, gint place,
+                      glong samples)
+{
+  src_buf+=place;
+  while(samples--)
+    {
+      comp_buf[0]=src_buf[0];
+      comp_buf[1]=src_buf[4];
+      comp_buf+=2;
+      src_buf+=8;
+    }
+
+  return TRUE;
+}
+
+#endif

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	Fri Aug  1 08:30:16 2008
@@ -32,59 +32,24 @@
 {
   gint x, y;
   gint yc = 0;
-  gdouble *Yr;
-  gdouble *Yi;
-
-  Yr = g_new0(gdouble, FFT_HALF(width)*height);
-  Yi = g_new0(gdouble, FFT_HALF(width)*height);
-
-  for (y=height/2; y<height; y++)
-    {
-      for (x=0; x<width; x++)
-        {
-          Yr[ELEM_ID_HALF_MATRIX(x, yc, width)] =
-            Xr[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hr[ELEM_ID_HALF_MATRIX(x, y, width)] -
-            Xi[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
-          Yi[ELEM_ID_HALF_MATRIX(x, yc, width)] =
-            Xi[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hr[ELEM_ID_HALF_MATRIX(x, y, width)] +
-            Xr[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
-        }
-      yc++;
-    }
-  for (y=0; y<height/2; y++)
-    {
-      for (x=0; x<width; x++)
-        {
-          Yr[ELEM_ID_HALF_MATRIX(x, yc, width)] =
-            Xr[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hr[ELEM_ID_HALF_MATRIX(x, y, width)] -
-            Xi[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
-          Yi[ELEM_ID_HALF_MATRIX(x, yc, width)] =
-            Xi[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hr[ELEM_ID_HALF_MATRIX(x, y, width)] +
-            Xr[ELEM_ID_HALF_MATRIX(x, yc, width)] *
-            Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
-        }
-      yc++;
-    }
-  for (y=0; y<height; y++)
-    {
-      for (x=0; x<width; x++)
-        {
-          Xr[ELEM_ID_HALF_MATRIX(x, y, width)] =
-            Yr[ELEM_ID_HALF_MATRIX(x, y, width)];
-          Xr[ELEM_ID_HALF_MATRIX(x, y, width)] =
-            Yr[ELEM_ID_HALF_MATRIX(x, y, width)];
-        }
-    }
-
-  g_free(Yr);
-  g_free(Yi);
+  gdouble Yr,Yi;
+  
+  for(y=0;y<height;y++)
+    for(x=0;x<(width/2+1);x++)
+      {
+        Yr=
+          Xr[ELEM_ID_HALF_MATRIX(x, y, width)] *
+          Hr[ELEM_ID_HALF_MATRIX(x, y, width)] -
+          Xi[ELEM_ID_HALF_MATRIX(x, y, width)] *
+          Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
+        Yi=
+          Xi[ELEM_ID_HALF_MATRIX(x, y, width)] *
+          Hr[ELEM_ID_HALF_MATRIX(x, y, width)] +
+          Xr[ELEM_ID_HALF_MATRIX(x, y, width)] *
+          Hi[ELEM_ID_HALF_MATRIX(x, y, width)];
+        Xr[ELEM_ID_HALF_MATRIX(x, y, width)] = Yr;
+        Xi[ELEM_ID_HALF_MATRIX(x, y, width)] = Yi;
+      }
   return TRUE;
 }
 
@@ -93,7 +58,7 @@
                       gint cutoff)
 {
   gint x, y;
-  gint x0, y0, xd:
+  gint x0, y0, xd;
   
   for (x=0; x<FFT_HALF(width); x++)
     {
@@ -101,8 +66,8 @@
         {
           Hi[ELEM_ID_HALF_MATRIX(x, y, width)] = 0;
           Hr[ELEM_ID_HALF_MATRIX(x, y, width)]
-            = exp(0 - ((x)*(x)+(y-height/2)*(y-height/2)/2/(cutoff*cutoff));
+            = exp(0 - ((x)*(x)+(y-height/2)*(y-height/2)/2*(cutoff*cutoff)));
         }
     }
-  retrun TRUE;
+  return TRUE;
 }

Modified: branches/branch2_zhangjb/operations/frequency/tools/fourier.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/fourier.c	(original)
+++ branches/branch2_zhangjb/operations/frequency/tools/fourier.c	Fri Aug  1 08:30:16 2008
@@ -33,9 +33,11 @@
 gboolean encode(gdouble *, gint);
 gint decode(gdouble *);
 
+
 gboolean
 dft(gdouble *src_buf, fftw_complex *dst_buf, gint width, gint height)
 {
+
   fftw_plan fftplan;
 
   fftplan = fftw_plan_dft_r2c_2d(height,



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