gegl r2318 - in branches/branch_zhangjb: . operations/frequency tests/frequency
- From: zhangjb svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2318 - in branches/branch_zhangjb: . operations/frequency tests/frequency
- Date: Sun, 18 May 2008 17:34:52 +0000 (UTC)
Author: zhangjb
Date: Sun May 18 17:34:52 2008
New Revision: 2318
URL: http://svn.gnome.org/viewvc/gegl?rev=2318&view=rev
Log:
* tests/frequency/hello-world-fourier.c:
* operations/frequency/dft-grey.c: a new operation calling dft.
Added:
branches/branch_zhangjb/operations/frequency/dft-grey.c
Modified:
branches/branch_zhangjb/ChangeLog
branches/branch_zhangjb/tests/frequency/hello-world-fourier.c
Added: branches/branch_zhangjb/operations/frequency/dft-grey.c
==============================================================================
--- (empty file)
+++ branches/branch_zhangjb/operations/frequency/dft-grey.c Sun May 18 17:34:52 2008
@@ -0,0 +1,105 @@
+/* This file is just for test. This operation can NOT be used in any
+ * practice case by now.
+ *
+ */
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+/* no properties */
+
+#else
+
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "dft-grey.c"
+
+#include "gegl-chant.h"
+#include "dft.h"
+#include <fftw3.h>
+
+static void prepare(GeglOperation *operation)
+{
+ Babl *image_format = babl_format_new(babl_model("Y"),
+ babl_type("double"),
+ babl_component("Y"),
+ NULL);
+ Babl *frequency_format = babl_format_new(babl_model("Y"),
+ babl_type("double"),
+ babl_component("Y"),
+ NULL);
+ gegl_operation_set_format(operation, "input", image_format);
+ gegl_operation_set_format(operation, "output", frequency_format);
+}
+
+static gboolean process(GeglOperation *operation,
+ GeglBuffer *input,
+ GeglBuffer *output,
+ const GeglRectangle *result)
+{
+ gint width= gegl_buffer_get_width(input);
+ gint height= gegl_buffer_get_height(input);
+ gdouble *src_buf;
+ gdouble *dst_buf;
+ gdouble *dst_imag_buf;
+
+ src_buf = g_new0(gdouble, width*height);
+ 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);
+
+ dst_buf = g_new0(gdouble, height*width);
+ dst_imag_buf = g_new0(gdouble, height*width);
+
+ dft(src_buf, dst_buf, dst_imag_buf, width, height);
+
+#if 0
+ printf("width = %d, height = %d\n", width, height);
+ for (i=0; i<height; i++)
+ {
+ for (j=0; j<width; j++)
+ {
+ printf("%f\t", src_buf[ELEM_ID_MATRIX(j, i, width)]);
+ }
+ printf("\n");
+ }
+ printf("output: width = %d, height = %d\n", width, height);
+ for (i=0; i<height; i++)
+ {
+ for (j=0; j<width; j++)
+ {
+ printf("%lf\t", dst_buf[ELEM_ID_MATRIX(j, i, width)]);
+ }
+ printf("\n");
+ }
+#endif
+
+ gegl_buffer_set(output,
+ NULL, babl_format_new(babl_model("Y"),
+ babl_type("double"),
+ babl_component("Y"),
+ NULL), dst_buf, GEGL_AUTO_ROWSTRIDE);
+
+ return TRUE;
+}
+
+static void gegl_chant_class_init(GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationFilterClass *filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS(klass);
+ filter_class = GEGL_OPERATION_FILTER_CLASS(klass);
+
+ filter_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "dft-grey";
+ operation_class->categories = "frequency";
+ operation_class->description
+ = "Perform 2-D Discrete Fourier Transform for the image.\n"
+ "Note this operation is just for test, which can NOT be "
+ "used to do anything by now.";
+}
+
+#endif
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 Sun May 18 17:34:52 2008
@@ -16,7 +16,7 @@
"path",
"/home/bear/GSoC2008/workspace/images/lena.png",
NULL);
- GeglNode *proc = gegl_node_new_child(gegl, "operation", "dft", NULL);
+ GeglNode *proc = gegl_node_new_child(gegl, "operation", "dft-grey", NULL);
GeglNode *grey = gegl_node_new_child(gegl, "operation", "grey", NULL);
GeglNode *save =
gegl_node_new_child(gegl,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]