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