** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: projections.cpp,v 1.68 2001/03/21 21:45:31 kevin Exp $
+** $Id: projections.cpp,v 1.70 2001/03/24 05:28:28 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
double** ppdView = adView.getArray();
double** ppdDet = adDet.getArray();
- std::complex<double>** ppcDetValue = new std::complex<double>* [m_nView];
+ std::complex<double>** ppcDetValue = new std::complex<double>* [pProj->m_nView];
unsigned int iView;
- for (iView = 0; iView < m_nView; iView++) {
- ppcDetValue[iView] = new std::complex<double> [m_nDet];
+ for (iView = 0; iView < pProj->m_nView; iView++) {
+ ppcDetValue[iView] = new std::complex<double> [pProj->m_nDet];
DetectorValue* detval = pProj->getDetectorArray (iView).detValues();
- for (unsigned int iDet = 0; iDet < m_nDet; iDet++)
+ for (unsigned int iDet = 0; iDet < pProj->m_nDet; iDet++)
ppcDetValue[iView][iDet] = std::complex<double>(detval[iDet], 0);
}
- pProj->calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet, m_nDet, 1., m_detInc);
+ pProj->calcArrayPolarCoordinates (nx, ny, ppdView, ppdDet, pProj->m_nDet, 1., pProj->m_detInc);
pProj->interpolatePolar (v, vImag, nx, ny, ppcDetValue, ppdView, ppdDet, pProj->m_nView, pProj->m_nDet,
pProj->m_nDet, iInterpolationID);
- for (iView = 0; iView < m_nView; iView++)
+ for (iView = 0; iView < pProj->m_nView; iView++)
delete [] ppcDetValue[iView];
delete [] ppcDetValue;
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);
+ dFFTScale /= 2; // Not sure why this scaling is necessary
for (unsigned int iView = 0; iView < m_nView; iView++) {
DetectorValue* detval = getDetectorArray(iView).detValues();
LinearInterpolator<DetectorValue> projInterp (detval, m_nDet);
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));
+ 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();
}
}
}
int iLastFloor = -1;
for (int iV = 0; iV < pProjNew->nView(); iV++, dViewAngle += pProjNew->m_rotInc) {
DetectorValue* detValues = pProjNew->getDetectorArray (iV).detValues();
- LinearInterpolator<double> interp (pdThetaValuesForT, pdRaysumsForT, pProjNew->nView());
+ LinearInterpolator<double> interp (pdThetaValuesForT, pdRaysumsForT, pProjNew->nView(), false);
detValues[iD] = interp.interpolate (dViewAngle, &iLastFloor);
}
}
detArray.setViewAngle (dViewAngle);
for (int i = 0; i < pProjNew->nDet(); i++)
- pdDetValueCopy[i] = detValues[i];
+ pdDetValueCopy[i] = detValues[i];
double dDetPos = pProjNew->m_detStart;
int iLastFloor = -1;
- LinearInterpolator<double> interp (pdOriginalDetPositions, pdDetValueCopy, pProjNew->nDet());
+ LinearInterpolator<double> interp (pdOriginalDetPositions, pdDetValueCopy, pProjNew->nDet(), false);
for (int iD = 0; iD < pProjNew->nDet(); iD++, dDetPos += pProjNew->m_detInc)
detValues[iD] = interp.interpolate (dDetPos, &iLastFloor);
}