** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: imagefile.cpp,v 1.29 2001/01/02 05:34:57 kevin Exp $
+** $Id: imagefile.cpp,v 1.30 2001/01/02 07:18:07 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
{\r
ImageFileArray v = getArray();\r
SignalFilter filter (filterName, domainName, bw, filt_param);\r
-\r
+ \r
#if 1\r
int iXCenter, iYCenter;\r
if (isEven (m_nx))\r
iYCenter = m_ny / 2;\r
else\r
iYCenter = (m_ny - 1) / 2;\r
-\r
- for (int ix = 0; ix < m_nx; ix++)\r
- for (int iy = 0; iy < m_ny; iy++) {\r
+ \r
+ for (unsigned int ix = 0; ix < m_nx; ix++)\r
+ for (unsigned int iy = 0; iy < m_ny; iy++) {\r
long lD2 = ((ix - iXCenter) * (ix - iXCenter)) + ((iy - iYCenter) * (iy - iYCenter));\r
double r = ::sqrt (static_cast<double>(lD2)) * dInputScale;\r
v[ix][iy] = filter.response (r) * dOutputScale;\r
}\r
#else
- int hx = (m_nx - 1) / 2;
- int hy = (m_ny - 1) / 2;
-
- for (int i = -hx; i <= hx; i++) {
- for (int j = -hy; j <= hy; j++) {
- double r = ::sqrt (i * i + j * j);
-
- v[i+hx][j+hy] = filter.response (r);
- }
- }\r
+ int hx = (m_nx - 1) / 2;
+ int hy = (m_ny - 1) / 2;
+
+ for (int i = -hx; i <= hx; i++) {
+ for (int j = -hy; j <= hy; j++) {
+ double r = ::sqrt (i * i + j * j);
+
+ v[i+hx][j+hy] = filter.response (r);
+ }
+ }\r
#endif
}
\r
if (isComplex() || rRHS.isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArrayConst vRHS = rRHS.getArray();\r
}\r
}\r
}\r
- \r
+ \r
return true;\r
}\r
\r
if (isComplex() || rRHS.isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArrayConst vRHS = rRHS.getArray();\r
\r
if (isComplex() || rRHS.isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArrayConst vRHS = rRHS.getArray();\r
for (unsigned int ix = 0; ix < m_nx; ix++) {\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
+ double dImag = 0;\r
if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
- std::complex<double> cRHS (vRHS[ix][iy], 0);\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
+ dImag = 0;\r
if (rRHS.isComplex())\r
- cRHS.imag (vRHSImag[ix][iy]);\r
+ dImag = vRHSImag[ix][iy];\r
+ std::complex<double> cRHS (vRHS[ix][iy], dImag);\r
std::complex<double> cResult = cLHS * cRHS;\r
vResult[ix][iy] = cResult.real();\r
vResultImag[ix][iy] = cResult.imag();\r
\r
if (isComplex() || rRHS.isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArrayConst vRHS = rRHS.getArray();\r
for (unsigned int ix = 0; ix < m_nx; ix++) {\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
+ double dImag = 0;\r
if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
- std::complex<double> cRHS (vRHS[ix][iy], 0);\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
+ dImag = 0;\r
if (rRHS.isComplex())\r
- cRHS.imag (vRHSImag[ix][iy]);\r
+ dImag = vRHSImag[ix][iy];\r
+ std::complex<double> cRHS (vRHS[ix][iy], dImag);\r
std::complex<double> cResult = cLHS / cRHS;\r
vResult[ix][iy] = cResult.real();\r
vResultImag[ix][iy] = cResult.imag();\r
}\r
}\r
\r
- \r
return true;\r
}\r
\r
\r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArray vResult = result.getArray();\r
\r
sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
return false;\r
}\r
-\r
+ \r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
\r
bComplexOutput = true;\r
break;\r
}\r
-\r
- ImageFileArrayConst vLHSImag = getImaginaryArray();\r
- ImageFileArray vResult = result.getArray();\r
- ImageFileArray vResultImag = result.getImaginaryArray();\r
- \r
- for (unsigned int ix = 0; ix < m_nx; ix++) {\r
- for (unsigned int iy = 0; iy < m_ny; iy++) {\r
- if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
- if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
- std::complex<double> cResult = std::sqrt(cLHS);\r
- vResult[ix][iy] = cResult.real();\r
- vResultImag[ix][iy] = cResult.imag();\r
- } else\r
- vResult[ix][iy] = ::sqrt (vLHS[ix][iy]);\r
- }\r
- }\r
- \r
- \r
- return true;\r
+ \r
+ ImageFileArrayConst vLHSImag = getImaginaryArray();\r
+ ImageFileArray vResult = result.getArray();\r
+ ImageFileArray vResultImag = result.getImaginaryArray();\r
+ \r
+ for (unsigned int ix = 0; ix < m_nx; ix++) {\r
+ for (unsigned int iy = 0; iy < m_ny; iy++) {\r
+ if (result.isComplex()) {\r
+ double dImag = 0;\r
+ if (isComplex())\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
+ std::complex<double> cResult = std::sqrt(cLHS);\r
+ vResult[ix][iy] = cResult.real();\r
+ vResultImag[ix][iy] = cResult.imag();\r
+ } else\r
+ vResult[ix][iy] = ::sqrt (vLHS[ix][iy]);\r
+ }\r
+ }\r
+ \r
+ \r
+ return true;\r
}\r
\r
bool\r
\r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArray vResult = result.getArray();\r
for (unsigned int ix = 0; ix < m_nx; ix++) {\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
+ double dImag = 0;\r
if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
std::complex<double> cResult = std::log (cLHS);\r
vResult[ix][iy] = cResult.real();\r
vResultImag[ix][iy] = cResult.imag();\r
sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
return false;\r
}\r
- \r
+ \r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArray vResult = result.getArray();\r
for (unsigned int ix = 0; ix < m_nx; ix++) {\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
+ double dImag = 0;\r
if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
std::complex<double> cResult = std::exp (cLHS);\r
vResult[ix][iy] = cResult.real();\r
vResultImag[ix][iy] = cResult.imag();\r
unsigned int ny = m_ny;\r
unsigned int newNX = result.nx();\r
unsigned int newNY = result.ny();\r
-\r
+ \r
double dXScale = static_cast<double>(newNX) / static_cast<double>(nx);\r
double dYScale = static_cast<double>(newNY) / static_cast<double>(ny);\r
-\r
+ \r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vReal = getArray();\r
ImageFileArrayConst vImag = getImaginaryArray();\r
ImageFileArray vResult = result.getArray();\r
\r
for (unsigned int ix = 0; ix < newNX; ix++) {\r
for (unsigned int iy = 0; iy < newNY; iy++) {\r
- unsigned int scaleNX = static_cast<unsigned int> (ix / dXScale);\r
- unsigned int scaleNY = static_cast<unsigned int> (iy / dYScale);\r
- vResult[ix][iy] = vReal[scaleNX][scaleNY];\r
- if (result.isComplex()) {\r
- if (isComplex())\r
- vResultImag[ix][iy] = vImag[scaleNX][scaleNY];\r
- else\r
- vResultImag[ix][iy] = 0;\r
+ double dXPos = ix / dXScale;\r
+ double dYPos = iy / dYScale;\r
+ unsigned int scaleNX = static_cast<unsigned int> (dXPos);\r
+ unsigned int scaleNY = static_cast<unsigned int> (dYPos);\r
+ double dXFrac = dXPos - scaleNX;\r
+ double dYFrac = dYPos - scaleNY;\r
+ if (scaleNX >= nx - 1 || scaleNY >= ny - 1) {\r
+ vResult[ix][iy] = vReal[scaleNX][scaleNY];\r
+ if (result.isComplex()) {\r
+ if (isComplex())\r
+ vResultImag[ix][iy] = vImag[scaleNX][scaleNY];\r
+ else\r
+ vResultImag[ix][iy] = 0;\r
+ }\r
+ } else {\r
+ vResult[ix][iy] = vReal[scaleNX][scaleNY] + \r
+ dXFrac * (vReal[scaleNX+1][scaleNY] - vReal[scaleNX][scaleNY]) + \r
+ dYFrac * (vReal[scaleNX][scaleNY+1] - vReal[scaleNX][scaleNY]);\r
+ if (result.isComplex()) {\r
+ if (isComplex())\r
+ vResultImag[ix][iy] = vImag[scaleNX][scaleNY] + \r
+ dXFrac * (vImag[scaleNX+1][scaleNY] - vImag[scaleNX][scaleNY]) + \r
+ dYFrac * (vImag[scaleNX][scaleNY+1] - vImag[scaleNX][scaleNY]);\r
+ else\r
+ vResultImag[ix][iy] = 0;\r
+ }\r
}\r
}\r
}\r
sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
return false;\r
}\r
-\r
+ \r
if (result.dataType() == Array2dFile::DATA_TYPE_REAL) {\r
if (! result.convertRealToComplex ())\r
return false;\r
}\r
-\r
+ \r
fftw_complex* in = new fftw_complex [m_nx * m_ny];\r
-\r
+ \r
ImageFileArrayConst vReal = getArray();\r
ImageFileArrayConst vImag = getImaginaryArray();\r
-\r
+ \r
unsigned int ix, iy;\r
unsigned int iArray = 0;\r
for (ix = 0; ix < m_nx; ix++)\r
in[iArray].im = 0;\r
iArray++;\r
}\r
-\r
- fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_FORWARD, FFTW_IN_PLACE);\r
-\r
- fftwnd_one (plan, in, NULL);\r
-\r
- ImageFileArray vRealResult = result.getArray();\r
- ImageFileArray vImagResult = result.getImaginaryArray();\r
- iArray = 0;\r
- unsigned int iScale = m_nx * m_ny;\r
- for (ix = 0; ix < m_nx; ix++)\r
- for (iy = 0; iy < m_ny; iy++) {\r
- vRealResult[ix][iy] = in[iArray].re / iScale;\r
- vImagResult[ix][iy] = in[iArray].im / iScale;\r
- iArray++;\r
- }\r
-\r
- fftwnd_destroy_plan (plan);\r
- delete in;\r
-\r
-\r
- Fourier::shuffleFourierToNaturalOrder (result);\r
-\r
- return true;\r
+ \r
+ fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_FORWARD, FFTW_IN_PLACE);\r
+ \r
+ fftwnd_one (plan, in, NULL);\r
+ \r
+ ImageFileArray vRealResult = result.getArray();\r
+ ImageFileArray vImagResult = result.getImaginaryArray();\r
+ iArray = 0;\r
+ unsigned int iScale = m_nx * m_ny;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ vRealResult[ix][iy] = in[iArray].re / iScale;\r
+ vImagResult[ix][iy] = in[iArray].im / iScale;\r
+ iArray++;\r
+ }\r
+ \r
+ fftwnd_destroy_plan (plan);\r
+ delete in;\r
+ \r
+ \r
+ Fourier::shuffleFourierToNaturalOrder (result);\r
+ \r
+ return true;\r
}\r
\r
\r
sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
return false;\r
}\r
-\r
+ \r
if (result.dataType() == Array2dFile::DATA_TYPE_REAL) {\r
if (! result.convertRealToComplex ())\r
return false;\r
}\r
-\r
+ \r
ImageFileArrayConst vReal = getArray();\r
ImageFileArrayConst vImag = getImaginaryArray();\r
ImageFileArray vRealResult = result.getArray();\r
else\r
vImagResult[ix][iy] = 0;\r
}\r
-\r
- Fourier::shuffleNaturalToFourierOrder (result);\r
-\r
- fftw_complex* in = new fftw_complex [m_nx * m_ny];\r
-\r
- unsigned int iArray = 0;\r
- for (ix = 0; ix < m_nx; ix++)\r
- for (iy = 0; iy < m_ny; iy++) {\r
- in[iArray].re = vRealResult[ix][iy];\r
- in[iArray].im = vImagResult[ix][iy];\r
- iArray++;\r
- }\r
-\r
- fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_BACKWARD, FFTW_IN_PLACE);\r
-\r
- fftwnd_one (plan, in, NULL);\r
-\r
- iArray = 0;\r
- for (ix = 0; ix < m_nx; ix++)\r
- for (iy = 0; iy < m_ny; iy++) {\r
- vRealResult[ix][iy] = in[iArray].re;\r
- vImagResult[ix][iy] = in[iArray].im;\r
- iArray++;\r
- }\r
-\r
- fftwnd_destroy_plan (plan);\r
-\r
- delete in;\r
-\r
- return true;\r
+ \r
+ Fourier::shuffleNaturalToFourierOrder (result);\r
+ \r
+ fftw_complex* in = new fftw_complex [m_nx * m_ny];\r
+ \r
+ unsigned int iArray = 0;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ in[iArray].re = vRealResult[ix][iy];\r
+ in[iArray].im = vImagResult[ix][iy];\r
+ iArray++;\r
+ }\r
+ \r
+ fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_BACKWARD, FFTW_IN_PLACE);\r
+ \r
+ fftwnd_one (plan, in, NULL);\r
+ \r
+ iArray = 0;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ vRealResult[ix][iy] = in[iArray].re;\r
+ vImagResult[ix][iy] = in[iArray].im;\r
+ iArray++;\r
+ }\r
+ \r
+ fftwnd_destroy_plan (plan);\r
+ \r
+ delete in;\r
+ \r
+ return true;\r
}\r
#endif // HAVE_FFTW\r
\r
\r
- \r
+\r
bool\r
ImageFile::fourier (ImageFile& result) const\r
{\r
if (! result.isComplex())\r
if (! result.convertRealToComplex ())\r
return false;\r
- \r
- ImageFileArrayConst vLHS = getArray();\r
- ImageFileArrayConst vLHSImag = getImaginaryArray();\r
- ImageFileArray vRealResult = result.getArray();\r
- ImageFileArray vImagResult = result.getImaginaryArray();\r
- \r
- unsigned int ix, iy;\r
-\r
- // alloc output matrix\r
- CTSimComplex** complexOut = new CTSimComplex* [m_nx];\r
- for (ix = 0; ix < m_nx; ix++)\r
- complexOut[ix] = new CTSimComplex [m_ny];\r
- \r
- // fourier each x column\r
+ \r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArrayConst vLHSImag = getImaginaryArray();\r
+ ImageFileArray vRealResult = result.getArray();\r
+ ImageFileArray vImagResult = result.getImaginaryArray();\r
+ \r
+ unsigned int ix, iy;\r
+ \r
+ // alloc output matrix\r
+ CTSimComplex** complexOut = new CTSimComplex* [m_nx];\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix] = new CTSimComplex [m_ny];\r
+ \r
+ // fourier each x column\r
#if 1\r
- CTSimComplex* pY = new CTSimComplex [m_ny];\r
- for (ix = 0; ix < m_nx; ix++) {\r
- for (iy = 0; iy < m_ny; iy++) {\r
- pY[iy].real (vLHS[ix][iy]);\r
- if (isComplex())\r
- pY[iy].imag (vLHSImag[ix][iy]);\r
- else\r
- pY[iy].imag (0);\r
- } \r
- ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
- }\r
+ CTSimComplex* pY = new CTSimComplex [m_ny];\r
+ for (ix = 0; ix < m_nx; ix++) {\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ double dImag = 0;\r
+ if (isComplex())\r
+ dImag = vLHSImag[ix][iy];\r
+ pY[iy] = complex<double>(vLHS[ix][iy], dImag);\r
+ } \r
+ ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
+ }\r
#else\r
- double* pY = new double [m_ny];\r
- for (ix = 0; ix < m_nx; ix++) {\r
- for (iy = 0; iy < m_ny; iy++) {\r
- pY[iy] = vLHS[ix][iy];\r
- } \r
- ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
- }\r
+ double* pY = new double [m_ny];\r
+ for (ix = 0; ix < m_nx; ix++) {\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ pY[iy] = vLHS[ix][iy];\r
+ } \r
+ ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
+ }\r
#endif\r
- delete [] pY;\r
- \r
- // fourier each y row\r
- CTSimComplex* pX = new CTSimComplex [m_nx];\r
- CTSimComplex* complexOutRow = new CTSimComplex [m_nx];\r
- for (iy = 0; iy < m_ny; iy++) {\r
- for (ix = 0; ix < m_nx; ix++)\r
- pX[ix] = complexOut[ix][iy];\r
- ProcessSignal::finiteFourierTransform (pX, complexOutRow, m_nx, ProcessSignal::FORWARD);\r
- for (ix = 0; ix < m_nx; ix++)\r
- complexOut[ix][iy] = complexOutRow[ix];\r
- }\r
- delete [] pX;\r
- delete [] complexOutRow;\r
-\r
- for (ix = 0; ix < m_nx; ix++)\r
+ delete [] pY;\r
+ \r
+ // fourier each y row\r
+ CTSimComplex* pX = new CTSimComplex [m_nx];\r
+ CTSimComplex* complexOutRow = new CTSimComplex [m_nx];\r
for (iy = 0; iy < m_ny; iy++) {\r
- vRealResult[ix][iy] = complexOut[ix][iy].real();\r
- vImagResult[ix][iy] = complexOut[ix][iy].imag();\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ pX[ix] = complexOut[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (pX, complexOutRow, m_nx, ProcessSignal::FORWARD);\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutRow[ix];\r
}\r
+ delete [] pX;\r
+ delete [] complexOutRow;\r
\r
- Fourier::shuffleFourierToNaturalOrder (result);\r
-\r
- // delete complexOut matrix\r
- for (ix = 0; ix < m_nx; ix++)\r
- delete [] complexOut[ix];\r
- delete [] complexOut;\r
- \r
- return true;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ vRealResult[ix][iy] = complexOut[ix][iy].real();\r
+ vImagResult[ix][iy] = complexOut[ix][iy].imag();\r
+ }\r
+ \r
+ Fourier::shuffleFourierToNaturalOrder (result);\r
+ \r
+ // delete complexOut matrix\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ delete [] complexOut[ix];\r
+ delete [] complexOut;\r
+ \r
+ return true;\r
}\r
\r
bool\r
CTSimComplex** complexOut = new CTSimComplex* [m_nx];\r
for (ix = 0; ix < m_nx; ix++)\r
complexOut[ix] = new CTSimComplex [m_ny];\r
-\r
+ \r
// put input image into result\r
for (ix = 0; ix < m_nx; ix++)\r
for (iy = 0; iy < m_ny; iy++) {\r
else\r
vImagResult[ix][iy] = 0;\r
}\r
-\r
- Fourier::shuffleNaturalToFourierOrder (result);\r
-\r
- // ifourier each x column\r
- CTSimComplex* pCol = new CTSimComplex [m_ny];\r
- for (ix = 0; ix < m_nx; ix++) {\r
- for (iy = 0; iy < m_ny; iy++) {\r
- pCol[iy].real (vRealResult[ix][iy]);\r
- pCol[iy].imag (vImagResult[ix][iy]);\r
+ \r
+ Fourier::shuffleNaturalToFourierOrder (result);\r
+ \r
+ // ifourier each x column\r
+ CTSimComplex* pCol = new CTSimComplex [m_ny];\r
+ for (ix = 0; ix < m_nx; ix++) {\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ pCol[iy] = std::complex<double> (vRealResult[ix][iy], vImagResult[ix][iy]);\r
+ }\r
+ ProcessSignal::finiteFourierTransform (pCol, complexOut[ix], m_ny, ProcessSignal::BACKWARD);\r
}\r
- ProcessSignal::finiteFourierTransform (pCol, complexOut[ix], m_ny, ProcessSignal::BACKWARD);\r
- }\r
- delete [] pCol;\r
-\r
- // ifourier each y row\r
- CTSimComplex* complexInRow = new CTSimComplex [m_nx];\r
- CTSimComplex* complexOutRow = new CTSimComplex [m_nx];\r
- for (iy = 0; iy < m_ny; iy++) {\r
- for (ix = 0; ix < m_nx; ix++)\r
- complexInRow[ix] = complexOut[ix][iy];\r
- ProcessSignal::finiteFourierTransform (complexInRow, complexOutRow, m_nx, ProcessSignal::BACKWARD);\r
- for (ix = 0; ix < m_nx; ix++)\r
- complexOut[ix][iy] = complexOutRow[ix];\r
- }\r
- delete [] complexInRow;\r
- delete [] complexOutRow;\r
-\r
- for (ix = 0; ix < m_nx; ix++)\r
+ delete [] pCol;\r
+ \r
+ // ifourier each y row\r
+ CTSimComplex* complexInRow = new CTSimComplex [m_nx];\r
+ CTSimComplex* complexOutRow = new CTSimComplex [m_nx];\r
for (iy = 0; iy < m_ny; iy++) {\r
- vRealResult[ix][iy] = complexOut[ix][iy].real();\r
- vImagResult[ix][iy] = complexOut[ix][iy].imag();\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexInRow[ix] = complexOut[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (complexInRow, complexOutRow, m_nx, ProcessSignal::BACKWARD);\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutRow[ix];\r
}\r
+ delete [] complexInRow;\r
+ delete [] complexOutRow;\r
\r
- // delete complexOut matrix\r
- for (ix = 0; ix < m_nx; ix++)\r
- delete [] complexOut[ix];\r
- delete [] complexOut;\r
- \r
- return true;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ vRealResult[ix][iy] = complexOut[ix][iy].real();\r
+ vImagResult[ix][iy] = complexOut[ix][iy].imag();\r
+ }\r
+ \r
+ // delete complexOut matrix\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ delete [] complexOut[ix];\r
+ delete [] complexOut;\r
+ \r
+ return true;\r
}\r
\r
\r
ImageFileArray vReal = getArray();\r
ImageFileArray vImag = getImaginaryArray();\r
ImageFileArray vRealResult = result.getArray();\r
-\r
+ \r
for (unsigned int ix = 0; ix < m_nx; ix++)\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (isComplex()) \r
else\r
vRealResult[ix][iy] = vReal[ix][iy];\r
}\r
-\r
- if (result.isComplex())\r
- result.convertComplexToReal();\r
- \r
+ \r
+ if (result.isComplex())\r
+ result.convertComplexToReal();\r
+ \r
return true;\r
}\r
\r
ImageFileArray vReal = getArray();\r
ImageFileArray vImag = getImaginaryArray();\r
ImageFileArray vRealResult = result.getArray();\r
-\r
+ \r
for (unsigned int ix = 0; ix < m_nx; ix++)\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (isComplex())\r
vRealResult[ix][iy] = 0;\r
}\r
\r
- if (result.isComplex())\r
- result.convertComplexToReal();\r
- \r
- return true;\r
+ if (result.isComplex())\r
+ result.convertComplexToReal();\r
+ \r
+ return true;\r
}\r
\r
bool\r
\r
if (isComplex() && ! result.isComplex())\r
result.convertRealToComplex();\r
-\r
+ \r
ImageFileArrayConst vLHS = getArray();\r
ImageFileArrayConst vLHSImag = getImaginaryArray();\r
ImageFileArray vResult = result.getArray();\r
for (unsigned int ix = 0; ix < m_nx; ix++) {\r
for (unsigned int iy = 0; iy < m_ny; iy++) {\r
if (result.isComplex()) {\r
- std::complex<double> cLHS (vLHS[ix][iy], 0);\r
+ double dImag = 0;\r
if (isComplex())\r
- cLHS.imag (vLHSImag[ix][iy]);\r
+ dImag = vLHSImag[ix][iy];\r
+ std::complex<double> cLHS (vLHS[ix][iy], dImag);\r
std::complex<double> cResult = cLHS * cLHS;\r
vResult[ix][iy] = cResult.real();\r
vResultImag[ix][iy] = cResult.imag();\r
ImageFile::convertFormatNameToID (const char* const formatName)\r
{\r
int formatID = FORMAT_INVALID;\r
-\r
+ \r
for (int i = 0; i < s_iFormatCount; i++)\r
- if (strcasecmp (formatName, s_aszFormatName[i]) == 0) {\r
- formatID = i;\r
- break;\r
- }\r
-\r
- return (formatID);\r
+ if (strcasecmp (formatName, s_aszFormatName[i]) == 0) {\r
+ formatID = i;\r
+ break;\r
+ }\r
+ \r
+ return (formatID);\r
}\r
\r
const char*\r
ImageFile::convertFormatIDToName (int formatID)\r
{\r
static const char *formatName = "";\r
-\r
+ \r
if (formatID >= 0 && formatID < s_iFormatCount)\r
- return (s_aszFormatName[formatID]);\r
-\r
+ return (s_aszFormatName[formatID]);\r
+ \r
return (formatName);\r
}\r
\r
ImageFile::convertFormatIDToTitle (const int formatID)\r
{\r
static const char *formatTitle = "";\r
-\r
+ \r
if (formatID >= 0 && formatID < s_iFormatCount)\r
- return (s_aszFormatTitle[formatID]);\r
-\r
+ return (s_aszFormatTitle[formatID]);\r
+ \r
return (formatTitle);\r
}\r
\r
sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat);\r
return false;\r
}\r
-\r
+ \r
if (iFormatID == FORMAT_PGM)\r
return writeImagePGM (pszFilename, nxcell, nycell, densmin, densmax);\r
else if (iFormatID == FORMAT_PGMASCII)\r
return writeImagePNG (pszFilename, 8, nxcell, nycell, densmin, densmax);\r
else if (iFormatID == FORMAT_PNG16)\r
return writeImagePNG (pszFilename, 16, nxcell, nycell, densmin, densmax);\r
-\r
+ \r
sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat);\r
return false;\r
}\r
\r
delete rowp;
fclose(fp);\r
-\r
+ \r
return true;
}
\r
delete rowp;
fclose(fp);\r
-\r
+ \r
return true;
}
delete rowp;\r
fclose(fp);\r
-\r
+ \r
return true;
}
#endif
gdImageGif(gif,out);
fclose(out);
gdImageDestroy(gif);\r
-\r
+ \r
delete rowp;\r
-\r
+ \r
return true;
}
#endif