1 /*****************************************************************************
5 ** Purpose: Imagefile classes
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: June 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: imagefile.cpp,v 1.1 2000/06/19 02:59:34 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
31 ///////////////////////////////////////////////////////////////////////////
32 // CLASS IMPLEMENTATION
34 // Name: Array2dFileLabel
35 // Purpose: Labels for Array2dFiles
36 ///////////////////////////////////////////////////////////////////////////
39 Array2dFileLabel::init (void)
42 m_labelType = L_EMPTY;
49 m_minute = td.t.minute;
50 m_second = td.t.second;
53 Array2dFileLabel::Array2dFileLabel()
58 Array2dFileLabel::Array2dFileLabel(const char* const str, double ctime = 0.)
67 Array2dFileLabel::Array2dFileLabel(const int type, const char* const str, double ctime = 0.)
76 Array2dFileLabel::~Array2dFileLabel()
81 Array2dFileLabel::getDateString (void) const
84 oss << m_month <<"/"<< m_day <<"/"<< m_year << " " << m_hour <<":"<< m_minute <<":"<< m_second;
85 m_strDate = oss.str();
91 * image.c Routines for managing images
93 * PROGRAMMER: Kevin Rosenberg
97 * Provides a set of routines for handling image files
102 image_filter_response (ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace)
104 int hx = im.nx() / 2;
105 int hy = im.ny() / 2;
106 ImageFileArray v = im.getArray();
108 for (int i = -hx; i <= hx; i++) {
109 for (int j = -hy; j <= hy; j++) {
110 double r = sqrt(i * i + j * j);
112 if (domain == D_SPATIAL)
113 v[i+hx][j+hy] = filter_spatial_response_analytic (filt_type, r, bw, filt_param);
115 v[i+hx][j+hy] = filter_frequency_response (filt_type, r, bw, filt_param);
116 if (opt_trace >= TRACE_PHM)
117 printf ("r=%8.4f, v=%8.4f\n", r, v[i+hx][j+hy]);
123 image_display (const ImageFile& im)
125 ImageFileValue pmin, pmax;
127 im.getPixelValueRange (pmin, pmax);
129 return (image_display_scale (im, 1, pmin, pmax));
132 int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax)
137 ImageFileArray v = im.getArray();
140 int* pens = new int [nx * ny * scale * scale ];
142 double view_scale = 255 / (pmax - pmin);
143 int id_X11 = g2_open_X11 (nx * scale, ny * scale);
145 for (int i = 0; i < 256; i++) {
146 double cval = i / 255.;
147 grayscale[i] = g2_ink (id_X11, cval, cval, cval);
150 for (int i= 0, iy = ny - 1; iy >= 0; iy--) {
151 for (int ix = 0; ix < nx; ix++) {
152 int cval = (int) ((v[ix][iy] - pmin) * view_scale);
157 pens[i++] = grayscale[cval];
161 g2_image (id_X11, 0., 0., nx, ny, pens);