+bool\r
+ImageFile::invertPixelValues (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in = vLHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ *out++ = - *in++;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::sqrt (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in = vLHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ if (*in < 0)\r
+ *out++ = -::sqrt(-*in++);\r
+ else\r
+ *out++ = ::sqrt(*in++);\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::log (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in = vLHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ if (*in <= 0)\r
+ *out++ = 0;\r
+ else\r
+ *out++ = ::log(*in++);\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::exp (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in = vLHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++)\r
+ *out++ = ::exp (*in++);\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::FFTMagnitude (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ int ix, iy;\r
+ double* pY = new double [m_ny];\r
+ std::complex<double>** complexOut = new std::complex<double>* [m_nx];\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix] = new std::complex<double> [m_ny];\r
+\r
+ for (ix = 0; ix < m_nx; ix++) {\r
+ for (iy = 0; iy < m_ny; iy++)\r
+ pY[iy] = vLHS[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
+ }\r
+ delete pY;\r
+\r
+ std::complex<double>* pX = new std::complex<double> [m_nx];\r
+ std::complex<double>* complexOutCol = new std::complex<double> [m_nx];\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ pX[ix] = complexOut[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (pX, complexOutCol, m_nx, ProcessSignal::FORWARD);\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutCol[ix];\r
+ }\r
+ delete [] pX;\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ ProcessSignal::shuffleFourierToNaturalOrder (complexOut[ix], m_ny);\r
+\r
+ \r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOutCol[ix] = complexOut[ix][iy];\r
+ ProcessSignal::shuffleFourierToNaturalOrder (complexOutCol, m_nx);;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutCol[ix];\r
+\r
+ }\r
+ delete [] complexOutCol;\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++)\r
+ vResult[ix][iy] = std::abs (complexOut[ix][iy]);\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ delete [] complexOut[ix];\r
+\r
+ delete [] complexOut;\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::FFTPhase (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ int ix, iy;\r
+ double* pY = new double [m_ny];\r
+ std::complex<double>** complexOut = new std::complex<double>* [m_nx];\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix] = new std::complex<double> [m_ny];\r
+\r
+ for (ix = 0; ix < m_nx; ix++) {\r
+ for (iy = 0; iy < m_ny; iy++)\r
+ pY[iy] = vLHS[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (pY, complexOut[ix], m_ny, ProcessSignal::FORWARD);\r
+ }\r
+ delete pY;\r
+\r
+ std::complex<double>* pX = new std::complex<double> [m_nx];\r
+ std::complex<double>* complexOutCol = new std::complex<double> [m_nx];\r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ pX[ix] = complexOut[ix][iy];\r
+ ProcessSignal::finiteFourierTransform (pX, complexOutCol, m_nx, ProcessSignal::FORWARD);\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutCol[ix];\r
+ }\r
+ delete [] pX;\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ ProcessSignal::shuffleFourierToNaturalOrder (complexOut[ix], m_ny);\r
+\r
+ \r
+ for (iy = 0; iy < m_ny; iy++) {\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOutCol[ix] = complexOut[ix][iy];\r
+ ProcessSignal::shuffleFourierToNaturalOrder (complexOutCol, m_nx);;\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ complexOut[ix][iy] = complexOutCol[ix];\r
+\r
+ }\r
+ delete [] complexOutCol;\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ for (iy = 0; iy < m_ny; iy++)\r
+ vResult[ix][iy] = atan (complexOut[ix][iy].imag / complexOut[ix][iy].real);\r
+\r
+ for (ix = 0; ix < m_nx; ix++)\r
+ delete [] complexOut[ix];\r
+\r
+ delete [] complexOut;\r
+\r
+ return true;\r
+}\r
+\r
+bool\r
+ImageFile::square (ImageFile& result) const\r
+{\r
+ if (m_nx != result.nx() || m_ny != result.ny()) {\r
+ sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]");\r
+ return false;\r
+ }\r
+\r
+ ImageFileArrayConst vLHS = getArray();\r
+ ImageFileArray vResult = result.getArray();\r
+\r
+ for (int ix = 0; ix < m_nx; ix++) {\r
+ ImageFileColumnConst in = vLHS[ix];\r
+ ImageFileColumn out = vResult[ix];\r
+ for (int iy = 0; iy < m_ny; iy++) {\r
+ *out++ = *in * *in;\r
+ in++;\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+\r