X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=libctsim%2Fphm2image.cpp;fp=libctsim%2Fphm2image.cpp;h=0000000000000000000000000000000000000000;hb=fff4beb84fcc84e65e4feb457e2ed25c7774cff4;hp=3e65e58a2d0b29b3efdaa6984a3d06cb6900e567;hpb=37ccf79b1044c04db41f5cf924f63c75be1c2366;p=ctsim.git 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 - -} -