gegl r2346 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools tests/frequency
- From: zhangjb svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2346 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools tests/frequency
- Date: Fri, 23 May 2008 16:35:54 +0000 (UTC)
Author: zhangjb
Date: Fri May 23 16:35:54 2008
New Revision: 2346
URL: http://svn.gnome.org/viewvc/gegl?rev=2346&view=rev
Log:
The operation preview-frequency-grey is able to use.
* operations/frequency/preview-frequency-grey.c: now works correctly with new data structure.
* operations/frequency/tools/display.c: used shift_dft to show the frequency domain.
* tests/frequency/hello-world-fourier.c: replaced test.png by lena_bw.png.
Modified:
branches/branch_zhangjb/ChangeLog
branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c
branches/branch_zhangjb/operations/frequency/tools/display.c
branches/branch_zhangjb/tests/frequency/hello-world-fourier.c
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 16:35:54 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
@@ -16,12 +30,12 @@
#include <fftw3.h>
static GeglRectangle
-get_required_for_output(GeglOperation *operation,
- const gchar *input_pad,
- const GeglRectangle *roi)
+get_bounding_box (GeglOperation *operation)
{
- GeglRectangle result = *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;
}
@@ -29,7 +43,21 @@
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 GeglRectangle
+get_required_for_output(GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *roi)
+{
+ GeglRectangle result = *gegl_operation_source_get_bounding_box(operation,
+ "input");
+ return result;
}
static void
@@ -53,43 +81,25 @@
GeglBuffer *output,
const GeglRectangle *result)
{
- gint width = gegl_buffer_get_width(input);
+ gint width = gegl_buffer_get_width(input)-2;
gint height = gegl_buffer_get_height(input);
gdouble *src_buf;
gdouble *dst_buf;
-
-#if 0
- printf("get_width(input)=%d, get_height(input)=%d\n", width, height);
-#endif
src_buf = g_new0(gdouble, 2*height*FFT_HALF(width));
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);
-
-#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
-
+ NULL), src_buf, GEGL_AUTO_ROWSTRIDE);
dst_buf = g_new0(gdouble, 2*width*height);
-
- fre2img((fftw_complex *)src_buf, dst_buf, width, height);
+
+ fre2img((fftw_complex *)src_buf, dst_buf, width, height);
gegl_buffer_set(output,
NULL, babl_format_new(babl_model("Y"),
babl_type("double"),
babl_component("Y"),
- NULL), (gdouble *)dst_buf, GEGL_AUTO_ROWSTRIDE);
+ NULL), (gdouble *)dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free(src_buf);
g_free(dst_buf);
return TRUE;
@@ -106,13 +116,14 @@
filter_class->process = process;
operation_class->prepare = prepare;
- operation_class->get_required_for_output= get_required_for_output;
+ operation_class->get_bounding_box = get_bounding_box;
+ operation_class->get_required_for_output= get_required_for_output;
operation_class->get_cached_region = get_cached_region;
operation_class->name = "preview-frequency-grey";
operation_class->categories = "frequency";
operation_class->description
- = "convert the frequency buffer to a diplayable image.";
+ = "convert the frequency buffer to a displayable gray image.";
}
#endif
Modified: branches/branch_zhangjb/operations/frequency/tools/display.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/tools/display.c (original)
+++ branches/branch_zhangjb/operations/frequency/tools/display.c Fri May 23 16:35:54 2008
@@ -149,7 +149,7 @@
}
zoomshow(dst_buf, samples);
- // shift_dft(dst_buf, width, height);
+ shift_dft(dst_buf, width, height);
g_free(dst_real_buf);
g_free(dst_imag_buf);
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 16:35:54 2008
@@ -13,7 +13,7 @@
"operation",
"load",
"path",
- "docs/images/test.png",
+ "docs/images/lena_bw.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]