r326: FFTW additions, filter image generation
[ctsim.git] / libctsim / backprojectors.cpp
index 152e026770059dcee869e6161d6d373639b85f5a..726e5b8d30189c14e472f5e4eee802930742964e 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: backprojectors.cpp,v 1.15 2000/12/03 15:16:18 kevin Exp $
+**  $Id: backprojectors.cpp,v 1.21 2001/01/01 10:14:34 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
@@ -84,7 +84,7 @@ const char* Backprojector::s_aszInterpTitle[] =
 {
   {"Nearest"},
   {"Linear"},
-  {"Frequency Preinterpolationj"},
+  {"Frequency Preinterpolation"},
 #if HAVE_BSPLINE_INTERP
   {"B-Spline"},
   {"B-Spline 1st Order"},
@@ -256,14 +256,20 @@ Backprojector::convertInterpIDToTitle (const int interpID)
 // PURPOSE
 //   Pure virtual base class for all backprojectors.
 
-Backproject::Backproject (const Projections& proj, ImageFile& im, const int interpType, const int interpFactor)
+Backproject::Backproject (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
     : proj(proj), im(im), interpType(interpType), m_interpFactor(interpFactor)
 {
   detInc = proj.detInc();
   nDet = proj.nDet();
   iDetCenter = (nDet - 1) / 2; // index refering to L=0 projection 
   rotScale = proj.rotInc();
-  rotScale /= (proj.nView() * proj.rotInc() / PI); // scale by number of PI rotations
+
+  if (proj.geometry() == Scanner::GEOMETRY_PARALLEL)\r
+       rotScale /= (proj.nView() * proj.rotInc() / PI); // scale by number of PI rotations\r
+  else if (proj.geometry() == Scanner::GEOMETRY_EQUIANGULAR || proj.geometry() == Scanner::GEOMETRY_EQUILINEAR)\r
+       rotScale /= (proj.nView() * proj.rotInc() / (2 * PI)); // scale by number of 2PI rotations\r
+  else\r
+         sys_error (ERR_SEVERE, "Invalid geometry type %d [Backproject::Backproject]", proj.geometry());\r
 
   v = im.getArray();
   nx = im.nx();
@@ -299,15 +305,17 @@ void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, doubl
 }
 
 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int iDetPos)
-{
-  ostringstream os;
+{\r
+#if 1
+  std::ostringstream os;
   os << "ix=" << ix << ", iy=" << iy << ", theta=" << theta << ", L=" << L << ", detinc=" << detInc << "\n";
   os << "ndet=" << nDet << ", detInc=" << detInc << ", iDetCenter=" << iDetCenter << "\n";
   os << "xMin=" << xMin << ", xMax=" << xMax << ", xInc=" << xInc << "\n";
   os << "yMin=" << yMin << ", yMax=" << yMax << ", yInc=" << yInc << "\n";
   os << "iDetPos index outside bounds: " << iDetPos << " [backprojector]";;
 
-  sys_error (ERR_WARNING, os.str().c_str());
+  sys_error (ERR_WARNING, os.str().c_str());\r
+#endif
 }
 
 
@@ -359,7 +367,7 @@ BackprojectTrig::BackprojectView (const double* const filteredProj, const double
 //   Precalculates trigometric function value for each point in image for backprojection.
 
 BackprojectTable::BackprojectTable (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
-  : Backproject::Backproject (proj, im, interpType, interpFactor)
+  : Backproject (proj, im, interpType, interpFactor)
 {
   arrayR.initSetSize (im.nx(), im.ny());
   arrayPhi.initSetSize (im.nx(), im.ny());
@@ -421,7 +429,7 @@ BackprojectTable::BackprojectView (const double* const filteredProj, const doubl
 //   Iterates in x & y direction by adding difference in L position
 
 BackprojectDiff::BackprojectDiff (const Projections& proj, ImageFile& im, int interpType, const int interpFactor)
-  :  Backproject::Backproject (proj, im, interpType, interpFactor)
+  :  Backproject (proj, im, interpType, interpFactor)
 {
   // calculate center of first pixel v[0][0] 
   double x = xMin + xInc / 2;
@@ -599,7 +607,7 @@ BackprojectIntDiff3::BackprojectView (const double* const filteredProj, const do
   kint32 detPosColStart = nearest<kint32> ((start_r * cos (theta - start_phi) / detInc + iDetCenter) * scale);
        
   // precalculate scaled difference for linear interpolation
-  double deltaFilteredProj [nDet];
+  double* deltaFilteredProj = new double [nDet];
   if (interpType == Backprojector::INTERP_LINEAR) {
     for (int i = 0; i < nDet - 1; i++)
       deltaFilteredProj[i] = (filteredProj[i+1] - filteredProj[i]) * dInvScale;
@@ -631,7 +639,9 @@ BackprojectIntDiff3::BackprojectView (const double* const filteredProj, const do
          *pImCol++ += filteredProj[iDetPos] + (detRemainder * deltaFilteredProj[iDetPos]);
       }        // end for iy
     } //end linear
-  } // end for ix
+  } // end for ix\r
+\r
+  delete deltaFilteredProj;
 }