gegl r2342 - in branches/branch_zhangjb: . operations/frequency tests/frequency



Author: zhangjb
Date: Fri May 23 13:52:34 2008
New Revision: 2342
URL: http://svn.gnome.org/viewvc/gegl?rev=2342&view=rev

Log:
output size is correct now, but the extra-part of the output is all zero ...
* operations/frequency/dft-grey.c: overwrote some functions to change the output size.
* operations/frequency/preview-frequency-grey.c: added some testing code.
* tests/frequency/hello-world-fourier.c:


Modified:
   branches/branch_zhangjb/ChangeLog
   branches/branch_zhangjb/operations/frequency/dft-grey.c
   branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c
   branches/branch_zhangjb/tests/frequency/hello-world-fourier.c

Modified: branches/branch_zhangjb/operations/frequency/dft-grey.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/dft-grey.c	(original)
+++ branches/branch_zhangjb/operations/frequency/dft-grey.c	Fri May 23 13:52:34 2008
@@ -16,6 +16,39 @@
 #include <fftw3.h>
 
 static GeglRectangle
+get_bounding_box (GeglOperation *operation)
+{
+  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
+  GeglRectangle  result  = { 0, 0, 0, 0 };
+
+  result.x = in_rect->x;
+  result.y = in_rect->y;
+  result.width  = (in_rect->width)+2;
+  result.height = in_rect->height;
+
+  return result;
+}
+
+static GeglRectangle
+get_invalidated_by_change (GeglOperation       *operation,
+                         const gchar         *input_pad,
+                         const GeglRectangle *input_region)
+{
+  GeglRectangle  result  = { 0, 0, 0, 0 };
+
+  result.x = input_region->x;
+  result.y = input_region->y;
+  result.width  = (input_region->width)+2;
+  result.height = input_region->height;
+  
+#if 0
+  printf("%d, %d\n", result.x, result.width);
+#endif  
+  
+  return result;
+}
+
+static GeglRectangle
 get_required_for_output(GeglOperation *operation,
                         const gchar *input_pad,
                         const GeglRectangle *roi)
@@ -57,6 +90,7 @@
   gint height = gegl_buffer_get_height(input);
   gdouble *src_buf;
   gdouble *dst_buf;
+  GeglRectangle extent = get_bounding_box(operation);
 
   src_buf = g_new0(gdouble, width*height);
   gegl_buffer_get(input, 1.0, 
@@ -92,6 +126,10 @@
         }
       printf("\n");
     }
+#endif
+  
+#if 1  
+  int x, y;
   printf("output: width = %d, height = %d\n", 2*FFT_HALF(width), height);
   for (y=0; y<height; y++)
     {
@@ -102,12 +140,35 @@
       printf("\n");
     }
 #endif
+
+#if 0 
+  printf("extent: x = %d, width = %d\n", extent.x, extent.width);
+#endif
   
   gegl_buffer_set(output, 
-                  NULL, babl_format_new(babl_model("Y"),
+                  &extent, babl_format_new(babl_model("Y"),
                                         babl_type("double"),
                                         babl_component("Y"),
                                         NULL), (gdouble *)dst_buf, GEGL_AUTO_ROWSTRIDE);
+
+  
+#if 0  
+  gegl_buffer_get(input, 1.0, 
+                    NULL, babl_format_new(babl_model("Y"),
+                                          babl_type("double"),
+                                          babl_component("Y"),
+                                          NULL), src_buf, GEGL_AUTO_ROWSTRIDE);
+  printf("output: width = %d, height = %d\n", 2*FFT_HALF(width), height);
+  for (y=0; y<height; y++)
+    {
+      for (x=0; x<2*FFT_HALF(width); x++)
+        {
+          printf("%lf\t", dst_buf[ELEM_ID_MATRIX(x, y, 2*FFT_HALF(width))]);
+        }
+      printf("\n");
+    }
+#endif
+  
   g_free(src_buf);
   g_free(dst_buf);
   return TRUE;
@@ -124,7 +185,9 @@
 
   filter_class->process = process;
   operation_class->prepare = prepare;
+  operation_class->get_bounding_box = get_bounding_box;
   operation_class->get_required_for_output= get_required_for_output;
+  operation_class->get_invalidated_by_change = get_invalidated_by_change;
   operation_class->get_cached_region = get_cached_region;
 
   operation_class->name = "dft-grey";

Modified: branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c	(original)
+++ branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c	Fri May 23 13:52:34 2008
@@ -58,7 +58,7 @@
   gdouble *src_buf;
   gdouble *dst_buf;
   
-#if 1
+#if 0
   printf("get_width(input)=%d, get_height(input)=%d\n", width, height);
 #endif
 
@@ -68,6 +68,20 @@
                                         babl_type("double"),
                                         babl_component("Y"),
                                         NULL), src_buf, GEGL_AUTO_ROWSTRIDE);
+  
+#if 1
+  int x, y;
+  printf("input: width = %d, height = %d\n", width, height);
+  for (y=0; y<height; y++)
+    {
+      for (x=0; x<width; x++)
+        {
+          printf("%lf\t", src_buf[ELEM_ID_MATRIX(x, y, width)]);
+        }
+      printf("\n");
+    }
+#endif
+  
   dst_buf = g_new0(gdouble, 2*width*height);
 
   fre2img((fftw_complex *)src_buf, dst_buf, width, height);

Modified: branches/branch_zhangjb/tests/frequency/hello-world-fourier.c
==============================================================================
--- branches/branch_zhangjb/tests/frequency/hello-world-fourier.c	(original)
+++ branches/branch_zhangjb/tests/frequency/hello-world-fourier.c	Fri May 23 13:52:34 2008
@@ -13,7 +13,7 @@
                                   "operation",
                                   "load",
                                   "path",
-                                  "docs/images/lena_bw.png",
+                                  "docs/images/test.png",
                                   NULL);
       GeglNode *dft = gegl_node_new_child(gegl, "operation", "dft-grey", NULL);
       GeglNode *idft = gegl_node_new_child(gegl, "operation", "dft-inverse-grey", NULL);



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