r256: *** empty log message ***
[ctsim.git] / libctsim / imagefile.cpp
index 803347f2e76f071c8fd1ae6b110ac04a84b61994..a751573aef3e35ab0ee60b80c7c37d603228966b 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: imagefile.cpp,v 1.17 2000/12/06 01:46:43 kevin Exp $
+**  $Id: imagefile.cpp,v 1.19 2000/12/16 02:44:26 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
@@ -256,7 +256,7 @@ ImageFile::statistics (double& min, double& max, double& mean, double& mode, dou
       for (int iy = 0; iy < ny; iy++) {
        int b = static_cast<int>((((v[ix4][iy] - min) / spread) * (nbin - 1)) + 0.5);
        hist[b]++;
-       double diff = (v[ix][iy] - mean);
+       double diff = (v[ix4][iy] - mean);
        stddev += diff * diff;
        }
     }
@@ -399,7 +399,7 @@ ImageFile::writeImagePNG (const char *outfile, int bitdepth, int nxcell, int nyc
   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;
@@ -451,6 +451,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);
+  delete rowp;\r
 
   fclose(fp);
 }