1 /*****************************************************************************
5 ** Purpose: Fourier transform functions
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: Dec 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: fourier.cpp,v 1.6 2001/03/21 21:45:31 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
33 Fourier::shuffleFourierToNaturalOrder (ImageFile& im)
35 ImageFileArray vReal = im.getArray();
36 ImageFileArray vImag = im.getImaginaryArray();
38 unsigned int nx = im.nx();
39 unsigned int ny = im.ny();
41 // shuffle each column
42 for (ix = 0; ix < nx; ix++) {
43 Fourier::shuffleFourierToNaturalOrder (vReal[ix], ny);
45 Fourier::shuffleFourierToNaturalOrder (vImag[ix], ny);
49 float* pRow = new float [nx];
50 for (iy = 0; iy < ny; iy++) {
51 for (ix = 0; ix < nx; ix++)
52 pRow[ix] = vReal[ix][iy];
53 Fourier::shuffleFourierToNaturalOrder (pRow, nx);
54 for (ix = 0; ix < nx; ix++)
55 vReal[ix][iy] = pRow[ix];
57 for (ix = 0; ix < nx; ix++)
58 pRow[ix] = vImag[ix][iy];
59 Fourier::shuffleFourierToNaturalOrder (pRow, nx);
60 for (ix = 0; ix < nx; ix++)
61 vImag[ix][iy] = pRow[ix];
68 Fourier::shuffleNaturalToFourierOrder (ImageFile& im)
70 ImageFileArray vReal = im.getArray();
71 ImageFileArray vImag = im.getImaginaryArray();
73 unsigned int nx = im.nx();
74 unsigned int ny = im.ny();
76 // shuffle each x column
77 for (ix = 0; ix < nx; ix++) {
78 Fourier::shuffleNaturalToFourierOrder (vReal[ix], ny);
80 Fourier::shuffleNaturalToFourierOrder (vImag[ix], ny);
84 float* pRow = new float [nx];
85 for (iy = 0; iy < ny; iy++) {
86 for (ix = 0; ix < nx; ix++)
87 pRow[ix] = vReal[ix][iy];
88 Fourier::shuffleNaturalToFourierOrder (pRow, nx);
89 for (ix = 0; ix < nx; ix++)
90 vReal[ix][iy] = pRow[ix];
92 for (ix = 0; ix < nx; ix++)
93 pRow[ix] = vImag[ix][iy];
94 Fourier::shuffleNaturalToFourierOrder (pRow, nx);
95 for (ix = 0; ix < nx; ix++)
96 vImag[ix][iy] = pRow[ix];