From 03c4bc505de131323cbc70a70bdceda9229269bf Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 4 Jul 2000 22:22:33 +0000 Subject: [PATCH] r131: *** empty log message *** --- ChangeLog | 8 +++++- include/filter.h | 5 +++- include/trace.h | 25 +++++++++--------- libctsim/filter.cpp | 57 ++++++++++++++++++++++++++++++++-------- libctsim/projections.cpp | 4 ++- src/if2img.cpp | 37 ++++++++++++-------------- src/phm2if.cpp | 4 +-- src/phm2pj.cpp | 4 +-- src/pjrec.cpp | 4 +-- 9 files changed, 96 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7d4478..5c73152 100644 --- 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 diff --git a/include/filter.h b/include/filter.h index 48f8210..8e0740b 100644 --- a/include/filter.h +++ b/include/filter.h @@ -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 input[], complex 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); diff --git a/include/trace.h b/include/trace.h index 20e3186..bf06207 100644 --- a/include/trace.h +++ b/include/trace.h @@ -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); } diff --git a/libctsim/filter.cpp b/libctsim/filter.cpp index 27d1829..d3a3fbd 100644 --- a/libctsim/filter.cpp +++ b/libctsim/filter.cpp @@ -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(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(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 complexOutput[m_nSignalPoints]; complex 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); } diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index 1d90776..0182eec 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -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; diff --git a/src/if2img.cpp b/src/if2img.cpp index 1aa8a39..2547b51 100644 --- a/src/if2img.cpp +++ b/src/if2img.cpp @@ -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 @@ -25,12 +25,9 @@ ** 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 diff --git a/src/phm2if.cpp b/src/phm2if.cpp index a6a7e26..afac816 100644 --- a/src/phm2if.cpp +++ b/src/phm2if.cpp @@ -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); } diff --git a/src/phm2pj.cpp b/src/phm2pj.cpp index 439fa83..2734b2d 100644 --- a/src/phm2pj.cpp +++ b/src/phm2pj.cpp @@ -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); } diff --git a/src/pjrec.cpp b/src/pjrec.cpp index 0a2b2c8..782563c 100644 --- a/src/pjrec.cpp +++ b/src/pjrec.cpp @@ -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); } -- 2.34.1