r7929: fix backprojection
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 30 Sep 2003 18:00:25 +0000 (18:00 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 30 Sep 2003 18:00:25 +0000 (18:00 +0000)
ChangeLog
debian/control
libctsim/backprojectors.cpp

index 409b9e86c7d266ebdcf1519458d1f20d76503f41..344a2ac700fddf9ca717df012ad430d2f4aa0d89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Sep 30, 2003  Version 4.2.7
+
+       * Fix minor issue with floating point difference backprojection, add
+       optimization
+       
+       * Fix building with newest versions of automake 1.7
+
+       * Add support for 8-byte longs [for example, Athlon64] in
+       integer difference backprojection allowing for 64-bit integer
+       math.
+
 Mar 22, 2003  Version 4.2.3
 
        * Added Fourier reconstruction method
index b773c1043bb1774e5bd3c6b93d9f2aacf7e7e13b..521b0ef698659d1640ad281b90fb4aa341e830c1 100644 (file)
@@ -10,7 +10,8 @@ Package: ctsim
 Architecture: any
 Depends: ${misc:Depends}, ${shlibs:Depends}, ctsim-help, ctn, libwxgtk2.4, fftw2, mesag3 | libgl1, libpng12-0
 Recommends: ctsim-doc
-Conflicts: ctsim-pentium4, ctsim-athlon, ctsim-pentium3
+Replaces: ctsim
+Conflicts: ctsim
 Description: Computed tomograpy simulator
  CTSim provides an interactive computed tomography simulator. Computed
  tomography is the technique of estimating the interior of an object
@@ -26,7 +27,9 @@ Package: ctsim-pentium4
 Architecture: i386
 Depends: ${misc:Depends}, ${shlibs:Depends}, ctsim-help, ctn, libwxgtk2.4, fftw2, mesag3 | libgl1, libpng12-0
 Recommends: ctsim-doc
-Conflicts: ctsim, ctsim-athlon, ctsim-pentium3
+Provides: ctsim
+Replaces: ctsim
+Conflicts: ctsim
 Description: Computed tomograpy simulator (Pentium 4 optimized)
  CTSim provides an interactive computed tomography simulator. Computed
  tomography is the technique of estimating the interior of an object
@@ -44,7 +47,9 @@ Package: ctsim-athlon
 Architecture: i386
 Depends: ${misc:Depends}, ${shlibs:Depends}, ctsim-help, ctn, libwxgtk2.4, fftw2, mesag3 | libgl1, libpng12-0
 Recommends: ctsim-doc
-Conflicts: ctsim, ctsim-pentium4, ctsim-pentium3
+Provides: ctsim
+Replaces: ctsim
+Conflicts: ctsim
 Description: Computed tomograpy simulator (Athlon optimized)
  CTSim provides an interactive computed tomography simulator. Computed
  tomography is the technique of estimating the interior of an object
@@ -62,7 +67,9 @@ Package: ctsim-pentium3
 Architecture: i386
 Depends: ${misc:Depends}, ${shlibs:Depends}, ctsim-help, ctn, libwxgtk2.4, fftw2, mesag3 | libgl1, libpng12-0
 Recommends: ctsim-doc
-Conflicts: ctsim, ctsim-pentium4, ctsim-athlon
+Provides: ctsim
+Replaces: ctsim
+Conflicts: ctsim
 Description: Computed tomograpy simulator (Pentium optimized)
  CTSim provides an interactive computed tomography simulator. Computed
  tomography is the technique of estimating the interior of an object
index b7d320d49aab76f31668b96e3efbfd178f00289a..d38b7189f6b6c878b09ec0549dca5daf242ce24e 100644 (file)
@@ -527,37 +527,48 @@ BackprojectDiff::BackprojectView (const double* const filteredProj, const double
   double det_dy = yInc * sin (theta) / detInc;
   
   // calculate detPosition for first point in image (ix=0, iy=0) 
-  double detPosColStart = start_r * cos (theta - start_phi) / detInc;
+  double detPosColStart = iDetCenter + start_r * cos (theta - start_phi) / detInc;
   
   CubicPolyInterpolator* pCubicInterp = NULL;
-  if (interpType == Backprojector::INTERP_CUBIC)
+  double* deltaFilteredProj = NULL;  
+  if (interpType == Backprojector::INTERP_LINEAR) {
+    // precalculate scaled difference for linear interpolation
+    deltaFilteredProj = new double [nDet];
+    for (int i = 0; i < nDet - 1; i++)
+      deltaFilteredProj[i] = filteredProj[i+1] - filteredProj[i];
+    deltaFilteredProj[nDet - 1] = 0;  // last detector
+  } else if (interpType == Backprojector::INTERP_CUBIC) {
     pCubicInterp = new CubicPolyInterpolator (filteredProj, nDet);
+  }
   
+  int iLastDet = nDet - 1;
   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) {
       if (interpType == Backprojector::INTERP_NEAREST) {
-        int iDetPos = iDetCenter + nearest<int> (curDetPos);   // calc index in the filtered raysum vector 
+        int iDetPos = nearest<int> (curDetPos);        // calc index in the filtered raysum vector 
         
         if (iDetPos >= 0 && iDetPos < nDet)
           *pImCol++ += filteredProj[iDetPos];
       } else if (interpType == Backprojector::INTERP_LINEAR) {
         double detPosFloor = floor (curDetPos);
-        int iDetPos = iDetCenter + static_cast<int>(detPosFloor);
+        int iDetPos = static_cast<int>(detPosFloor);
         double frac = curDetPos - detPosFloor; // fraction distance from det 
-        if (iDetPos > 0 && iDetPos < nDet - 1)
-          *pImCol++ += filteredProj[iDetPos] + (frac * (filteredProj[iDetPos+1] - filteredProj[iDetPos]));
+        if (iDetPos >= 0 && iDetPos <= iLastDet)
+           *pImCol++ += filteredProj[iDetPos] + (frac * deltaFilteredProj[iDetPos]);
       } else if (interpType == Backprojector::INTERP_CUBIC) {
-        double p = iDetCenter + curDetPos;     // position along detector
+        double p = curDetPos;  // position along detector
         if (p >= 0 && p < nDet)
           *pImCol++  += pCubicInterp->interpolate (p);
       }
     }  // end for y
   }    // end for x
 
-  if (interpType == Backprojector::INTERP_CUBIC)
+  if (interpType == Backprojector::INTERP_LINEAR)
+    delete deltaFilteredProj;
+  else if (interpType == Backprojector::INTERP_CUBIC)
     delete pCubicInterp;
 }
 
@@ -602,7 +613,7 @@ BackprojectIntDiff::BackprojectView (const double* const filteredProj, const dou
   
   int iLastDet = nDet - 1;
   for (int ix = 0; ix < nx; ix++, detPosColStart += det_dx) {
-    kint32 curDetPos = detPosColStart;
+    long curDetPos = detPosColStart;
     ImageFileColumn pImCol = v[ix];
     
     if (interpType == Backprojector::INTERP_NEAREST) {
@@ -622,7 +633,8 @@ BackprojectIntDiff::BackprojectView (const double* const filteredProj, const dou
         const long iDetPos = curDetPos >> scaleShift;
         const long detRemainder = curDetPos & scaleBitmask;
         if (iDetPos >= 0 && iDetPos <= iLastDet)
-          *pImCol++ += filteredProj[iDetPos] + (detRemainder * deltaFilteredProj[iDetPos]);
+           *pImCol++ += filteredProj[iDetPos] + (detRemainder * deltaFilteredProj[iDetPos]);
+           
       }        // end for iy
     } else if (interpType == Backprojector::INTERP_CUBIC) {
       for (int iy = 0; iy < ny; iy++, curDetPos += det_dy) {