** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: imagefile.cpp,v 1.23 2000/12/21 03:40:58 kevin Exp $
+** $Id: imagefile.cpp,v 1.24 2000/12/22 04:18:00 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
}
}
}
+\r
+bool\r
+ImageFile::subtractImages (const ImageFile& rRHS, ImageFile& result) const\r
+{\r
+ if (m_nx != rRHS.nx() || m_ny != rRHS.ny() || m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::subtractImage]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArrayConst vRHS = rRHS.getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in1 = vLHS[ix];\r
+ ImageFileColumnConst in2 = vRHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ *out++ = *in1++ - *in2++;\r
+ }\r
+\r
+ return true;\r
+}\r
+bool\r
+ImageFile::addImages (const ImageFile& rRHS, ImageFile& result) const\r
+{\r
+ if (m_nx != rRHS.nx() || m_ny != rRHS.ny() || m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::subtractImage]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArrayConst vRHS = rRHS.getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in1 = vLHS[ix];\r
+ ImageFileColumnConst in2 = vRHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ *out++ = *in1++ + *in2++;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::multiplyImages (const ImageFile& rRHS, ImageFile& result) const\r
+{\r
+ if (m_nx != rRHS.nx() || m_ny != rRHS.ny() || m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::subtractImage]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArrayConst vRHS = rRHS.getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in1 = vLHS[ix];\r
+ ImageFileColumnConst in2 = vRHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ *out++ = *in1++ * *in2++;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::divideImages (const ImageFile& rRHS, ImageFile& result) const\r
+{\r
+ if (m_nx != rRHS.nx() || m_ny != rRHS.ny() || m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::subtractImage]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArrayConst vRHS = rRHS.getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in1 = vLHS[ix];\r
+ ImageFileColumnConst in2 = vRHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++) {\r
+ if (*in2 != 0.)\r
+ *out++ = *in1++ / *in2++;\r
+ else\r
+ *out++ = 0;\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+\r
void
ImageFile::writeImagePGM (const char *outfile, int nxcell, int nycell, double densmin, double densmax)
{