r121: *** empty log message ***
[ctsim.git] / include / imagefile.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **      Name:         imagefile.h
5 **      Purpose:      imagefile class header
6 **      Programmer:   Kevin Rosenberg
7 **      Date Started: June 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: imagefile.h,v 1.15 2000/06/26 21:15:24 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifndef IMAGEFILE_H
29 #define IMAGEFILE_H
30
31 #include <string>
32 #include <sys/types.h>
33 #include <unistd.h>
34 #include <fstream>
35 #include <iostream>
36 #include "ctsupport.h"
37 #include "fnetorderstream.h"
38 #include "array2dfile.h"
39
40 using namespace std;
41
42 #ifdef HAVE_MPI
43 #include <mpi++.h>
44 #endif
45
46 class F32Image : public Array2dFile
47 {
48 public:
49   F32Image (int nx, int ny)
50       : Array2dFile::Array2dFile (nx, ny, sizeof(kfloat32), Array2dFile::PIXEL_FLOAT32)
51   {
52   }
53
54   F32Image (void)
55       : Array2dFile::Array2dFile()
56   {
57       setPixelFormat (Array2dFile::PIXEL_FLOAT32);
58       setPixelSize (sizeof(kfloat32));
59   }
60
61   kfloat32** getArray (void)
62       { return (kfloat32**) (m_arrayData); }
63
64   const kfloat32** getArray (void) const
65        { return (const kfloat32**) (m_arrayData); }
66
67 #ifdef HAVE_MPI
68   MPI::Datatype getMPIDataType (void) const
69       { return MPI::FLOAT; }
70 #endif
71
72  private:
73   F32Image (const F32Image& rhs);             //copy constructor
74   F32Image& operator= (const F32Image& rhs);  // assignment operator
75 };
76
77
78 class F64Image : public Array2dFile
79 {
80  public:
81
82   F64Image (int nx, int ny)
83       : Array2dFile::Array2dFile (nx, ny, sizeof(kfloat64), Array2dFile::PIXEL_FLOAT64)
84   {
85   }
86
87   F64Image (void)
88       : Array2dFile::Array2dFile ()
89   {
90       setPixelFormat (PIXEL_FLOAT64);
91       setPixelSize (sizeof(kfloat64));
92   }
93
94   kfloat64** getArray (void)
95       { return (kfloat64**) (m_arrayData); }
96
97   const kfloat64** getArray (void) const
98       { return (const kfloat64**) (m_arrayData); }
99
100 #ifdef HAVE_MPI
101   MPI::Datatype getMPIDataType (void) const
102       { return MPI::DOUBLE; }
103 #endif
104  private:
105   F64Image (const F64Image& rhs);             //copy constructor
106   F64Image& operator= (const F64Image& rhs);  // assignment operator
107 };
108
109 #undef IMAGEFILE_64_BITS
110 #ifdef IMAGEFILE_64_BITS
111 typedef F64Image   ImageFileBase;
112 typedef kfloat64   ImageFileValue;
113 typedef kfloat64*  ImageFileColumn;
114 typedef kfloat64** ImageFileArray;
115 #else
116 typedef F32Image   ImageFileBase;
117 typedef kfloat32   ImageFileValue;
118 typedef kfloat32*  ImageFileColumn;
119 typedef kfloat32** ImageFileArray;
120 #endif
121
122
123 class ImageFile : public ImageFileBase
124 {
125  public:
126   ImageFile (int nx, int ny)
127       : ImageFileBase (nx, ny)
128   {}
129
130   ImageFile (void)
131       : ImageFileBase ()
132   {}
133
134   void filterResponse (const char* const domainName, double bw, const char* const filterName, double filt_param);
135
136   void statistics (double& min, double& max, double& mean, double& mode, double& median, double& stddev) const;
137
138   void printStatistics (ostream& os) const;
139
140   bool comparativeStatistics (const ImageFile& imComp, double& d, double& r, double& e) const;
141
142   bool printComparativeStatistics (const ImageFile& imComp, ostream& os) const;
143
144   int display (void);
145
146   int displayScaling (const int scaleFactor, ImageFileValue pmin, ImageFileValue pmax);
147
148 };
149
150
151 #endif