r244: *** 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.20 2000/12/04 05:36:57 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 #ifndef MSVC\r
32 #include <unistd.h>\r
33 #endif\r
34 #include <string>
35 #include <sys/types.h>
36 #include <fstream>
37 #include <iostream>
38 #include "ctsupport.h"
39 #include "fnetorderstream.h"
40 #include "array2dfile.h"
41
42 using namespace std;
43
44 #ifdef HAVE_MPI
45 #include <mpi++.h>
46 #endif
47
48 class F32Image : public Array2dFile
49 {
50 public:
51   F32Image (int nx, int ny);     
52   F32Image (void);\r
53
54   kfloat32** getArray (void)
55       { return (kfloat32**) (m_arrayData); }
56
57   const kfloat32* const * getArray (void) const
58        { return (const kfloat32**) (m_arrayData); }
59
60 #ifdef HAVE_MPI
61   MPI::Datatype getMPIDataType (void) const
62       { return MPI::FLOAT; }
63 #endif
64
65  private:
66   F32Image (const F32Image& rhs);             //copy constructor
67   F32Image& operator= (const F32Image& rhs);  // assignment operator
68 };
69
70
71 class F64Image : public Array2dFile
72 {
73  public:
74
75   F64Image (int nx, int ny);
76   F64Image (void);
77
78   kfloat64** getArray (void)
79       { return (kfloat64**) (m_arrayData); }
80
81   const kfloat64* const * getArray (void) const
82       { return (const kfloat64**) (m_arrayData); }
83
84 #ifdef HAVE_MPI
85   MPI::Datatype getMPIDataType (void) const
86       { return MPI::DOUBLE; }
87 #endif
88  private:
89   F64Image (const F64Image& rhs);             //copy constructor
90   F64Image& operator= (const F64Image& rhs);  // assignment operator
91 };
92
93 #undef IMAGEFILE_64_BITS
94 #ifdef IMAGEFILE_64_BITS
95 typedef F64Image   ImageFileBase;
96 typedef kfloat64   ImageFileValue;
97 typedef kfloat64*  ImageFileColumn;
98 typedef kfloat64** ImageFileArray;
99 typedef const kfloat64* const * ImageFileArrayConst;
100 #else
101 typedef F32Image   ImageFileBase;
102 typedef kfloat32   ImageFileValue;
103 typedef kfloat32*  ImageFileColumn;
104 typedef kfloat32** ImageFileArray;
105 typedef const kfloat32* const * ImageFileArrayConst;
106 #endif
107
108
109 class ImageFile : public ImageFileBase
110 {
111  public:
112   ImageFile (int nx, int ny)
113       : ImageFileBase (nx, ny)
114   {}
115
116   ImageFile (void)
117       : ImageFileBase ()
118   {}
119
120   void filterResponse (const char* const domainName, double bw, const char* const filterName, double filt_param);
121
122   void statistics (double& min, double& max, double& mean, double& mode, double& median, double& stddev) const;
123
124   void getMinMax (double& min, double& max) const;
125
126   void printStatistics (ostream& os) const;
127
128   bool comparativeStatistics (const ImageFile& imComp, double& d, double& r, double& e) const;
129
130   bool printComparativeStatistics (const ImageFile& imComp, ostream& os) const;
131
132   int display (void) const;
133
134   int displayScaling (const int scaleFactor, ImageFileValue pmin, ImageFileValue pmax) const;
135
136 #if HAVE_PNG
137   void writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nycell, double densmin, double densmax);
138 #endif
139 #if HAVE_GD
140   void writeImageGIF (const char *outfile, int nxcell, int nycell, double densmin, double densmax);
141 #endif
142   void writeImagePGM (const char *outfile, int nxcell, int nycell, double densmin, double densmax);
143   void writeImagePGMASCII (const char *outfile, int nxcell, int nycell, double densmin, double densmax);
144 };
145
146
147 #endif