1 /*****************************************************************************
5 ** Purpose: imagefile class header
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.h,v 1.24 2000/12/29 15:45:06 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 ******************************************************************************/
35 #include <sys/types.h>
38 #include "ctsupport.h"
39 #include "fnetorderstream.h"
40 #include "array2dfile.h"
46 class F32Image : public Array2dFile
49 F32Image (int nx, int ny);
52 kfloat32** getArray (void)
53 { return (kfloat32**) (m_arrayData); }
55 kfloat32** const getArray (void) const
56 { return (kfloat32** const) (m_arrayData); }
59 MPI::Datatype getMPIDataType (void) const
60 { return MPI::FLOAT; }
64 F32Image (const F32Image& rhs); //copy constructor
65 F32Image& operator= (const F32Image& rhs); // assignment operator
69 class F64Image : public Array2dFile
73 F64Image (int nx, int ny);
76 kfloat64** getArray (void)
77 { return (kfloat64**) (m_arrayData); }
79 kfloat64** const getArray (void) const
80 { return (kfloat64** const) (m_arrayData); }
83 MPI::Datatype getMPIDataType (void) const
84 { return MPI::DOUBLE; }
87 F64Image (const F64Image& rhs); //copy constructor
88 F64Image& operator= (const F64Image& rhs); // assignment operator
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 kfloat64** const ImageFileArrayConst;
\r
98 typedef const kfloat64* ImageFileColumnConst;
100 typedef F32Image ImageFileBase;
101 typedef kfloat32 ImageFileValue;
102 typedef kfloat32* ImageFileColumn;
103 typedef kfloat32** ImageFileArray;
104 typedef kfloat32** const ImageFileArrayConst;
105 typedef const kfloat32* ImageFileColumnConst;
\r
109 class ImageFile : public ImageFileBase
112 ImageFile (int nx, int ny)
113 : ImageFileBase (nx, ny)
120 void filterResponse (const char* const domainName, double bw, const char* const filterName, double filt_param);
122 void statistics (double& min, double& max, double& mean, double& mode, double& median, double& stddev) const;
123 void getMinMax (double& min, double& max) const;
124 void printStatistics (std::ostream& os) const;
125 bool comparativeStatistics (const ImageFile& imComp, double& d, double& r, double& e) const;
126 bool printComparativeStatistics (const ImageFile& imComp, std::ostream& os) const;
128 bool subtractImages (const ImageFile& rRHS, ImageFile& result) const;
129 bool addImages (const ImageFile& rRHS, ImageFile& result) const;
\r
130 bool multiplyImages (const ImageFile& rRHS, ImageFile& result) const;
\r
131 bool divideImages (const ImageFile& rRHS, ImageFile& result) const;
\r
133 bool invertPixelValues (ImageFile& result) const;
\r
134 bool sqrt (ImageFile& result) const;
\r
135 bool square (ImageFile& result) const;
\r
136 bool log (ImageFile& result) const;
\r
137 bool exp (ImageFile& result) const;
\r
138 bool FFTMagnitude (ImageFile& result) const;
\r
139 bool FFTPhase (ImageFile& result) const;
\r
141 int display (void) const;
142 int displayScaling (const int scaleFactor, ImageFileValue pmin, ImageFileValue pmax) const;
145 void writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nycell, double densmin, double densmax);
148 void writeImageGIF (const char *outfile, int nxcell, int nycell, double densmin, double densmax);
150 void writeImagePGM (const char *outfile, int nxcell, int nycell, double densmin, double densmax);
151 void writeImagePGMASCII (const char *outfile, int nxcell, int nycell, double densmin, double densmax);