gegl r2323 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools



Author: zhangjb
Date: Tue May 20 13:43:32 2008
New Revision: 2323
URL: http://svn.gnome.org/viewvc/gegl?rev=2323&view=rev

Log:
* operations/frequency/tools/dft.h: moved shift_dft to file display.h
* operations/frequency/tools/dft.c:
* operations/frequency/tools/display.c: some functions to show frequency image.
* operations/frequency/tools/display.h
* operations/frequency/tools/Makefile.am:
* operations/frequency/dft-grey.c: testing functions in display.h|c 


Added:
   branches/branch_zhangjb/operations/frequency/tools/display.c
   branches/branch_zhangjb/operations/frequency/tools/display.h
Modified:
   branches/branch_zhangjb/ChangeLog
   branches/branch_zhangjb/operations/frequency/dft-grey.c
   branches/branch_zhangjb/operations/frequency/tools/Makefile.am
   branches/branch_zhangjb/operations/frequency/tools/dft.c
   branches/branch_zhangjb/operations/frequency/tools/dft.h

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	Tue May 20 13:43:32 2008
@@ -15,6 +15,8 @@
 #include "gegl-chant.h"
 #include "tools/dft.h"
 #include "tools/dft.c"
+#include "tools/display.h"
+#include "tools/display.c"
 #include <fftw3.h>
 
 static void prepare(GeglOperation *operation)
@@ -53,6 +55,8 @@
   dst_imag_buf = g_new0(gdouble, height*width);
 
   dft(src_buf, dst_buf, dst_imag_buf, width, height);
+  zoomshow(dst_buf, width*height);
+  shift_dft(dst_buf, width, height);
 
 #if 0
   printf("width = %d, height = %d\n", width, height);

Modified: branches/branch_zhangjb/operations/frequency/tools/Makefile.am
==============================================================================
--- branches/branch_zhangjb/operations/frequency/tools/Makefile.am	(original)
+++ branches/branch_zhangjb/operations/frequency/tools/Makefile.am	Tue May 20 13:43:32 2008
@@ -1,3 +1,5 @@
 EXTRA_DIST = \
 	dft.c	\
-	dft.h
\ No newline at end of file
+	dft.h	\
+	display.c	\
+	display.h
\ No newline at end of file

Modified: branches/branch_zhangjb/operations/frequency/tools/dft.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/tools/dft.c	(original)
+++ branches/branch_zhangjb/operations/frequency/tools/dft.c	Tue May 20 13:43:32 2008
@@ -16,8 +16,6 @@
  * Copyright 2008 Zhang Junbo  <zhangjb svn gnome org>
  */
 
-#include "dft.h"
-
 static gint
 fft_complex_get_half_id(gint x, gint y, gint width, gint height)
 {

Modified: branches/branch_zhangjb/operations/frequency/tools/dft.h
==============================================================================
--- branches/branch_zhangjb/operations/frequency/tools/dft.h	(original)
+++ branches/branch_zhangjb/operations/frequency/tools/dft.h	Tue May 20 13:43:32 2008
@@ -38,8 +38,3 @@
 	  gdouble *dst_buf,
 	  gint width,
 	  gint height);
-
-gboolean
-shift_dft (gdouble *buf,
-		   gint width,
-		   gint height);

Added: branches/branch_zhangjb/operations/frequency/tools/display.c
==============================================================================
--- (empty file)
+++ branches/branch_zhangjb/operations/frequency/tools/display.c	Tue May 20 13:43:32 2008
@@ -0,0 +1,61 @@
+/* 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>
+ */
+
+gboolean
+zoomshow (gdouble *buf,
+		  glong samples)
+{
+  glong i;
+
+  for (i=0; i<samples; i++)
+	{
+	  *(buf+i) = log10(*(buf+i))/6;
+	}
+  return TRUE;
+}
+
+gboolean
+shift_dft (gdouble *buf,
+		   gint width,
+		   gint height)
+{
+  gint cx, cy;
+  gint add_x, add_y;
+  gint x, y;
+  gdouble tmp_buf[width*height];
+
+  cx = width/2;
+  cy = height/2;
+
+  for (x=0; x<width; x++)
+  {
+	  for (y=0; y<height; y++)
+	  {
+		  add_x = (x<(cx+width%2)) ? cx : (0-cx-width%2);
+		  add_y = (y<(cy+height%2)) ? cy : (0-cy-height%2);
+		  tmp_buf[ELEM_ID_MATRIX(x+add_x, y+add_y, width)] 
+				  = buf[ELEM_ID_MATRIX(x, y, width)];
+	  }
+  }
+  for (x=0; x<width*height; x++)
+  {
+	  buf[x] = tmp_buf[x];
+  }
+
+  return TRUE;
+}

Added: branches/branch_zhangjb/operations/frequency/tools/display.h
==============================================================================
--- (empty file)
+++ branches/branch_zhangjb/operations/frequency/tools/display.h	Tue May 20 13:43:32 2008
@@ -0,0 +1,41 @@
+/* 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>
+ */
+
+#ifndef FFT_HALF
+#define FFT_HALF(n) (gint)((n)/2+1)
+#define ELEM_ID_MATRIX(x, y, c) ((y)*(c)+(x)) 
+#define ELEM_ID_HALF_MATRIX(x, y, c) ((y)*(FFT_HALF(c))+(x))
+#endif
+
+#include "gegl.h"
+#include <math.h>
+
+gboolean
+shift_dft (gdouble *buf,
+		   gint width,
+		   gint height);
+
+gboolean
+i_shift_dft (gdouble *buf,
+		   gint width,
+		   gint height);
+
+gboolean
+zoomshow (gdouble *buf,
+		  glong samples);
+



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