initBackprojector (proj, im, backprojName, interpName, interpFactor);
}
initBackprojector (proj, im, backprojName, interpName, interpFactor);
}
- if (m_idBackproject == BPROJ_TRIG)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectTrig (proj, im, m_idInterpolation, interpFactor));
- else if (m_idBackproject == BPROJ_TABLE)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectTable (proj, im, m_idInterpolation, interpFactor));
- else if (m_idBackproject == BPROJ_DIFF)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectDiff (proj, im, m_idInterpolation, interpFactor));
- else if (m_idBackproject == BPROJ_DIFF2)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectDiff2 (proj, im, m_idInterpolation, interpFactor));
- else if (m_idBackproject == BPROJ_IDIFF2)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectIntDiff2 (proj, im, m_idInterpolation, interpFactor));
- else if (m_idBackproject == BPROJ_IDIFF3)
- m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectIntDiff3 (proj, im, m_idInterpolation, interpFactor));
+ if (m_idBackproject == BPROJ_TRIG)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectTrig (proj, im, m_idInterpolation, interpFactor));
+ else if (m_idBackproject == BPROJ_TABLE)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectTable (proj, im, m_idInterpolation, interpFactor));
+ else if (m_idBackproject == BPROJ_DIFF)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectDiff (proj, im, m_idInterpolation, interpFactor));
+ else if (m_idBackproject == BPROJ_DIFF2)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectDiff2 (proj, im, m_idInterpolation, interpFactor));
+ else if (m_idBackproject == BPROJ_IDIFF2)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectIntDiff2 (proj, im, m_idInterpolation, interpFactor));
+ else if (m_idBackproject == BPROJ_IDIFF3)
+ m_pBackprojectImplem = static_cast<Backproject*>(new BackprojectIntDiff3 (proj, im, m_idInterpolation, interpFactor));
// Pure virtual base class for all backprojectors.
Backproject::Backproject (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
// Pure virtual base class for all backprojectors.
Backproject::Backproject (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
xMin = -proj.phmLen() / 2; // Retangular coords of phantom
xMax = xMin + proj.phmLen();
yMin = -proj.phmLen() / 2;
yMax = yMin + proj.phmLen();
xMin = -proj.phmLen() / 2; // Retangular coords of phantom
xMax = xMin + proj.phmLen();
yMin = -proj.phmLen() / 2;
yMax = yMin + proj.phmLen();
void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int iDetPos)
{
void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int iDetPos)
{
- sys_error (ERR_WARNING, "r=%f, phi=%f", r, phi);
- errorIndexOutsideDetector (ix, iy, theta, L, iDetPos);
+ sys_error (ERR_WARNING, "r=%f, phi=%f", r, phi);
+ errorIndexOutsideDetector (ix, iy, theta, L, iDetPos);
}
void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int iDetPos)
}
void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int iDetPos)
os << "xMin=" << xMin << ", xMax=" << xMax << ", xInc=" << xInc << "\n";
os << "yMin=" << yMin << ", yMax=" << yMax << ", yInc=" << yInc << "\n";
os << "iDetPos index outside bounds: " << iDetPos << " [backprojector]";;
os << "xMin=" << xMin << ", xMax=" << xMax << ", xInc=" << xInc << "\n";
os << "yMin=" << yMin << ", yMax=" << yMax << ", yInc=" << yInc << "\n";
os << "iDetPos index outside bounds: " << iDetPos << " [backprojector]";;
double x = xMin + xInc / 2; // Rectang coords of center of pixel
for (int ix = 0; ix < nx; x += xInc, ix++) {
double y = yMin + yInc / 2;
double x = xMin + xInc / 2; // Rectang coords of center of pixel
for (int ix = 0; ix < nx; x += xInc, ix++) {
double y = yMin + yInc / 2;
double r = sqrt (x * x + y * y); // distance of cell from center
double phi = atan2 (y, x); // angle of cell from center
double L = r * cos (theta - phi); // position on detector
double r = sqrt (x * x + y * y); // distance of cell from center
double phi = atan2 (y, x); // angle of cell from center
double L = r * cos (theta - phi); // position on detector
- int iDetPos = iDetCenter + nearest<int> (L / detInc); // calc'd index in the filter raysum array
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, r, phi, L, iDetPos);
- else
- v[ix][iy] += rotScale * filteredProj[iDetPos];
+ int iDetPos = iDetCenter + nearest<int> (L / detInc); // calc'd index in the filter raysum array
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, r, phi, L, iDetPos);
+ else
+ v[ix][iy] += rotScale * filteredProj[iDetPos];
- double p = L / detInc; // position along detector
- double pFloor = floor (p);
- int iDetPos = iDetCenter + static_cast<int>(pFloor);
- double frac = p - pFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1) // check for impossible: index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, r, phi, L, iDetPos);
- else
- v[ix][iy] += rotScale * ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
+ double p = L / detInc; // position along detector
+ double pFloor = floor (p);
+ int iDetPos = iDetCenter + static_cast<int>(pFloor);
+ double frac = p - pFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1) // check for impossible: index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, r, phi, L, iDetPos);
+ else
+ v[ix][iy] += rotScale * ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
// Precalculates trigometric function value for each point in image for backprojection.
BackprojectTable::BackprojectTable (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
// Precalculates trigometric function value for each point in image for backprojection.
BackprojectTable::BackprojectTable (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
{
arrayR.initSetSize (im.nx(), im.ny());
arrayPhi.initSetSize (im.nx(), im.ny());
r = arrayR.getArray();
phi = arrayPhi.getArray();
{
arrayR.initSetSize (im.nx(), im.ny());
arrayPhi.initSetSize (im.nx(), im.ny());
r = arrayR.getArray();
phi = arrayPhi.getArray();
double x, y; // Rectang coords of center of pixel
int ix, iy;
for (x = xMin + xInc / 2, ix = 0; ix < nx; x += xInc, ix++)
double x, y; // Rectang coords of center of pixel
int ix, iy;
for (x = xMin + xInc / 2, ix = 0; ix < nx; x += xInc, ix++)
- int iDetPos = iDetCenter + nearest<int>(L / detInc); // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, r[ix][iy], phi[ix][iy], L, iDetPos);
- else
- pImCol[iy] += filteredProj[iDetPos];
+ int iDetPos = iDetCenter + nearest<int>(L / detInc); // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, r[ix][iy], phi[ix][iy], L, iDetPos);
+ else
+ pImCol[iy] += filteredProj[iDetPos];
- double dPos = L / detInc; // position along detector
- double dPosFloor = floor (dPos);
- int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
- double frac = dPos - dPosFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1)
- errorIndexOutsideDetector (ix, iy, theta, r[ix][iy], phi[ix][iy], L, iDetPos);
- else
- pImCol[iy] += ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
+ double dPos = L / detInc; // position along detector
+ double dPosFloor = floor (dPos);
+ int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
+ double frac = dPos - dPosFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1)
+ errorIndexOutsideDetector (ix, iy, theta, r[ix][iy], phi[ix][iy], L, iDetPos);
+ else
+ pImCol[iy] += ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
// Iterates in x & y direction by adding difference in L position
BackprojectDiff::BackprojectDiff (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
// Iterates in x & y direction by adding difference in L position
BackprojectDiff::BackprojectDiff (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
{
// calculate center of first pixel v[0][0]
double x = xMin + xInc / 2;
double y = yMin + yInc / 2;
start_r = sqrt (x * x + y * y);
start_phi = atan2 (y, x);
{
// calculate center of first pixel v[0][0]
double x = xMin + xInc / 2;
double y = yMin + yInc / 2;
start_r = sqrt (x * x + y * y);
start_phi = atan2 (y, x);
double det_dx = xInc * cos (theta);
double det_dy = yInc * sin (theta);
double lColStart = start_r * cos (theta - start_phi); // calculate L for first point in image
double det_dx = xInc * cos (theta);
double det_dy = yInc * sin (theta);
double lColStart = start_r * cos (theta - start_phi); // calculate L for first point in image
for (int ix = 0; ix < nx; ix++, lColStart += det_dx) {
double curDetPos = lColStart;
ImageFileColumn pImCol = v[ix];
for (int ix = 0; ix < nx; ix++, lColStart += det_dx) {
double curDetPos = lColStart;
ImageFileColumn pImCol = v[ix];
for (int iy = 0; iy < ny; iy++, curDetPos += det_dy) {
#ifdef DEBUG
printf ("[%2d,%2d]: %8.5f ", ix, iy, curDetPos);
#endif
if (interpType == Backprojector::INTERP_NEAREST) {
for (int iy = 0; iy < ny; iy++, curDetPos += det_dy) {
#ifdef DEBUG
printf ("[%2d,%2d]: %8.5f ", ix, iy, curDetPos);
#endif
if (interpType == Backprojector::INTERP_NEAREST) {
- int iDetPos = iDetCenter + nearest<int>(curDetPos / detInc); // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- pImCol[iy] += filteredProj[iDetPos];
+ int iDetPos = iDetCenter + nearest<int>(curDetPos / detInc); // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ pImCol[iy] += filteredProj[iDetPos];
- double detPos = curDetPos / detInc; // position along detector
- double detPosFloor = floor (detPos);
- int iDetPos = iDetCenter + static_cast<int>(detPosFloor);
- double frac = detPos - detPosFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1)
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- pImCol[iy] += ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
+ double detPos = curDetPos / detInc; // position along detector
+ double detPosFloor = floor (detPos);
+ int iDetPos = iDetCenter + static_cast<int>(detPosFloor);
+ double frac = detPos - detPosFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1)
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ pImCol[iy] += ((1-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
// Distance betw. detectors for an angle given in units of detectors
double det_dx = xInc * cos (theta) / detInc;
double det_dy = yInc * sin (theta) / detInc;
// Distance betw. detectors for an angle given in units of detectors
double det_dx = xInc * cos (theta) / detInc;
double det_dy = yInc * sin (theta) / detInc;
#ifdef DEBUG
printf ("start_r=%8.5f, start_phi=%8.5f, rotScale=%8.5f\n", start_r, start_phi, rotScale);
#endif
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
double curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
#ifdef DEBUG
printf ("start_r=%8.5f, start_phi=%8.5f, rotScale=%8.5f\n", start_r, start_phi, rotScale);
#endif
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
double curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
for (int iy = 0; iy < ny; iy++, curDetPos += det_dy) {
#ifdef DEBUG
printf ("[%2d,%2d]: %8.5f %8.5f\n", ix, iy, curDetPos, filteredProj[iDetCenter + nearest<int>(curDetPos)]);
#endif
if (interpType == Backprojector::INTERP_NEAREST) {
for (int iy = 0; iy < ny; iy++, curDetPos += det_dy) {
#ifdef DEBUG
printf ("[%2d,%2d]: %8.5f %8.5f\n", ix, iy, curDetPos, filteredProj[iDetCenter + nearest<int>(curDetPos)]);
#endif
if (interpType == Backprojector::INTERP_NEAREST) {
- int iDetPos = iDetCenter + nearest<int> (curDetPos); // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- *pImCol++ += filteredProj[iDetPos];
+ int iDetPos = iDetCenter + nearest<int> (curDetPos); // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ *pImCol++ += filteredProj[iDetPos];
- double detPosFloor = floor (curDetPos);
- int iDetPos = iDetCenter + static_cast<int>(detPosFloor);
- double frac = curDetPos - detPosFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1)
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- *pImCol++ += filteredProj[iDetPos] + (frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos]));
+ double detPosFloor = floor (curDetPos);
+ int iDetPos = iDetCenter + static_cast<int>(detPosFloor);
+ double frac = curDetPos - detPosFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1)
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ *pImCol++ += filteredProj[iDetPos] + (frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos]));
static const kint32 scale = 1 << 16;
static const double dScale = scale;
static const kint32 halfScale = scale / 2;
static const kint32 scale = 1 << 16;
static const double dScale = scale;
static const kint32 halfScale = scale / 2;
// calculate L for first point in image (0, 0)
kint32 detPosColStart = nearest<kint32> (start_r * cos (theta - start_phi) / detInc * scale);
// calculate L for first point in image (0, 0)
kint32 detPosColStart = nearest<kint32> (start_r * cos (theta - start_phi) / detInc * scale);
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
kint32 curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
kint32 curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
- int detPosNearest = (curDetPos >= 0 ? ((curDetPos + halfScale) / scale) : ((curDetPos - halfScale) / scale));
- int iDetPos = iDetCenter + detPosNearest; // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for index outside of raysum pos
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- *pImCol++ += filteredProj[iDetPos];
+ int detPosNearest = (curDetPos >= 0 ? ((curDetPos + halfScale) / scale) : ((curDetPos - halfScale) / scale));
+ int iDetPos = iDetCenter + detPosNearest; // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for index outside of raysum pos
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ *pImCol++ += filteredProj[iDetPos];
- kint32 detPosFloor = curDetPos / scale;
- kint32 detPosRemainder = curDetPos % scale;
- if (detPosRemainder < 0) {
- detPosFloor--;
- detPosRemainder += scale;
- }
- int iDetPos = iDetCenter + detPosFloor;
- double frac = detPosRemainder / dScale;
- if (iDetPos < 0 || iDetPos >= nDet - 1)
- errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
- else
- *pImCol++ += ((1.-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
+ kint32 detPosFloor = curDetPos / scale;
+ kint32 detPosRemainder = curDetPos % scale;
+ if (detPosRemainder < 0) {
+ detPosFloor--;
+ detPosRemainder += scale;
+ }
+ int iDetPos = iDetCenter + detPosFloor;
+ double frac = detPosRemainder / dScale;
+ if (iDetPos < 0 || iDetPos >= nDet - 1)
+ errorIndexOutsideDetector (ix, iy, theta, curDetPos, iDetPos);
+ else
+ *pImCol++ += ((1.-frac) * filteredProj[iDetPos] + frac * filteredProj[iDetPos+1]);
static const kint32 scaleBitmask = scale - 1;
static const kint32 halfScale = scale / 2;
static const double dInvScale = 1. / scale;
static const kint32 scaleBitmask = scale - 1;
static const kint32 halfScale = scale / 2;
static const double dInvScale = 1. / scale;
// calculate L for first point in image (0, 0)
kint32 detPosColStart = nearest<kint32> ((start_r * cos (theta - start_phi) / detInc + iDetCenter) * scale);
// calculate L for first point in image (0, 0)
kint32 detPosColStart = nearest<kint32> ((start_r * cos (theta - start_phi) / detInc + iDetCenter) * scale);
// precalculate scaled difference for linear interpolation
double* deltaFilteredProj = new double [nDet];
if (interpType == Backprojector::INTERP_LINEAR) {
// precalculate scaled difference for linear interpolation
double* deltaFilteredProj = new double [nDet];
if (interpType == Backprojector::INTERP_LINEAR) {
int iLastDet = nDet - 1;
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
kint32 curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
int iLastDet = nDet - 1;
for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
kint32 curDetPos = detPosColStart;
ImageFileColumn pImCol = v[ix];
- const int iDetPos = (curDetPos + halfScale) >> 16;
- if (iDetPos >= 0 && iDetPos <= iLastDet)
- *pImCol++ += filteredProj[iDetPos];
+ const int iDetPos = (curDetPos + halfScale) >> 16;
+ if (iDetPos >= 0 && iDetPos <= iLastDet)
+ *pImCol++ += filteredProj[iDetPos];
- const int iDetPos = ((curDetPos + halfScale) >> 16) * m_interpFactor;
- if (iDetPos >= 0 && iDetPos <= iLastDet)
- *pImCol++ += filteredProj[iDetPos];
+ const int iDetPos = ((curDetPos + halfScale) >> 16) * m_interpFactor;
+ if (iDetPos >= 0 && iDetPos <= iLastDet)
+ *pImCol++ += filteredProj[iDetPos];
- const kint32 iDetPos = curDetPos >> scaleShift;
- const kint32 detRemainder = curDetPos & scaleBitmask;
- if (iDetPos >= 0 && iDetPos <= iLastDet)
- *pImCol++ += filteredProj[iDetPos] + (detRemainder * deltaFilteredProj[iDetPos]);
+ const kint32 iDetPos = curDetPos >> scaleShift;
+ const kint32 detRemainder = curDetPos & scaleBitmask;
+ if (iDetPos >= 0 && iDetPos <= iLastDet)
+ *pImCol++ += filteredProj[iDetPos] + (detRemainder * deltaFilteredProj[iDetPos]);
for (int iy = 0; iy < ny; iy++) {
double dAngleDiff = beta - phi[ix][iy];
double rcos_t = r[ix][iy] * cos (dAngleDiff);
for (int iy = 0; iy < ny; iy++) {
double dAngleDiff = beta - phi[ix][iy];
double rcos_t = r[ix][iy] * cos (dAngleDiff);
double dFLPlusSin = m_dFocalLength + rsin_t;
double gamma = atan (rcos_t / dFLPlusSin);
double dL2 = dFLPlusSin * dFLPlusSin + (rcos_t * rcos_t);
double dFLPlusSin = m_dFocalLength + rsin_t;
double gamma = atan (rcos_t / dFLPlusSin);
double dL2 = dFLPlusSin * dFLPlusSin + (rcos_t * rcos_t);
- int iDetPos =iDetCenter + nearest<int>(gamma / detInc); // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) { // check for impossible: index outside of raysum pos
- ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], gamma, iDetPos);
- } else
- pImCol[iy] += filteredProj[iDetPos] / dL2;
+ int iDetPos =iDetCenter + nearest<int>(gamma / detInc); // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) { // check for impossible: index outside of raysum pos
+ ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], gamma, iDetPos);
+ } else
+ pImCol[iy] += filteredProj[iDetPos] / dL2;
- double dPos = gamma / detInc; // position along detector
- double dPosFloor = floor (dPos);
- int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
- double frac = dPos - dPosFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1) {
- ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], gamma, iDetPos);
- } else
- pImCol[iy] += (filteredProj[iDetPos] + frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos])) / dL2;
+ double dPos = gamma / detInc; // position along detector
+ double dPosFloor = floor (dPos);
+ int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
+ double frac = dPos - dPosFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1) {
+ ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], gamma, iDetPos);
+ } else
+ pImCol[iy] += (filteredProj[iDetPos] + frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos])) / dL2;
for (int iy = 0; iy < ny; iy++) {
double dAngleDiff = beta - phi[ix][iy];
double rcos_t = r[ix][iy] * cos (dAngleDiff);
double rsin_t = r[ix][iy] * sin (dAngleDiff);
for (int iy = 0; iy < ny; iy++) {
double dAngleDiff = beta - phi[ix][iy];
double rcos_t = r[ix][iy] * cos (dAngleDiff);
double rsin_t = r[ix][iy] * sin (dAngleDiff);
double dU = (m_dFocalLength + rsin_t) / m_dFocalLength;
double dDetPos = rcos_t / dU;
// double to scale for imaginary detector that passes through origin
// of phantom, see Kak-Slaney Figure 3.22
dDetPos *= 2;
double dU = (m_dFocalLength + rsin_t) / m_dFocalLength;
double dDetPos = rcos_t / dU;
// double to scale for imaginary detector that passes through origin
// of phantom, see Kak-Slaney Figure 3.22
dDetPos *= 2;
- int iDetPos = iDetCenter + nearest<int>(dDetPos / detInc); // calc index in the filtered raysum vector
-
- if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
- ; /// errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], dDetPos, iDetPos);
- else
- pImCol[iy] += (filteredProj[iDetPos] / (dU * dU));
+ int iDetPos = iDetCenter + nearest<int>(dDetPos / detInc); // calc index in the filtered raysum vector
+
+ if (iDetPos < 0 || iDetPos >= nDet) // check for impossible: index outside of raysum pos
+ ; /// errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], dDetPos, iDetPos);
+ else
+ pImCol[iy] += (filteredProj[iDetPos] / (dU * dU));
- double dPos = dDetPos / detInc; // position along detector
- double dPosFloor = floor (dPos);
- int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
- double frac = dPos - dPosFloor; // fraction distance from det
- if (iDetPos < 0 || iDetPos >= nDet - 1)
- ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], dDetPos, iDetPos);
- else
- pImCol[iy] += (filteredProj[iDetPos] + frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos])) / (dU * dU);
+ double dPos = dDetPos / detInc; // position along detector
+ double dPosFloor = floor (dPos);
+ int iDetPos = iDetCenter + static_cast<int>(dPosFloor);
+ double frac = dPos - dPosFloor; // fraction distance from det
+ if (iDetPos < 0 || iDetPos >= nDet - 1)
+ ; // errorIndexOutsideDetector (ix, iy, beta, r[ix][iy], phi[ix][iy], dDetPos, iDetPos);
+ else
+ pImCol[iy] += (filteredProj[iDetPos] + frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos])) / (dU * dU);