** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: projections.cpp,v 1.70 2001/03/24 05:28:28 kevin Exp $
+** $Id: projections.cpp,v 1.73 2001/03/30 19:17:32 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
const int Projections::s_iInterpCount = sizeof(s_aszInterpName) / sizeof(char*);
+
/* NAME
* Projections Constructor for projections matrix storage
*
if (! v || nx == 0 || ny == 0)
return false;
- if (m_geometry != Scanner::GEOMETRY_PARALLEL) {
- sys_error (ERR_WARNING, "convertFFTPolar supports Parallel only");
- return false;
- }
+ Projections* pProj = this;
+ if (m_geometry == Scanner::GEOMETRY_EQUIANGULAR || m_geometry == Scanner::GEOMETRY_EQUILINEAR)
+ pProj = interpolateToParallel();
int iInterpDet = nx;
+// int iInterpDet = pProj->m_nDet;
int iNumInterpDetWithZeros = ProcessSignal::addZeropadFactor (iInterpDet, iZeropad);
double dZeropadRatio = static_cast<double>(iNumInterpDetWithZeros) / static_cast<double>(iInterpDet);
fftw_plan plan = fftw_create_plan (iNumInterpDetWithZeros, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM);
fftw_complex* pcIn = new fftw_complex [iNumInterpDetWithZeros];
- std::complex<double>** ppcDetValue = new std::complex<double>* [m_nView];
- double dInterpScale = (m_nDet-1) / static_cast<double>(iInterpDet-1) / SQRT2;
+ std::complex<double>** ppcDetValue = new std::complex<double>* [pProj->m_nView];
+ double dInterpScale = (pProj->m_nDet-1) / static_cast<double>(iInterpDet-1) / SQRT2;
double dFFTScale = 1. / static_cast<double>(iInterpDet * iInterpDet);
- dFFTScale /= 2; // Not sure why this scaling is necessary
+ int iMidPoint = iInterpDet / 2;
+ double dMidPoint = static_cast<double>(iInterpDet) / 2.;
+ int iZerosAdded = iNumInterpDetWithZeros - iInterpDet;
+
+ // For each view, interpolate to nx length, shift to center at origin, and FFt transform
for (unsigned int iView = 0; iView < m_nView; iView++) {
- DetectorValue* detval = getDetectorArray(iView).detValues();
- LinearInterpolator<DetectorValue> projInterp (detval, m_nDet);
+ DetectorValue* detval = pProj->getDetectorArray(iView).detValues();
+ LinearInterpolator<DetectorValue> projInterp (detval, pProj->m_nDet);
for (unsigned int iDet = 0; iDet < iInterpDet; iDet++) {
-// double dInterpPos = iInterpDet * dInterpScale;
- double dInterpPos = (m_nDet / 2.) + (iDet - iInterpDet/2.) * dInterpScale;
- pcIn[iDet].re = projInterp.interpolate (dInterpPos);
+ double dInterpPos = (m_nDet / 2.) + (iDet - dMidPoint) * dInterpScale;
+ pcIn[iDet].re = projInterp.interpolate (dInterpPos) * dInterpScale;
pcIn[iDet].im = 0;
}
- for (unsigned int iDet2 = iInterpDet; iDet2 < iNumInterpDetWithZeros; iDet2++)
- pcIn[iDet2].re = pcIn[iDet2].im = 0;
+
+ Fourier::shuffleFourierToNaturalOrder (pcIn, iInterpDet);
+ if (iZerosAdded > 0) {
+ for (unsigned int iDet1 = iMidPoint; iDet1 < iInterpDet; iDet1++)
+ pcIn[iDet1+iZerosAdded] = pcIn[iDet1];
+ for (unsigned int iDet2 = iMidPoint; iDet2 < iMidPoint + iZerosAdded; iDet2++)
+ pcIn[iDet2].re = pcIn[iDet2].im = 0;
+ }
fftw_one (plan, pcIn, NULL);
ppcDetValue[iView] = new std::complex<double> [iNumInterpDetWithZeros];
- for (unsigned int iD = 0; iD < iNumInterpDetWithZeros; iD++)
+ for (unsigned int iD = 0; iD < iNumInterpDetWithZeros; iD++) {
ppcDetValue[iView][iD] = std::complex<double> (pcIn[iD].re * dFFTScale, pcIn[iD].im * dFFTScale);
+ }
Fourier::shuffleFourierToNaturalOrder (ppcDetValue[iView], iNumInterpDetWithZeros);
}
Array2d<double> adDet (nx, ny);
double** ppdView = adView.getArray();
double** ppdDet = adDet.getArray();
- calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet, iNumInterpDetWithZeros, dZeropadRatio,
- m_detInc * dInterpScale);
+ pProj->calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet, iNumInterpDetWithZeros, dZeropadRatio,
+ pProj->m_detInc * dInterpScale);
- interpolatePolar (v, vImag, nx, ny, ppcDetValue, ppdView, ppdDet, m_nView, m_nDet, iNumInterpDetWithZeros,
- iInterpolationID);
+ pProj->interpolatePolar (v, vImag, nx, ny, ppcDetValue, ppdView, ppdDet, pProj->m_nView, pProj->m_nDet,
+ iNumInterpDetWithZeros, iInterpolationID);
+
+ if (m_geometry == Scanner::GEOMETRY_EQUIANGULAR || m_geometry == Scanner::GEOMETRY_EQUILINEAR)
+ delete pProj;
for (int i = 0; i < m_nView; i++)
delete [] ppcDetValue[i];