gegl r2512 - in branches/branch2_zhangjb: . operations/frequency operations/frequency/tools
- From: zhangjb svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2512 - in branches/branch2_zhangjb: . operations/frequency operations/frequency/tools
- Date: Mon, 30 Jun 2008 03:26:14 +0000 (UTC)
Author: zhangjb
Date: Mon Jun 30 03:26:14 2008
New Revision: 2512
URL: http://svn.gnome.org/viewvc/gegl?rev=2512&view=rev
Log:
* operations/frequency/freq-general-filter.c: get/set_freq() tested.
* operations/frequency/tools/component.c: modified get/set_freq().
* operations/frequency/tools/display.c:
* operations/frequency/tools/filters.c: remodified the parameter table.
Modified:
branches/branch2_zhangjb/ChangeLog
branches/branch2_zhangjb/operations/frequency/freq-general-filter.c
branches/branch2_zhangjb/operations/frequency/tools/component.c
branches/branch2_zhangjb/operations/frequency/tools/display.c
branches/branch2_zhangjb/operations/frequency/tools/filters.c
Modified: branches/branch2_zhangjb/operations/frequency/freq-general-filter.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/freq-general-filter.c (original)
+++ branches/branch2_zhangjb/operations/frequency/freq-general-filter.c Mon Jun 30 03:26:14 2008
@@ -27,6 +27,7 @@
#include "gegl-chant.h"
#include "tools/component.c"
+#include "tools/filters.c"
static GeglRectangle
get_bounding_box (GeglOperation *operation)
@@ -68,6 +69,8 @@
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gdouble *src_buf;
gdouble *dst_buf;
+ gdouble *comp_real;
+ gdouble *comp_imag;
gdouble *H_buf = o->Hbuf;
src_buf = g_new0(gdouble, 8*width*height);
@@ -75,14 +78,16 @@
gegl_buffer_get(input, 1.0, NULL, babl_format ("frequency double"), src_buf,
GEGL_AUTO_ROWSTRIDE);
-#if 1
- gint i;
- for (i=0; i<(width/2+1)*height; i++)
- {
- printf("%lf ", H_buf[i]);
- }
- printf("\n");
-#endif
+ comp_real = g_new0(gdouble, FFT_HALF(width)*height);
+ comp_imag = g_new0(gdouble, FFT_HALF(width)*height);
+
+ get_freq_component(src_buf, comp_real, 0, FFT_HALF(width)*height);
+ get_freq_component(src_buf, comp_imag, 4, FFT_HALF(width)*height);
+
+ freq_multiply(comp_real, comp_imag, H_buf, width, height);
+
+ set_freq_component(comp_real, dst_buf, 0, FFT_HALF(width)*height);
+ set_freq_component(comp_imag, dst_buf, 4, FFT_HALF(width)*height);
gegl_buffer_set(output, NULL, babl_format ("frequency double"), dst_buf,
GEGL_AUTO_ROWSTRIDE);
Modified: branches/branch2_zhangjb/operations/frequency/tools/component.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/component.c (original)
+++ branches/branch2_zhangjb/operations/frequency/tools/component.c Mon Jun 30 03:26:14 2008
@@ -16,14 +16,16 @@
* Copyright 2008 Zhang Junbo <zhangjb svn gnome org>
*/
-gboolean get_rgba_component(gdouble* src_buf, gdouble* comp_buf, gint place,
- glong samples);
-gboolean set_rgba_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
- glong samples);
-gboolean get_freq_component(gdouble* src_buf, gdouble* comp_buf, gint place,
- glong samples);
-gboolean set_freq_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
- glong samples);
+#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
+
+gboolean get_rgba_component(gdouble *, gdouble *, gint, glong);
+gboolean set_rgba_component(gdouble *, gdouble *, gint, glong);
+gboolean get_freq_component(gdouble *, gdouble *, gint, glong);
+gboolean set_freq_component(gdouble *, gdouble *, gint, glong);
gboolean
get_rgba_component(gdouble* src_buf, gdouble *comp_buf, gint place,
@@ -54,11 +56,10 @@
get_freq_component(gdouble* src_buf, gdouble *comp_buf, gint place,
glong samples)
{
- src_buf += place*2;
+ src_buf += place;
while (samples--)
{
*(comp_buf++) = *src_buf;
- *(comp_buf++) = *(src_buf+1);
src_buf += 8;
}
return TRUE;
@@ -68,11 +69,10 @@
set_freq_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
glong samples)
{
- dst_buf += place*2;
+ dst_buf += place;
while (samples--)
{
*dst_buf = *(comp_buf++);
- *(dst_buf+1) = *(comp_buf++);
dst_buf += 8;
}
return TRUE;
Modified: branches/branch2_zhangjb/operations/frequency/tools/display.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/display.c (original)
+++ branches/branch2_zhangjb/operations/frequency/tools/display.c Mon Jun 30 03:26:14 2008
@@ -130,19 +130,24 @@
{
if (x<FFT_HALF(width))
{
- dst_real_buf[ELEM_ID_MATRIX(x, y, width)] = src_buf[ELEM_ID_HALF_MATRIX(x, y, width)][0];
- dst_imag_buf[ELEM_ID_MATRIX(x, y, width)] = src_buf[ELEM_ID_HALF_MATRIX(x, y, width)][1];
+ dst_real_buf[ELEM_ID_MATRIX(x, y, width)] =
+ src_buf[ELEM_ID_HALF_MATRIX(x, y, width)][0];
+ dst_imag_buf[ELEM_ID_MATRIX(x, y, width)] =
+ src_buf[ELEM_ID_HALF_MATRIX(x, y, width)][1];
}
else
{
- dst_real_buf[ELEM_ID_MATRIX(x, y, width)] = src_buf[fft_complex_get_half_id(x, y, width, height)][0];
- dst_imag_buf[ELEM_ID_MATRIX(x, y, width)] = 0-src_buf[fft_complex_get_half_id(x, y, width, height)][1];
+ dst_real_buf[ELEM_ID_MATRIX(x, y, width)] =
+ src_buf[fft_complex_get_half_id(x, y, width, height)][0];
+ dst_imag_buf[ELEM_ID_MATRIX(x, y, width)] =
+ 0-src_buf[fft_complex_get_half_id(x, y, width, height)][1];
}
}
}
for (x=0; x<width*height; x++)
{
- dst_buf[x] = sqrt(dst_real_buf[x]*dst_real_buf[x]+dst_imag_buf[x]*dst_imag_buf[x]);
+ dst_buf[x] =
+ sqrt(dst_real_buf[x]*dst_real_buf[x]+dst_imag_buf[x]*dst_imag_buf[x]);
}
zoomshow(dst_buf, samples);
Modified: branches/branch2_zhangjb/operations/frequency/tools/filters.c
==============================================================================
--- branches/branch2_zhangjb/operations/frequency/tools/filters.c (original)
+++ branches/branch2_zhangjb/operations/frequency/tools/filters.c Mon Jun 30 03:26:14 2008
@@ -22,10 +22,10 @@
#define ELEM_ID_HALF_MATRIX(x, y, c) ((y)*(FFT_HALF(c))+(x))
#endif
-gboolean freq_multiply(gdouble, gdouble, gdouble, gint, gint);
+gboolean freq_multiply(gdouble *, gdouble *, gdouble *, gint, gint);
gboolean
-freq_multiply(gdouble *X_buf, gdouble *H_buf, gdouble *Y_buf,
+freq_multiply(gdouble *Xr_buf, gdouble *Xi_buf, gdouble *H_buf,
gint width, gint height)
{
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]