r131: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 4 Jul 2000 22:22:33 +0000 (22:22 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 4 Jul 2000 22:22:33 +0000 (22:22 +0000)
ChangeLog
include/filter.h
include/trace.h
libctsim/filter.cpp
libctsim/projections.cpp
src/if2img.cpp
src/phm2if.cpp
src/phm2pj.cpp
src/pjrec.cpp

index c7d44785f7526e487d6840f517b4c983895496f2..5c73152c67b02190f3be14f4696ea8529899f472 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,16 @@
+2.0.0 - 7/07/00
+   Update trace level processing
+   Added trace level to SignalFilter
+       
 1.9.9 - 7/04/00
    Fixed const issue with ImageFileArray
    Fixed Array2dFile::labelsCopy()
    Added copy constructor and assignment for Array2dFileLabel class
    Added Timer to if-2.cpp and ifinfo.cpp
    Added beginning of frequency-based (DFT & FFT) filter to SignalFilter
-   Fixed format string for EZPlot
+   Added option processing for filter-method for pjrec to choose
+       between convolution, dft, & fft filtering
+   Fixed format string for EZPlot so axis labels now print
        
 1.9.8 - 6/27/2000
    Rewrote Array2dFile class to be non-templated
index 48f82109bcc385364ee9f22018cbbdbc28e76984..8e0740b982e1bb34dc4592d090fb309c9b8e806c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: filter.h,v 1.8 2000/07/04 18:33:35 kevin Exp $
+**  $Id: filter.h,v 1.9 2000/07/04 22:21:01 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
@@ -112,6 +112,8 @@ class SignalFilter {
 
     void finiteFourierTransform (const complex<double> input[], complex<double> output[], const int direction) const;
 
+    void setTraceLevel (int traceLevel) {m_traceLevel = traceLevel; }
+
     bool fail(void) const      {return m_fail;}
     const string& failMessage(void) const {return m_failMessage;}
 
@@ -161,6 +163,7 @@ class SignalFilter {
     DomainID m_idDomain;
     double m_filterParam;
     int m_numIntegral;
+    int m_traceLevel;
 
     static const FilterID convertFilterNameToID (const char* filterName);
     static const char* convertFilterIDToName (const FilterID filterID);
index 20e3186e8cc70164c98c81f10b04c154b8eb736f..bf062076df8148ccfb91394667f922edd5a65dd7 100644 (file)
@@ -2,12 +2,13 @@
 #define TRACE_H
 
 enum {
-  TRACE_NONE,          /* No tracing */
-  TRACE_TEXT,          /* Minimal status */
-  TRACE_PHM,           /* Show phantom */
-  TRACE_RAYS,          /* Show all rays */
-  TRACE_PLOT,          /* Plot raysums */
-  TRACE_CLIPPING       /* Plot clipping */
+    TRACE_INVALID=-1,
+    TRACE_NONE=0,              /* No tracing */
+    TRACE_TEXT,                /* Minimal status */
+    TRACE_PHM,         /* Show phantom */
+    TRACE_RAYS,                /* Show all rays */
+    TRACE_PLOT,                /* Plot raysums */
+    TRACE_CLIPPING     /* Plot clipping */
 };
 
 static const char TRACE_NONE_STR[]=     "none";
@@ -26,16 +27,20 @@ class TraceLevel
 
     bool isTrace (const char* const traceQuery) const;
 
+    int getTraceLevel(void) const { return m_traceLevel; }
+
  private:
 
+    int m_traceLevel;
+
     bool addTraceElements (const char* const traceString);
 };
 
 
 inline int 
-opt_set_trace (const char *traceString)
+convertTraceNameToID (const char *traceString)
 {
-  int traceID;
+  int traceID = TRACE_INVALID;
 
   if (strcasecmp (traceString, TRACE_NONE_STR) == 0)
     traceID = TRACE_NONE;
@@ -49,10 +54,6 @@ opt_set_trace (const char *traceString)
     traceID = TRACE_CLIPPING;
   else if (strcasecmp (traceString, TRACE_RAYS_STR) == 0)
     traceID = TRACE_RAYS;
-  else {
-    sys_error(ERR_WARNING,"Invalid trace option %s\n", traceString);
-    traceID = -1;
-  }
 
   return (traceID);
 }
index 27d1829380ae5224feff90fb221a801079884f20..d3a3fbdfaf01ed399ba8e2923a55ee0fd75e3443 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: filter.cpp,v 1.8 2000/07/04 18:33:35 kevin Exp $
+**  $Id: filter.cpp,v 1.9 2000/07/04 22:21:01 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
@@ -115,6 +115,7 @@ SignalFilter::init (const FilterID filterID, const FilterMethodID filterMethodID
     m_fail = true;
     return;
   }
+  m_traceLevel = TRACE_NONE;
   m_nameFilter = convertFilterIDToName (m_idFilter);
   m_nameDomain = convertDomainIDToName (m_idDomain);
   m_nameFilterMethod = convertFilterMethodIDToName (m_idFilterMethod);
@@ -133,9 +134,9 @@ SignalFilter::init (const FilterID filterID, const FilterMethodID filterMethodID
       m_vecFourierSinTable[i] = sin (angleIncrement * i);
     }
     m_nFilterPoints = m_nSignalPoints;
-    m_filterMin = 0;
-    m_filterMax = m_nSignalPoints * m_signalInc;
-    m_filterInc = (m_filterMax - m_filterMin) / (m_nFilterPoints - 1);
+    m_filterMin = -1. / (2 * m_signalInc);
+    m_filterMax = 1. / (2 * m_signalInc);
+    m_filterInc = (m_filterMax - m_filterMin) / m_nFilterPoints;
     m_vecFilter = new double [m_nFilterPoints];
     int halfFilter = m_nFilterPoints / 2;
     for (int i = 0; i < halfFilter; i++) 
@@ -143,7 +144,7 @@ SignalFilter::init (const FilterID filterID, const FilterMethodID filterMethodID
     for (int i = 0; i < halfFilter; i++)
        m_vecFilter[m_nFilterPoints - i - 1] = static_cast<double>(i) / (halfFilter - 1) / (2 * m_signalInc);
     if (halfFilter % 2) // odd
-      m_vecFilter[halfFilter] = 1;
+      m_vecFilter[halfFilter] = 1 / (2 * m_signalInc);
   } else if (m_idFilterMethod == FILTER_METHOD_FFT || m_idFilterMethod == FILTER_METHOD_FFT_ZEROPAD_2 || m_idFilterMethod == FILTER_METHOD_FFT_ZEROPAD_4) {
     m_nFilterPoints = m_nSignalPoints;
     if (m_idFilterMethod == FILTER_METHOD_FFT_ZEROPAD_2 || m_idFilterMethod == FILTER_METHOD_FFT_ZEROPAD_4) {
@@ -156,9 +157,9 @@ SignalFilter::init (const FilterID filterID, const FilterMethodID filterMethodID
       m_nFilterPoints = 1 << nextPowerOf2;
       cout << "nFilterPoints = " << m_nFilterPoints << endl;
     }
-    m_filterMin = 0;
-    m_filterMax = m_nSignalPoints * m_signalInc;
-    m_filterInc = (m_filterMax - m_filterMin) / (m_nFilterPoints - 1);
+    m_filterMin = -1. / (2 * m_signalInc);
+    m_filterMax = 1. / (2 * m_signalInc);
+    m_filterInc = (m_filterMax - m_filterMin) / m_nFilterPoints;
     m_vecFilter = new double [m_nFilterPoints];
     int halfFilter = m_nFilterPoints / 2;
     for (int i = 0; i < halfFilter; i++) 
@@ -166,7 +167,7 @@ SignalFilter::init (const FilterID filterID, const FilterMethodID filterMethodID
     for (int i = 0; i < halfFilter; i++)
        m_vecFilter[m_nFilterPoints - i - 1] = static_cast<double>(i) / (halfFilter - 1) /  (2 * m_signalInc);
     if (halfFilter % 2) // odd
-      m_vecFilter[halfFilter] = 1;
+      m_vecFilter[halfFilter] = 1 / (2 * m_signalInc);
 
 #if HAVE_FFTW
     m_planForward = fftw_create_plan (m_nFilterPoints, FFTW_FORWARD, FFTW_ESTIMATE);
@@ -364,11 +365,24 @@ SignalFilter::filterSignal (const float input[], double output[]) const
     complex<double> complexOutput[m_nSignalPoints];
     complex<double> filteredSignal[m_nSignalPoints];
     finiteFourierTransform (input, fftSignal, m_nSignalPoints, -1);
+    if (m_traceLevel >= TRACE_PLOT) {
+       double test[m_nSignalPoints];
+       for (int i = 0; i < m_nSignalPoints; i++) 
+           test[i] = abs(fftSignal[i]);
+       ezplot_1d(test, m_nSignalPoints);
+       cio_kb_getc();
+    }
     dotProduct (m_vecFilter, fftSignal, filteredSignal, m_nSignalPoints);
+    if (m_traceLevel >= TRACE_PLOT) {
+       double test[m_nSignalPoints];
+       for (int i = 0; i < m_nSignalPoints; i++) 
+           test[i] = abs(filteredSignal[i]);
+       ezplot_1d(test, m_nSignalPoints);
+       cio_kb_getc();
+    }
     finiteFourierTransform (filteredSignal, complexOutput, m_nSignalPoints, 1);
-    for (int i = 0; i < m_nSignalPoints; i++) {
+    for (int i = 0; i < m_nSignalPoints; i++) 
       output[i] = abs( complexOutput[i] );
-    }
   } else if (m_idFilterMethod == FILTER_METHOD_FFT || FILTER_METHOD_FFT_ZEROPAD_2 || FILTER_METHOD_FFT_ZEROPAD_4) {
     fftw_complex in[m_nFilterPoints], out[m_nFilterPoints];
     for (int i = 0; i < m_nSignalPoints; i++) {
@@ -379,11 +393,32 @@ SignalFilter::filterSignal (const float input[], double output[]) const
       in[i].re = in[i].im = 0;      // ZeroPad
     }
     fftw_one(m_planForward, in, out);
+    if (m_traceLevel >= TRACE_PLOT) {
+       double test[m_nFilterPoints];
+       for (int i = 0; i < m_nFilterPoints; i++) 
+           test[i] = sqrt(out[i].re * out[i].re + out[i].im * out[i].im);
+       ezplot_1d(test, m_nFilterPoints);
+       cio_kb_getc();
+    }
     for (int i = 0; i < m_nFilterPoints; i++) {
       out[i].re = m_vecFilter[i] * out[i].re / m_nSignalPoints;
       out[i].im = m_vecFilter[i] * out[i].im / m_nSignalPoints;
     }
+    if (m_traceLevel >= TRACE_PLOT) {
+       double test[m_nFilterPoints];
+       for (int i = 0; i < m_nFilterPoints; i++) 
+           test[i] = sqrt(out[i].re * out[i].re + out[i].im * out[i].im);
+       ezplot_1d(test, m_nFilterPoints);
+       cio_kb_getc();
+    }
     fftw_one(m_planBackward, out, in);
+    if (m_traceLevel >= TRACE_PLOT) {
+       double test[m_nFilterPoints];
+       for (int i = 0; i < m_nFilterPoints; i++) 
+           test[i] = sqrt(in[i].re * in[i].re + in[i].im * in[i].im);
+       ezplot_1d(test, m_nFilterPoints);
+       cio_kb_getc();
+    }
     for (int i = 0; i < m_nSignalPoints; i++) 
       output[i] = sqrt (in[i].re * in[i].re + in[i].im * in[i].im);
   }
index 1d90776a039a15d85479c82b11327b7c0763586f..0182eec8d4af2ff6bae3ec189f2a3ad942974c6f 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.10 2000/07/04 18:33:35 kevin Exp $
+**  $Id: projections.cpp,v 1.11 2000/07/04 22:21:01 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
@@ -506,6 +506,8 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi
 
   double filterBW = 1. / detInc;
   SignalFilter filter (filterName, filterMethodName, filterBW, m_detInc, m_nDet, filt_param, "spatial", 0);
+  filter.setTraceLevel(trace);
+
   if (filter.fail()) {
       sys_error (ERR_SEVERE, "%s [Projections::reconstruct]", filter.failMessage().c_str());
       return false;
index 1aa8a39d49bf44c04520cbabcec0cbff1332bbf8..2547b512de7b9e939ba0c51becd97653ae77ba9f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if2img.cpp,v 1.9 2000/06/26 21:15:24 kevin Exp $
+**  $Id: if2img.cpp,v 1.10 2000/07/04 22:21:01 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
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
 
-/* FILE
- *   if2img.c          Convert an SDF file to a viewable format image
- */
-
 #include "ct.h"
 
+
 #if HAVE_PNG
 void sdf2d_to_png (ImageFile& im, char *outfile, int bitdepth, int nxcell, int nycell, double densmin, double densmax);
 #endif
@@ -61,24 +58,24 @@ static struct option my_options[] =
 };
 
 enum { O_AUTO_FULL, O_AUTO_STD0_1, O_AUTO_STD0_5, O_AUTO_STD1, O_AUTO_STD2, O_AUTO_STD3 };
-#define O_AUTO_FULL_STR  "full"
-#define O_AUTO_STD0_1_STR  "std0.1"
-#define O_AUTO_STD0_5_STR  "std0.5"
-#define O_AUTO_STD1_STR  "std1"
-#define O_AUTO_STD2_STR  "std2"
-#define O_AUTO_STD3_STR  "std3"
+static const char O_AUTO_FULL_STR[]="full";
+static const char O_AUTO_STD0_1_STR[]="std0.1";
+static const char O_AUTO_STD0_5_STR[]="std0.5";
+static const char O_AUTO_STD1_STR[]="std1";
+static const char O_AUTO_STD2_STR[]="std2";
+static const char O_AUTO_STD3_STR[]="std3";
 
 enum { O_CENTER_MEAN, O_CENTER_MODE };
-#define O_CENTER_MEAN_STR  "mean"
-#define O_CENTER_MODE_STR  "mode"
+static const char O_CENTER_MEAN_STR[]="mean";
+static const char O_CENTER_MODE_STR[]="mode";
 
 enum { O_FORMAT_GIF, O_FORMAT_PNG, O_FORMAT_PNG16, O_FORMAT_PGM, O_FORMAT_PGMASC, O_FORMAT_DISP };
-#define O_FORMAT_GIF_STR   "gif"
-#define O_FORMAT_PNG_STR   "png" 
-#define O_FORMAT_PNG16_STR   "png16" 
-#define O_FORMAT_PGM_STR   "pgm"
-#define O_FORMAT_PGMASC_STR "pgmasc"
-#define O_FORMAT_DISP_STR    "disp"
+static const char O_FORMAT_GIF_STR[]="gif";
+static const char O_FORMAT_PNG_STR[]="png" ;
+static const char O_FORMAT_PNG16_STR[]="png16" ;
+static const char O_FORMAT_PGM_STR[]="pgm";
+static const char O_FORMAT_PGMASC_STR[]="pgmasc";
+static const char O_FORMAT_DISP_STR[]="disp";
 
 void 
 if2img_usage (const char *program)
@@ -573,7 +570,7 @@ sdf2d_to_png (ImageFile& im, char *outfile, int bitdepth, int nxcell, int nycell
 
 #ifdef HAVE_GD
 #include "gd.h"
-#define N_GRAYSCALE 256
+static const int N_GRAYSCALE=256;
 #endif
 
 void
index a6a7e260aa50ac75fe7ae9a00204c839c5d0ae3d..afac8162d2ebe0fa0e4eaae64b52b67c8a3e150a 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.15 2000/06/26 21:15:24 kevin Exp $
+**  $Id: phm2if.cpp,v 1.16 2000/07/04 22:21:01 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
@@ -152,7 +152,7 @@ phm2if_main (int argc, char* argv[])
        opt_debug = 1;
        break;
       case O_TRACE:
-       if ((opt_trace = opt_set_trace(optarg)) < 0) {
+       if ((opt_trace = convertTraceNameToID(optarg)) == TRACE_INVALID) {
          phm2if_usage(argv[0]);
          return (1);
        }
index 439fa83920e1ea8a6697cac0c9f7189f52856713..2734b2d6a94eac0a0e792ad3edd62c7e2a755145 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2pj.cpp,v 1.5 2000/06/26 21:15:24 kevin Exp $
+**  $Id: phm2pj.cpp,v 1.6 2000/07/04 22:21:01 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
@@ -133,7 +133,7 @@ phm2pj_main (int argc, char* argv[])
        break;
        break;
       case O_TRACE:
-       if ((opt_trace = opt_set_trace(optarg)) < 0) {
+       if ((opt_trace = convertTraceNameToID(optarg)) == TRACE_INVALID) {
          phm2pj_usage(argv[0]);
          return (1);
        }
index 0a2b2c84ae47bf65d7debc251f9839774b04229f..782563cb1dd76d40a48bf0003b6427ae9fc1e4b9 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pjrec.cpp,v 1.5 2000/07/04 18:33:35 kevin Exp $
+**  $Id: pjrec.cpp,v 1.6 2000/07/04 22:21:01 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
@@ -170,7 +170,7 @@ pjrec_main (int argc, char * argv[])
          optDebug = 1;
          break;
        case O_TRACE:
-         if ((optTrace = opt_set_trace(optarg)) < 0) {
+         if ((optTrace = convertTraceNameToID(optarg)) == TRACE_INVALID) {
            pjrec_usage(argv[0]);
            return (1);
          }