projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r296: *** empty log message ***
[ctsim.git]
/
libctsim
/
imagefile.cpp
diff --git
a/libctsim/imagefile.cpp
b/libctsim/imagefile.cpp
index 851b4fdb6d953efb848259debe3e987cac3c7e84..3e97fb25c3db7315c25625e8a54ae373ab6299dd 100644
(file)
--- a/
libctsim/imagefile.cpp
+++ b/
libctsim/imagefile.cpp
@@
-9,7
+9,7
@@
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: imagefile.cpp,v 1.
18 2000/12/16 02:31:00
kevin Exp $
+** $Id: imagefile.cpp,v 1.
21 2000/12/17 19:08:06
kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
@@
-193,14
+193,14
@@
ImageFile::comparativeStatistics (const ImageFile& imComp, double& d, double& r,
bool
bool
-ImageFile::printComparativeStatistics (const ImageFile& imComp, ostream& os) const
+ImageFile::printComparativeStatistics (const ImageFile& imComp,
std::
ostream& os) const
{
double d, r, e;
if (comparativeStatistics (imComp, d, r, e)) {
{
double d, r, e;
if (comparativeStatistics (imComp, d, r, e)) {
-
os << " Normalized root mean squared distance (d): " << d <<
endl;
-
os << " Normalized mean absolute distance (r): " << r <<
endl;
-
os << "Worst case distance (2x2 pixel average) (e): " << e <<
endl;
+
os << " Normalized root mean squared distance (d): " << d << std::
endl;
+
os << " Normalized mean absolute distance (r): " << r << std::
endl;
+
os << "Worst case distance (2x2 pixel average) (e): " << e << std::
endl;
return true;
}
return false;
return true;
}
return false;
@@
-208,18
+208,18
@@
ImageFile::printComparativeStatistics (const ImageFile& imComp, ostream& os) con
void
void
-ImageFile::printStatistics (ostream& os) const
+ImageFile::printStatistics (
std::
ostream& os) const
{
double min, max, mean, mode, median, stddev;
statistics (min, max, mean, mode, median, stddev);
{
double min, max, mean, mode, median, stddev;
statistics (min, max, mean, mode, median, stddev);
- os << " min: " << min << endl;
- os << " max: " << max << endl;
- os << " mean: " << mean << endl;
- os << " mode: " << mode << endl;
- os << "median: " << median << endl;
- os << "stddev: " << stddev << endl;
+ os << " min: " << min <<
std::
endl;
+ os << " max: " << max <<
std::
endl;
+ os << " mean: " << mean <<
std::
endl;
+ os << " mode: " << mode <<
std::
endl;
+ os << "median: " << median <<
std::
endl;
+ os << "stddev: " << stddev <<
std::
endl;
}
}
@@
-274,20
+274,16
@@
ImageFile::statistics (double& min, double& max, double& mean, double& mode, dou
mode = (max_binindex * spread / (nbin - 1)) + min;
int nPixels = nx * ny;
mode = (max_binindex * spread / (nbin - 1)) + min;
int nPixels = nx * ny;
-
list
<double> vecImage;
+
std::vector
<double> vecImage;
for (int ix5 = 0; ix5 < nx; ix5++)
for (int iy = 0; iy < ny; iy++)
for (int ix5 = 0; ix5 < nx; ix5++)
for (int iy = 0; iy < ny; iy++)
- vecImage.push_front (v[ix5][iy]);
- vecImage.sort();
- list<double>::const_iterator iter = vecImage.begin();
- for (int i = 0; i < (nPixels / 2) - 1; i++)
- iter++; // Advance iterator to (nPixels / 2) - 1;
-
- if (nPixels % 2) { // Odd
- iter++;
- median = *iter;
- } else // Even
- median = (*iter++ + *iter) / 2;
+ vecImage.push_back (v[ix5][iy]);
+ std::sort(vecImage.begin(), vecImage.end());
\r
+
\r
+ if (nPixels % 2) // Odd
+ median = vecImage[((nPixels - 1) / 2)];
\r
+ else // Even
+ median = (vecImage[(nPixels / 2) - 1] + vecImage[nPixels / 2]) / 2;
}
}
@@
-399,7
+395,7
@@
ImageFile::writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nyc
int ny = m_ny;
ImageFileArray v = getArray();
int ny = m_ny;
ImageFileArray v = getArray();
- unsigned char
rowp
[nx * nxcell * (bitdepth / 8)];
+ unsigned char
* rowp = new unsigned char
[nx * nxcell * (bitdepth / 8)];
if ((fp = fopen (outfile, "wb")) == NULL)
return;
if ((fp = fopen (outfile, "wb")) == NULL)
return;
@@
-451,6
+447,7
@@
ImageFile::writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nyc
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
+ delete rowp;
\r
fclose(fp);
}
fclose(fp);
}