gegl r2339 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools
- From: zhangjb svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2339 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools
- Date: Fri, 23 May 2008 04:52:49 +0000 (UTC)
Author: zhangjb
Date: Fri May 23 04:52:49 2008
New Revision: 2339
URL: http://svn.gnome.org/viewvc/gegl?rev=2339&view=rev
Log:
* operations/frequency/dft-grey.c: added some testing code.
* operations/frequency/preview-frequency-grey.c: fixed a small bug.
* operations/frequency/tools/display.c: replaced i|j by x|y.
Modified:
branches/branch_zhangjb/ChangeLog
branches/branch_zhangjb/operations/frequency/dft-grey.c
branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c
branches/branch_zhangjb/operations/frequency/tools/display.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 04:52:49 2008
@@ -68,6 +68,41 @@
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");
+ }
+ 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(output,
NULL, babl_format_new(babl_model("Y"),
babl_type("double"),
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 04:52:49 2008
@@ -58,7 +58,7 @@
gdouble *src_buf;
gdouble *dst_buf;
- src_buf = g_new0(gdouble, 2*width*FFT_HALF(height));
+ 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"),
@@ -67,7 +67,6 @@
dst_buf = g_new0(gdouble, 2*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"),
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 04:52:49 2008
@@ -119,36 +119,49 @@
gboolean
fre2img(fftw_complex *src_buf, gdouble *dst_buf, gint width, gint height)
{
- gint i, j;
+ gint x, y;
glong samples = width*height;
gdouble *dst_real_buf;
gdouble *dst_imag_buf;
- dst_real_buf = g_new0(gdouble, 2*width*height);
- dst_imag_buf = g_new0(gdouble, 2*width*height);
+ dst_real_buf = g_new0(gdouble, width*height);
+ dst_imag_buf = g_new0(gdouble, width*height);
- for (i=0; i<height; i++)
+ for (y=0; y<height; y++)
{
- for (j=0; j<width; j++)
+ for (x=0; x<width; x++)
{
- if (j<FFT_HALF(width))
+ if (x<FFT_HALF(width))
{
- dst_real_buf[ELEM_ID_MATRIX(j, i, width)] = src_buf[ELEM_ID_HALF_MATRIX(j, i, width)][0];
- dst_imag_buf[ELEM_ID_MATRIX(j, i, width)] = src_buf[ELEM_ID_HALF_MATRIX(j, i, 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(j, i, width)] = src_buf[fft_complex_get_half_id(j, i, width, height)][0];
- dst_imag_buf[ELEM_ID_MATRIX(j, i, width)] = 0-src_buf[fft_complex_get_half_id(j, i, 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 (i=0; i<width*height; i++)
+ for (x=0; x<width*height; x++)
{
- dst_buf[i] = sqrt(dst_real_buf[i]*dst_real_buf[i]+dst_imag_buf[i]*dst_imag_buf[i]);
+ dst_buf[x] = sqrt(dst_real_buf[x]*dst_real_buf[x]+dst_imag_buf[x]*dst_imag_buf[x]);
}
+
+#if 1
+ printf("output: width = %d, height = %d\n", FFT_HALF(width), height);
+ for (y=0; y<height; y++)
+ {
+ for (x=0; x<FFT_HALF(width); x++)
+ {
+ printf("%lf\t", src_buf[ELEM_ID_MATRIX(x, y, FFT_HALF(width))][0]);
+ }
+ printf("\n");
+ }
+#endif
+
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]