gegl r2345 - in branches/branch_zhangjb: . operations/frequency



Author: zhangjb
Date: Fri May 23 16:08:19 2008
New Revision: 2345
URL: http://svn.gnome.org/viewvc/gegl?rev=2345&view=rev

Log:
The operation dft-grey is able to use.
* operations/frequency/dft-grey.c: now works correctly with new data structure.


Modified:
   branches/branch_zhangjb/ChangeLog
   branches/branch_zhangjb/operations/frequency/dft-grey.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 16:08:19 2008
@@ -1,5 +1,19 @@
-/* This file is just for test. This operation can NOT be used in any 
- * practice case by now. 
+/* This file is a part of 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 2008 Zhang Junbo  <zhangjb svn gnome org>
  */
 
 #ifdef GEGL_CHANT_PROPERTIES
@@ -19,32 +33,9 @@
 get_bounding_box (GeglOperation *operation)
 {
   GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
-  GeglRectangle  result  = { 0, 0, 0, 0 };
+  GeglRectangle  result  = *in_rect;
 
-  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  
-  
+  result.width  += 2;
   return result;
 }
 
@@ -62,7 +53,11 @@
 get_cached_region(GeglOperation *operation,
                   const GeglRectangle *roi)
 {
-  return *gegl_operation_source_get_bounding_box(operation, "input");
+  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
+  GeglRectangle  result  = *in_rect;
+
+  result.width  += 2;
+  return result;
 }
 
 static void
@@ -90,11 +85,6 @@
   gint height = gegl_buffer_get_height(input);
   gdouble *src_buf;
   gdouble *dst_buf;
-  GeglRectangle extent = get_bounding_box(operation);
-  
-#if 0
-  printf("extent: x = %d, width = %d\n", extent.x, extent.width);
-#endif
 
   src_buf = g_new0(gdouble, width*height);
   gegl_buffer_get(input, 1.0, 
@@ -106,70 +96,12 @@
 
   dft(src_buf, (fftw_complex *)dst_buf, width, height);
 
-#if 0
-  /* to show how many times this section be executed. */
-  printf("@\t");  
-#endif
-  
-#if 0  
-  int i;
-  for (i=0; i<width*height; i++)
-    {
-      dst_buf[i] = src_buf[i];
-    }
-#endif
-
-#if 0
-  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
-  
-#if 1  
-  int x, y;
-  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
-
-  //gegl_buffer_set_extent(output, &extent);
   gegl_buffer_set(output, 
-                  &extent, babl_format_new(babl_model("Y"),
+                  NULL, babl_format_new(babl_model("Y"),
                                         babl_type("double"),
                                         babl_component("Y"),
                                         NULL), dst_buf, GEGL_AUTO_ROWSTRIDE);
 
-  
-#if 1  
-  gegl_buffer_get(output, 1.0, 
-                  &extent, babl_format_new(babl_model("Y"),
-                                          babl_type("double"),
-                                          babl_component("Y"),
-                                          NULL), dst_buf, GEGL_AUTO_ROWSTRIDE);
-  printf("output: width = %d, height = %d\n", gegl_buffer_get_width(output), gegl_buffer_get_height(output));
-  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;
@@ -188,15 +120,12 @@
   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";
   operation_class->categories = "frequency";
   operation_class->description
-    = "Perform 2-D inverse Discrete Fourier Transform .\n"
-    "Note this operation is just for test, which can NOT be "
-    "used to do anything by now.";
+    = "Perform 2-D inverse Discrete Fourier Transform for a grey image.";
 }
 
 #endif



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