From fff4beb84fcc84e65e4feb457e2ed25c7774cff4 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 19 Jun 2000 19:54:23 +0000 Subject: [PATCH] r113: *** empty log message *** --- ChangeLog | 5 +- NEWS | 5 +- README | 20 +++---- configure | 2 +- configure.in | 2 +- libctsim/Makefile.am | 2 +- libctsim/phantom.cpp | 80 ++++++++++++++++++++++++- libctsim/phm2image.cpp | 132 ----------------------------------------- 8 files changed, 98 insertions(+), 150 deletions(-) delete mode 100644 libctsim/phm2image.cpp diff --git a/ChangeLog b/ChangeLog index 1bb4c6b..fe5bd6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -1.9.2 - 6/17/2000 +1.9.3 - 6/19/2000 + Reorganized source file + +1.9.2 - 6/18/2000 Reorganized include files Fixed const pointers in strfuncs diff --git a/NEWS b/NEWS index d10d07d..3361499 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,2 @@ -Now, CTSim uses C++ and has cross-platform compatible data files. - -In the next release, interactive graphics will be added. +6/17/2000 + CTSim converted to C++ and has cross-platform compatible data files. diff --git a/README b/README index 5e16d8e..2028fad 100644 --- a/README +++ b/README @@ -38,7 +38,7 @@ OVERVIEW -------- CTSim simulates the collection of x-rays by a CT scanner. These x-rays -of objects are called projections or raysums. +of objects are called projections. Phantom objects are defined. Several built-in phantoms are included, as well as an extension to load files of phantom definitions. @@ -51,20 +51,20 @@ based on a image file format used by the Jet Propulsion Laboratory THE PROGRAMS ------------ -phm2sdf - generates an SDF image of a phantom object +phm2if - generates an image file of a phantom object -phm2rs - Simulates the collection of CT data, or raysums, of a phantom +phm2pj - Simulates the collection of CT data, or projections, of a phantom object ctrec - Performs an CT reconstruction, also known as image -reconstruction from projections. Reads a raysum file and writes a SDF +reconstruction from projections. Reads a projection file and writes a SDF file. -rs2sdf - Converts raysum data to a raw sinugram image +pj2if - Converts projection data to a raw sinugram image -sdf2img - Converts an SDF file to a variety of 8-bit image formats +if2img - Converts an image file to a variety of 8-bit and 16-bit image formats -sdfinfo - Show statistics and history labels of SDF files +ifinfo - Show statistics and history labels of SDF files TYPICAL USAGE ------------- @@ -75,9 +75,9 @@ Create a phantom image and viewable image file phm2sdf ... sdf2img ... -Simulate CT data collection and create a viewable image of raw raysums - phm2rs ... - rs2sdf ... +Simulate CT data collection and create a viewable image of raw projections + phm2pj ... + pj2sdf ... sdf2img ... Perform CT reconstruction and create viewable image file diff --git a/configure b/configure index b525481..5b11285 100755 --- a/configure +++ b/configure @@ -711,7 +711,7 @@ fi PACKAGE=ctsim -VERSION=1.9.2 +VERSION=1.9.3 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index 2e4a23d..b63f09a 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout dnl CDPATH= AC_INIT(src/ctrec.cpp) -AM_INIT_AUTOMAKE(ctsim,1.9.2) +AM_INIT_AUTOMAKE(ctsim,1.9.3) AM_CONFIG_HEADER(config.h) dnl Checks for programs. diff --git a/libctsim/Makefile.am b/libctsim/Makefile.am index 0c1b79b..3cc76ac 100644 --- a/libctsim/Makefile.am +++ b/libctsim/Makefile.am @@ -1,5 +1,5 @@ noinst_LIBRARIES = libctsim.a -libctsim_a_SOURCES = filter.cpp scanner.cpp projections.cpp phantom.cpp options.cpp convolve.cpp reconstr.cpp phm2image.cpp imagefile.cpp reconstr.cpp phm2image.cpp backprojectors.cpp projections.cpp +libctsim_a_SOURCES = filter.cpp scanner.cpp projections.cpp phantom.cpp options.cpp convolve.cpp reconstr.cpp imagefile.cpp reconstr.cpp backprojectors.cpp INCLUDES=@my_includes@ EXTRA_DIST=Makefile.nt diff --git a/libctsim/phantom.cpp b/libctsim/phantom.cpp index 1508bea..e28074f 100644 --- a/libctsim/phantom.cpp +++ b/libctsim/phantom.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phantom.cpp,v 1.1 2000/06/19 02:59:34 kevin Exp $ +** $Id: phantom.cpp,v 1.2 2000/06/19 19:54:23 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 @@ -315,6 +315,84 @@ Phantom::std_herman (void) } +/* NAME + * convertToImagefile Make image array from Phantom + * + * SYNOPSIS + * pic_to_imagefile (pic, im, nsample) + * Phantom& pic Phantom definitions + * ImageFile *im Computed pixel array + * int nsample Number of samples along each axis for each pixel + * (total samples per pixel = nsample * nsample) + */ + +void +Phantom::convertToImagefile (ImageFile& im, const int colStart, const int colCount, const int in_nsample, const int trace) const +{ + int nx = im.nx(); + int ny = im.ny(); + if (nx < 2 || ny < 2) + return; + + if (nsample < 1) + nsample = 1; + + int nsample = in_nsample; + double dx = m_xmax - m_xmin; + double dy = m_ymax - m_ymin; + double xcent = m_xmin + dx / 2; + double ycent = m_ymin + dy / 2; + double phmlen = (dx > dy ? dx : dy); + + double phmradius = phmlen / 2; + + double xmin = xcent - phmradius; + double xmax = xcent + phmradius; + double ymin = ycent - phmradius; + double ymax = ycent + phmradius; + + // Each pixel holds the average of the intensity of the cell with (ix,iy) at the center of the pixel + // Set major increments so that the last cell v[nx-1][ny-1] will start at xmax - xinc, ymax - yinc). + // Set minor increments so that sample points are centered in cell + + double xinc = (xmax - xmin) / nx; + double yinc = (ymax - ymin) / ny; + + double kxinc = xinc / nsample; /* interval between samples */ + double kyinc = yinc / nsample; + double kxofs = kxinc / 2; /* offset of 1st point */ + double kyofs = kyinc / 2; + + im.setAxisExtent (xmin, xmax, ymin, ymax); + im.setAxisIncrement (xinc, yinc); + + ImageFileArray v = im.getArray(); + + double x_start = xmin + (colStart * xinc); + for (PElemConstIterator pelem = m_listPElem.begin; pelem != m_listPElem.end; pelem++) { + double x, y, xi, yi; + int ix, iy, kx, ky; + for (ix = 0, x = x_start; ix < colCount; ix++, x += xinc) { + for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) { + for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) { + for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc) + if ((*pelem)->isPointInside (xi, yi, PHM_COORD) == TRUE) + v[ix][iy] += (*pelem)->atten(); + } // for kx + } /* for iy */ + } /* for ix */ + } /* for pelem */ + + + if (nsample > 1) { + double factor = 1.0 / (nsample * nsample); + + for (int ix = 0; ix < colCount; ix++) + for (int iy = 0; iy < ny; iy++) + v[ix][iy] *= factor; + } +} + //////////////////////////////////////////////////////////////////////////////////////////////////////// // CLASS IDENTIFICATION // diff --git a/libctsim/phm2image.cpp b/libctsim/phm2image.cpp deleted file mode 100644 index 3e65e58..0000000 --- a/libctsim/phm2image.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** -** FILE IDENTIFICATION -** -** Name: phm2image.cpp -** Purpose: Convert phantom objects to rasterized images -** Programmer: Kevin Rosenberg -** Date Started: 1984 -** -** This part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: phm2image.cpp,v 1.1 2000/06/19 02:59: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 -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ - -#include "ct.h" - - -/* NAME - * pic_to_imagefile Make image array from Phantom - * - * SYNOPSIS - * pic_to_imagefile (pic, im, nsample) - * Phantom& pic Phantom definitions - * ImageFile *im Computed pixel array - * int nsample Number of samples along each axis for each pixel - * (total samples per pixel = nsample * nsample) - */ - -void -phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int in_nsample, const int trace) -{ - int nsample = in_nsample; - double dx = phm.xmax() - phm.xmin(); - double dy = phm.ymax() - phm.ymin(); - double xcent = phm.xmin() + dx / 2; - double ycent = phm.ymin() + dy / 2; - double phmlen = (dx > dy ? dx : dy); - - double phmradius = phmlen / 2; - - double xmin = xcent - phmradius; - double xmax = xcent + phmradius; - double ymin = ycent - phmradius; - double ymax = ycent + phmradius; - - im.setAxisExtent (xmin, xmax, ymin, ymax); - int nx = im.nx(); - int ny = im.ny(); - -/* Each pixel holds the average of the intensity of the cell with (ix,iy) - * at the center of the pixel - * - * Set major increments so that the last cell v[nx-1][ny-1] will start at - * (xmax - xinc, ymax - yinc). - * - * Set minor increments so that sample points are centered in cell - */ - - if (nx < 2 || ny < 2) - return; - - double xinc = (xmax - xmin) / nx; - double yinc = (ymax - ymin) / ny; - im.setAxisIncrement (xinc, yinc); - - if (nsample < 1) - nsample = 1; - - double kxinc = xinc / nsample; /* interval between samples */ - double kyinc = yinc / nsample; - double kxofs = kxinc / 2; /* offset of 1st point */ - double kyofs = kyinc / 2; - -#ifdef HAVE_SGP - SGP_ID gid = NULL; - if (trace > TRACE_TEXT) { - gid = sgp2_init (0, 0, "Phantom to Image"); - sgp2_window (xmin, ymin, xmax, ymax); - sgp2_frame_vpt(); - } -#endif - - ImageFileArray v = im.getArray(); - - double x_start = xmin + (col_start * xinc); - for (PElemConstIterator i = phm.listPElem().begin(); i != phm.listPElem().end(); i++) { -#ifdef HAVE_SGP - if (trace > TRACE_TEXT) - sgp2_polyline_abs ((*i)->xOutline(), (*i)->yOutline(), (*i)->nOutlinePoints()); -#endif - double x, y, xi, yi; - int ix, iy, kx, ky; - for (ix = 0, x = x_start; ix < col_count; ix++, x += xinc) { - for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) { - for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) { - for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc) - if ((*i)->isPointInside (xi, yi, PHM_COORD) == TRUE) - v[ix][iy] += (*i)->atten(); - } // for kx - } /* for iy */ - } /* for ix */ - } /* for pelem */ - - - if (nsample > 0) { - double factor = 1.0 / (nsample * nsample); - - for (int ix = 0; ix < col_count; ix++) - for (int iy = 0; iy < ny; iy++) - v[ix][iy] *= factor; - } - -#if HAVE_SGP - if (trace > TRACE_TEXT) - sgp2_close(gid); -#endif - -} - -- 2.34.1