r144: Initial CVS import
[ctsim.git] / libctsim / projections.cpp
index 6e21b3568285ded1049dccf2d2ca9f7052e26a8f..8f1edf7b4e7f8ed32757b0c522cae49264784751 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.8 2000/07/02 18:21:39 kevin Exp $
+**  $Id: projections.cpp,v 1.13 2000/07/11 10:32:44 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
@@ -487,18 +487,17 @@ Projections::printScanInfo (void) const
  */
 
 bool
-Projections::reconstruct (ImageFile& im, const char* const filterName, double filt_param, const char* const filterMethodName, const char* const interpName, int interp_param, const char* const backprojectName, const int trace)
+Projections::reconstruct (ImageFile& im, const char* const filterName, double filt_param, const char* const filterMethodName, const int zeropad, const char* const interpName, int interpFactor, const char* const backprojectName, const int trace)
 {
   int nview = m_nView;
   double detInc = m_detInc;
-  double detlen = (m_nDet - 1) * detInc;
-  int n_filteredProj = m_nDet;
+  int n_filteredProj = m_nDet * interpFactor;
   double filteredProj [n_filteredProj];   // filtered projections
 
 #ifdef HAVE_BSPLINE_INTERP
   int spline_order = 0, zoom_factor = 0;
   if (interp_type == I_BSPLINE) {
-    zoom_factor = interp_param;
+    zoom_factor = interpFactor;
     spline_order = 3;
     zoom_factor = 3;
     n_filteredProj = (m_nDet - 1) * (zoom_factor + 1) + 1;
@@ -506,8 +505,9 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi
 #endif
 
   double filterBW = 1. / detInc;
+  SignalFilter filter (filterName, filterMethodName, filterBW, m_detInc, m_nDet, filt_param, "spatial", zeropad, interpFactor);
+  filter.setTraceLevel(trace);
 
-  SignalFilter filter (filterName, filterMethodName, filterBW, detlen, m_nDet, filt_param, "spatial", 0);
   if (filter.fail()) {
       sys_error (ERR_SEVERE, "%s [Projections::reconstruct]", filter.failMessage().c_str());
       return false;
@@ -518,27 +518,29 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi
 
 #if HAVE_SGP
   SGP_ID gid;
-  int n_vec_filter = filter.getNFilterPoints();
-  double plot_xaxis [n_vec_filter];                    // array for plotting 
+  int nVecFilter = filter.getNFilterPoints();
+  double plot_xaxis [nVecFilter];                      // array for plotting 
 
-  if (trace > TRACE_TEXT)  {
+  if (trace > TRACE_TEXT && nVecFilter > 0)  {
     int i;
     double f;
-    double filterInc = (detlen * 2) / (n_vec_filter - 1);
-    for (i = 0, f = -detlen; i < n_vec_filter; i++, f += filterInc)
+    double filterInc = filter.getFilterIncrement();
+    for (i = 0, f = filter.getFilterMin(); i < nVecFilter; i++, f += filterInc) 
       plot_xaxis[i] = f;
-      
-    gid = ezplot (plot_xaxis, filter.getFilter(), n_vec_filter);
-    cio_put_str ("Press any key to continue");
-    cio_kb_getc ();
-    sgp2_close (gid);
+
+    if (filter.getFilter()) {
+      gid = ezplot (plot_xaxis, filter.getFilter(), nVecFilter);
+      cio_put_str ("Press any key to continue");
+      cio_kb_getc ();
+      sgp2_close (gid);
+    }
   }
   if (trace >= TRACE_TEXT) {
     printf ("nview=%d, ndet=%d, det_start=%.4f, detInc=%.4f\n", m_nView, m_nDet, m_detStart, m_detInc);
   }
 #endif  //HAVE_SGP
 
-  Backprojector bj (*this, im, backprojectName, interpName);
+  Backprojector bj (*this, im, backprojectName, interpName, interpFactor);
   if (bj.fail()) {
     sys_error (ERR_SEVERE, "%s [Projections::reconstruct]", bj.failMessage().c_str());
     return false;
@@ -551,10 +553,7 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi
     DetectorArray& darray = getDetectorArray (iview);
     DetectorValue* detval = darray.detValues();
 
-    filter.filterSignal (detval, filteredProj, detInc, m_nDet);
-
-    //    for (int j = 0; j < m_nDet; j++)
-    //      filteredProj[j] = filter.convolve (detval, detInc, j, m_nDet);
+    filter.filterSignal (detval, filteredProj);
 
 #ifdef HAVE_SGP
     if (trace >= TRACE_PLOT)  {
@@ -575,8 +574,9 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi
       ezset  ("xporigin .5.");
       ezset  ("xlength .5.");
       ezset ("box");
+
       ezset ("grid");
-      gid = ezplot (filteredProj, plot_xaxis, m_nDet);
+      gid = ezplot (filteredProj, plot_xaxis, n_filteredProj);
     }
 #endif  //HAVE_SGP