** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: projections.cpp,v 1.69 2001/03/22 02:30:00 kevin Exp $
+** $Id: projections.cpp,v 1.72 2001/03/29 21:25:49 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
*
std::complex<double>** ppcDetValue = new std::complex<double>* [m_nView];
double dInterpScale = (m_nDet-1) / static_cast<double>(iInterpDet-1) / SQRT2;
+ double dFFTScale = 1. / static_cast<double>(iInterpDet * iInterpDet);
+ int iMidPoint = iInterpDet / 2;
+ double dMidPoint = static_cast<double>(iInterpDet) / 2.;
+ int iZerosAdded = iNumInterpDetWithZeros - iInterpDet;
for (unsigned int iView = 0; iView < m_nView; iView++) {
DetectorValue* detval = getDetectorArray(iView).detValues();
LinearInterpolator<DetectorValue> projInterp (detval, 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++)
- ppcDetValue[iView][iD] = std::complex<double> (pcIn[iD].re / iInterpDet / (iInterpDet/2), pcIn[iD].im / iInterpDet / (iInterpDet/2));
+ 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);
}
if (phi < 0)
phi += TWOPI;
-
if (phi >= PI) {
phi -= PI;
r = -r;
double** ppdDet, unsigned int nView, unsigned int nDet, unsigned int nDetWithZeros, int iInterpolationID)
{
typedef std::complex<double> complexValue;
- BilinearInterpolator<complexValue> bilinear (ppcDetValue, nView, nDetWithZeros);
+
+ BilinearInterpolator<complexValue>* pBilinear;
+ if (iInterpolationID == POLAR_INTERP_BILINEAR)
+ pBilinear = new BilinearInterpolator<complexValue> (ppcDetValue, nView, nDetWithZeros);
+
+ BicubicPolyInterpolator<complexValue>* pBicubic;
+ if (iInterpolationID == POLAR_INTERP_BICUBIC)
+ pBicubic = new BicubicPolyInterpolator<complexValue> (ppcDetValue, nView, nDetWithZeros);
for (unsigned int ix = 0; ix < ny; ix++) {
for (unsigned int iy = 0; iy < ny; iy++) {
v[ix][iy] = 0;
} else if (iInterpolationID == POLAR_INTERP_BILINEAR) {
-#if 1
- std::complex<double> vInterp = bilinear.interpolate (ppdView[ix][iy], ppdDet[ix][iy]);
+ std::complex<double> vInterp = pBilinear->interpolate (ppdView[ix][iy], ppdDet[ix][iy]);
v[ix][iy] = vInterp.real();
if (vImag)
vImag[ix][iy] = vInterp.imag();
-#else
- int iFloorView = ::floor (ppdView[ix][iy]);
- double dFracView = ppdView[ix][iy] - iFloorView;
- int iFloorDet = ::floor (ppdDet[ix][iy]);
- double dFracDet = ppdDet[ix][iy] - iFloorDet;
-
- if (iFloorDet >= 0 && iFloorView >= 0) {
- std::complex<double> v1 = ppcDetValue[iFloorView][iFloorDet];
- std::complex<double> v2, v3, v4;
- if (iFloorView < nView - 1)
- v2 = ppcDetValue[iFloorView + 1][iFloorDet];
- else
- v2 = ppcDetValue[0][iFloorDet];
- if (iFloorDet < nDetWithZeros - 1)
- v4 = ppcDetValue[iFloorView][iFloorDet+1];
- else
- v4 = v1;
- if (iFloorView < nView - 1 && iFloorDet < nDetWithZeros - 1)
- v3 = ppcDetValue [iFloorView+1][iFloorDet+1];
- else if (iFloorView < nView - 1)
- v3 = v2;
- else
- v3 = ppcDetValue[0][iFloorDet+1];
-
- std::complex<double> vInterp = (1 - dFracView) * (1 - dFracDet) * v1 +
- dFracView * (1 - dFracDet) * v2 + dFracView * dFracDet * v3 +
- dFracDet * (1 - dFracView) * v4;
- v[ix][iy] = vInterp.real();
- if (vImag)
- vImag[ix][iy] = vInterp.imag();
- } else {
- // sys_error (ERR_SEVERE, "Can't find projection data for ix=%d,iy=%d with radView=%f and radDet=%f", ix, iy, ppdView[ix][iy], ppdDet[ix][iy]);
- v[ix][iy] = 0;
- if (vImag)
- vImag[ix][iy] = 0;
- }
-#endif
} else if (iInterpolationID == POLAR_INTERP_BICUBIC) {
- v[ix][iy] =0;
- if (vImag)
- vImag[ix][iy] = 0;
+ std::complex<double> vInterp = pBicubic->interpolate (ppdView[ix][iy], ppdDet[ix][iy]);
+ v[ix][iy] = vInterp.real();
+ if (vImag)
+ vImag[ix][iy] = vInterp.imag();
}
}
}