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.3 2000/06/22 10:17:28 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
96 image_filter_response (ImageFile& im, const char* const domainName, double bw, const char* const filterName, double filt_param, const int opt_trace)
100 ImageFileArray v = im.getArray();
102 for (int i = -hx; i <= hx; i++) {
103 for (int j = -hy; j <= hy; j++) {
104 double r = sqrt(i * i + j * j);
106 v[i+hx][j+hy] = SignalFilter::response (filterName, domainName, bw, r, filt_param);
107 if (opt_trace >= TRACE_PHM)
108 printf ("r=%8.4f, v=%8.4f\n", r, v[i+hx][j+hy]);
114 image_display (const ImageFile& im)
116 ImageFileValue pmin, pmax;
118 im.getPixelValueRange (pmin, pmax);
120 return (image_display_scale (im, 1, pmin, pmax));
123 int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax)
128 ImageFileArray v = im.getArray();
131 int pens [nx * ny * scale * scale ];
133 double view_scale = 255 / (pmax - pmin);
134 int id_X11 = g2_open_X11 (nx * scale, ny * scale);
136 for (int i = 0; i < 256; i++) {
137 double cval = i / 255.;
138 grayscale[i] = g2_ink (id_X11, cval, cval, cval);
141 for (int i= 0, iy = ny - 1; iy >= 0; iy--) {
142 for (int ix = 0; ix < nx; ix++) {
143 int cval = static_cast<int>((v[ix][iy] - pmin) * view_scale);
148 pens[i++] = grayscale[cval];
152 g2_image (id_X11, 0., 0., nx, ny, pens);