X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fimagefile.cpp;h=bab87bdeff5ab0fa4486a66f629089e85efd4d91;hp=134a0c59f2ed525762ec893f118402c39511b452;hb=3ea498d51ce4597e9649cd21f155b51175ea0bea;hpb=c358b8c8b5649f14e2b8203b999ba8549a244727 diff --git a/libctsim/imagefile.cpp b/libctsim/imagefile.cpp index 134a0c5..bab87bd 100644 --- a/libctsim/imagefile.cpp +++ b/libctsim/imagefile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: imagefile.cpp,v 1.38 2001/03/01 20:02:18 kevin Exp $ +** $Id: imagefile.cpp,v 1.42 2001/03/21 21:45:31 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 @@ -26,6 +26,9 @@ ******************************************************************************/ #include "ct.h" +#ifdef HAVE_CTN_DICOM +#include "ctndicom.h" +#endif const double ImageFile::s_dRedGrayscaleFactor = 0.299; const double ImageFile::s_dGreenGrayscaleFactor = 0.587; @@ -33,18 +36,20 @@ const double ImageFile::s_dBlueGrayscaleFactor = 0.114; const int ImageFile::EXPORT_FORMAT_INVALID = -1; -const int ImageFile::EXPORT_FORMAT_PGM = 0; -const int ImageFile::EXPORT_FORMAT_PGMASCII = 1; +const int ImageFile::EXPORT_FORMAT_TEXT = 0; +const int ImageFile::EXPORT_FORMAT_PGM = 1; +const int ImageFile::EXPORT_FORMAT_PGMASCII = 2; #ifdef HAVE_PNG -const int ImageFile::EXPORT_FORMAT_PNG = 2; -const int ImageFile::EXPORT_FORMAT_PNG16 = 3; +const int ImageFile::EXPORT_FORMAT_PNG = 3; +const int ImageFile::EXPORT_FORMAT_PNG16 = 4; #endif #ifdef HAVE_CTN_DICOM -const int ImageFile::EXPORT_FORMAT_DICOM = 4; +const int ImageFile::EXPORT_FORMAT_DICOM = 5; #endif const char* ImageFile::s_aszExportFormatName[] = { + {"text"}, {"pgm"}, {"pgmascii"}, #ifdef HAVE_PNG @@ -58,6 +63,7 @@ const char* ImageFile::s_aszExportFormatName[] = const char* ImageFile::s_aszExportFormatTitle[] = { + {"Text"}, {"PGM"}, {"PGM ASCII"}, {"PNG"}, @@ -144,7 +150,8 @@ ImageFile::getCenterCoordinates (unsigned int& iXCenter, unsigned int& iYCenter) void -ImageFile::filterResponse (const char* const domainName, double bw, const char* const filterName, double filt_param, double dInputScale, double dOutputScale) +ImageFile::filterResponse (const char* const domainName, double bw, const char* const filterName, + double filt_param, double dInputScale, double dOutputScale) { ImageFileArray v = getArray(); SignalFilter filter (filterName, domainName, bw, filt_param); @@ -160,60 +167,6 @@ ImageFile::filterResponse (const char* const domainName, double bw, const char* } } -int -ImageFile::display (void) const -{ - double pmin, pmax; - - getMinMax (pmin, pmax); - - return (displayScaling (1, pmin, pmax)); -} - -int -ImageFile::displayScaling (const int scale, const ImageFileValue pmin, const ImageFileValue pmax) const -{ - int nx = m_nx; - int ny = m_ny; - ImageFileArrayConst v = getArray(); - if (v == NULL || nx == 0 || ny == 0) - return 0; - -#if HAVE_G2_H - int* pPens = new int [nx * ny * scale * scale ]; - - double view_scale = 255 / (pmax - pmin); - int id_X11 = g2_open_X11 (nx * scale, ny * scale); - int grayscale[256]; - for (int i = 0; i < 256; i++) { - double cval = i / 255.; - grayscale[i] = g2_ink (id_X11, cval, cval, cval); - } - - for (int iy = ny - 1; iy >= 0; iy--) { - int iRowPos = ((ny - 1 - iy) * scale) * (nx * scale); - for (int ix = 0; ix < nx; ix++) { - int cval = static_cast((v[ix][iy] - pmin) * view_scale); - if (cval < 0) - cval = 0; - else if (cval > 255) - cval = 255; - for (int sy = 0; sy < scale; sy++) - for (int sx = 0; sx < scale; sx++) - pPens[iRowPos+(sy * nx * scale)+(sx + (ix * scale))] = grayscale[cval]; - } - } - - g2_image (id_X11, 0., 0., nx * scale, ny * scale, pPens); - - delete pPens; - return (id_X11); -#else - return 0; -#endif -} - - // ImageFile::comparativeStatistics Calculate comparative stats // @@ -644,7 +597,7 @@ bool ImageFile::log (ImageFile& result) const { if (m_nx != result.nx() || m_ny != result.ny()) { - sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]"); + sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::log]"); return false; } @@ -666,8 +619,12 @@ ImageFile::log (ImageFile& result) const std::complex cResult = std::log (cLHS); vResult[ix][iy] = cResult.real(); vResultImag[ix][iy] = cResult.imag(); - } else - vResult[ix][iy] = ::log (vLHS[ix][iy]); + } else { + if (vLHS[ix][iy] > 0) + vResult[ix][iy] = ::log (vLHS[ix][iy]); + else + vResult[ix][iy] = 0; + } } } @@ -729,40 +686,22 @@ ImageFile::scaleImage (ImageFile& result) const ImageFileArray vResult = result.getArray(); ImageFileArray vResultImag = result.getImaginaryArray(); + BilinearInterpolator realInterp (vReal, nx, ny); + BilinearInterpolator imagInterp (vImag, nx, ny); + for (unsigned int ix = 0; ix < newNX; ix++) { for (unsigned int iy = 0; iy < newNY; iy++) { double dXPos = ix / dXScale; double dYPos = iy / dYScale; - unsigned int scaleNX = static_cast (dXPos); - unsigned int scaleNY = static_cast (dYPos); - double dXFrac = dXPos - scaleNX; - double dYFrac = dYPos - scaleNY; - if (scaleNX >= nx - 1 || scaleNY >= ny - 1) { - vResult[ix][iy] = vReal[scaleNX][scaleNY]; - if (result.isComplex()) { - if (isComplex()) - vResultImag[ix][iy] = vImag[scaleNX][scaleNY]; - else - vResultImag[ix][iy] = 0; - } - } else { - vResult[ix][iy] = (1 - dXFrac) * (1 - dYFrac) * vReal[scaleNX][scaleNY] + - dXFrac * (1 - dYFrac) * vReal[scaleNX+1][scaleNY] + - dYFrac * (1 - dXFrac) * vReal[scaleNX][scaleNY+1] + - dXFrac * dYFrac * vReal[scaleNX+1][scaleNY+1]; - if (result.isComplex()) { - if (isComplex()) - vResultImag[ix][iy] = (1 - dXFrac) * (1 - dYFrac) * vImag[scaleNX][scaleNY] + - dXFrac * (1 - dYFrac) * vImag[scaleNX+1][scaleNY] + - dYFrac * (1 - dXFrac) * vImag[scaleNX][scaleNY+1] + - dXFrac * dYFrac * vImag[scaleNX+1][scaleNY+1]; - else - vResultImag[ix][iy] = 0; - } - } + vResult[ix][iy] = realInterp.interpolate (dXPos, dYPos); + if (result.isComplex()) + if (isComplex()) + vResultImag[ix][iy] = imagInterp.interpolate (dXPos, dYPos); + else + vResultImag[ix][iy] = 0; } } - + return true; } @@ -787,7 +726,7 @@ ImageFile::fft (ImageFile& result) const unsigned int ix, iy; unsigned int iArray = 0; - for (ix = 0; ix < m_nx; ix++) + for (ix = 0; ix < m_nx; ix++) { for (iy = 0; iy < m_ny; iy++) { in[iArray].re = vReal[ix][iy]; if (isComplex()) @@ -796,29 +735,28 @@ ImageFile::fft (ImageFile& result) const in[iArray].im = 0; iArray++; } - - fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_FORWARD, FFTW_IN_PLACE); - - fftwnd_one (plan, in, NULL); - - ImageFileArray vRealResult = result.getArray(); - ImageFileArray vImagResult = result.getImaginaryArray(); - iArray = 0; - unsigned int iScale = m_nx * m_ny; - for (ix = 0; ix < m_nx; ix++) - for (iy = 0; iy < m_ny; iy++) { - vRealResult[ix][iy] = in[iArray].re / iScale; - vImagResult[ix][iy] = in[iArray].im / iScale; - iArray++; - } - - fftwnd_destroy_plan (plan); - delete in; - - - Fourier::shuffleFourierToNaturalOrder (result); - - return true; + } + + fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); + fftwnd_one (plan, in, NULL); + + ImageFileArray vRealResult = result.getArray(); + ImageFileArray vImagResult = result.getImaginaryArray(); + iArray = 0; + unsigned int iScale = m_nx * m_ny; + for (ix = 0; ix < m_nx; ix++) { + for (iy = 0; iy < m_ny; iy++) { + vRealResult[ix][iy] = in[iArray].re / iScale; + vImagResult[ix][iy] = in[iArray].im / iScale; + iArray++; + } + } + delete in; + fftwnd_destroy_plan (plan); + + Fourier::shuffleFourierToNaturalOrder (result); + + return true; } @@ -840,7 +778,7 @@ ImageFile::ifft (ImageFile& result) const ImageFileArray vRealResult = result.getArray(); ImageFileArray vImagResult = result.getImaginaryArray(); unsigned int ix, iy; - for (ix = 0; ix < m_nx; ix++) + for (ix = 0; ix < m_nx; ix++) { for (iy = 0; iy < m_ny; iy++) { vRealResult[ix][iy] = vReal[ix][iy]; if (isComplex()) @@ -848,36 +786,38 @@ ImageFile::ifft (ImageFile& result) const else vImagResult[ix][iy] = 0; } - - Fourier::shuffleNaturalToFourierOrder (result); - - fftw_complex* in = new fftw_complex [m_nx * m_ny]; - - unsigned int iArray = 0; - for (ix = 0; ix < m_nx; ix++) - for (iy = 0; iy < m_ny; iy++) { - in[iArray].re = vRealResult[ix][iy]; - in[iArray].im = vImagResult[ix][iy]; - iArray++; - } - - fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_BACKWARD, FFTW_IN_PLACE); - - fftwnd_one (plan, in, NULL); - - iArray = 0; - for (ix = 0; ix < m_nx; ix++) - for (iy = 0; iy < m_ny; iy++) { - vRealResult[ix][iy] = in[iArray].re; - vImagResult[ix][iy] = in[iArray].im; - iArray++; - } - - fftwnd_destroy_plan (plan); - - delete in; - - return true; + } + + Fourier::shuffleNaturalToFourierOrder (result); + + fftw_complex* in = new fftw_complex [m_nx * m_ny]; + + unsigned int iArray = 0; + for (ix = 0; ix < m_nx; ix++) { + for (iy = 0; iy < m_ny; iy++) { + in[iArray].re = vRealResult[ix][iy]; + in[iArray].im = vImagResult[ix][iy]; + iArray++; + } + } + + fftwnd_plan plan = fftw2d_create_plan (m_nx, m_ny, FFTW_BACKWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); + + fftwnd_one (plan, in, NULL); + + iArray = 0; + for (ix = 0; ix < m_nx; ix++) { + for (iy = 0; iy < m_ny; iy++) { + vRealResult[ix][iy] = in[iArray].re; + vImagResult[ix][iy] = in[iArray].im; + iArray++; + } + } + fftwnd_destroy_plan (plan); + + delete in; + + return true; } bool @@ -892,18 +832,16 @@ ImageFile::fftRows (ImageFile& result) const if (! result.convertRealToComplex ()) return false; } - - fftw_complex* in = new fftw_complex [m_nx]; - + ImageFileArrayConst vReal = getArray(); ImageFileArrayConst vImag = getImaginaryArray(); - fftw_plan plan = fftw_create_plan (m_nx, FFTW_FORWARD, FFTW_IN_PLACE); - std::complex* pcRow = new std::complex [m_nx]; - - unsigned int ix, iy; - unsigned int iArray = 0; - for (iy = 0; iy < m_ny; iy++) { + fftw_plan plan = fftw_create_plan (m_nx, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); + + fftw_complex* in = new fftw_complex [m_nx]; + std::complex* pcRow = new std::complex [m_nx]; + for (int iy = 0; iy < m_ny; iy++) { + unsigned int ix; for (ix = 0; ix < m_nx; ix++) { in[ix].re = vReal[ix][iy]; if (isComplex()) @@ -919,8 +857,8 @@ ImageFile::fftRows (ImageFile& result) const Fourier::shuffleFourierToNaturalOrder (pcRow, m_nx); for (ix = 0; ix < m_nx; ix++) { - vReal[ix][iy] = pcRow[ix].real(); - vImag[ix][iy] = pcRow[ix].imag(); + vReal[ix][iy] = pcRow[ix].real() / m_nx; + vImag[ix][iy] = pcRow[ix].imag() / m_nx; } } delete [] pcRow; @@ -949,7 +887,7 @@ ImageFile::ifftRows (ImageFile& result) const ImageFileArrayConst vReal = getArray(); ImageFileArrayConst vImag = getImaginaryArray(); - fftw_plan plan = fftw_create_plan (m_nx, FFTW_BACKWARD, FFTW_IN_PLACE); + fftw_plan plan = fftw_create_plan (m_nx, FFTW_BACKWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); std::complex* pcRow = new std::complex [m_nx]; unsigned int ix, iy; @@ -987,13 +925,103 @@ ImageFile::ifftRows (ImageFile& result) const bool ImageFile::fftCols (ImageFile& result) const { - return false; + if (m_nx != result.nx() || m_ny != result.ny()) { + sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::fftRows]"); + return false; + } + + if (result.dataType() == Array2dFile::DATA_TYPE_REAL) { + if (! result.convertRealToComplex ()) + return false; + } + + ImageFileArrayConst vReal = getArray(); + ImageFileArrayConst vImag = getImaginaryArray(); + + fftw_plan plan = fftw_create_plan (m_ny, FFTW_FORWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); + + std::complex* pcCol = new std::complex [m_ny]; + fftw_complex* in = new fftw_complex [m_ny]; + for (int ix = 0; ix < m_nx; ix++) { + unsigned int iy; + for (iy = 0; iy < m_ny; iy++) { + in[iy].re = vReal[ix][iy]; + if (isComplex()) + in[iy].im = vImag[ix][iy]; + else + in[iy].im = 0; + } + + fftw_one (plan, in, NULL); + + for (iy = 0; iy < m_ny; iy++) + pcCol[iy] = std::complex(in[iy].re, in[iy].im); + + Fourier::shuffleFourierToNaturalOrder (pcCol, m_ny); + for (iy = 0; iy < m_ny; iy++) { + vReal[ix][iy] = pcCol[iy].real() / m_ny; + vImag[ix][iy] = pcCol[iy].imag() / m_ny; + } + } + delete [] pcCol; + + fftw_destroy_plan (plan); + delete in; + + return true; } bool ImageFile::ifftCols (ImageFile& result) const { - return false; + if (m_nx != result.nx() || m_ny != result.ny()) { + sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::fftRows]"); + return false; + } + + if (result.dataType() == Array2dFile::DATA_TYPE_REAL) { + if (! result.convertRealToComplex ()) + return false; + } + + fftw_complex* in = new fftw_complex [m_ny]; + + ImageFileArrayConst vReal = getArray(); + ImageFileArrayConst vImag = getImaginaryArray(); + + fftw_plan plan = fftw_create_plan (m_ny, FFTW_BACKWARD, FFTW_IN_PLACE | FFTW_ESTIMATE | FFTW_USE_WISDOM); + std::complex* pcCol = new std::complex [m_ny]; + + unsigned int ix, iy; + unsigned int iArray = 0; + for (ix = 0; ix < m_nx; ix++) { + for (iy = 0; iy < m_ny; iy++) { + double dImag = 0; + if (isComplex()) + dImag = vImag[ix][iy]; + pcCol[iy] = std::complex (vReal[ix][iy], dImag); + } + + Fourier::shuffleNaturalToFourierOrder (pcCol, m_ny); + + for (iy = 0; iy < m_ny; iy++) { + in[iy].re = pcCol[iy].real(); + in[iy].im = pcCol[iy].imag(); + } + + fftw_one (plan, in, NULL); + + for (iy = 0; iy < m_ny; iy++) { + vReal[ix][iy] = in[iy].re; + vImag[ix][iy] = in[iy].im; + } + } + delete [] pcCol; + + fftw_destroy_plan (plan); + delete in; + + return true; } #endif // HAVE_FFTW @@ -1161,7 +1189,7 @@ ImageFile::magnitude (ImageFile& result) const } if (result.isComplex()) - result.convertComplexToReal(); + result.reallocComplexToReal(); return true; } @@ -1178,18 +1206,67 @@ ImageFile::phase (ImageFile& result) const ImageFileArray vImag = getImaginaryArray(); ImageFileArray vRealResult = result.getArray(); - for (unsigned int ix = 0; ix < m_nx; ix++) + for (unsigned int ix = 0; ix < m_nx; ix++) { for (unsigned int iy = 0; iy < m_ny; iy++) { if (isComplex()) vRealResult[ix][iy] = ::atan2 (vImag[ix][iy], vReal[ix][iy]); else vRealResult[ix][iy] = 0; } + } + if (result.isComplex()) + result.reallocComplexToReal(); - if (result.isComplex()) - result.convertComplexToReal(); + return true; +} + +bool +ImageFile::real (ImageFile& result) const +{ + if (m_nx != result.nx() || m_ny != result.ny()) { + sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]"); + return false; + } + + ImageFileArray vReal = getArray(); + ImageFileArray vRealResult = result.getArray(); + + for (unsigned int ix = 0; ix < m_nx; ix++) { + for (unsigned int iy = 0; iy < m_ny; iy++) { + vRealResult[ix][iy] = vReal[ix][iy]; + } + } + + if (result.isComplex()) + result.reallocComplexToReal(); - return true; + return true; +} + +bool +ImageFile::imaginary (ImageFile& result) const +{ + if (m_nx != result.nx() || m_ny != result.ny()) { + sys_error (ERR_WARNING, "Difference sizes of images [ImageFile::invertPixelValues]"); + return false; + } + + ImageFileArray vImag = getArray(); + ImageFileArray vRealResult = result.getArray(); + + for (unsigned int ix = 0; ix < m_nx; ix++) { + for (unsigned int iy = 0; iy < m_ny; iy++) { + if (isComplex()) + vRealResult[ix][iy] = vImag[ix][iy]; + else + vRealResult[ix][iy] = 0; + } + } + + if (result.isComplex()) + result.reallocComplexToReal(); + + return true; } bool @@ -1222,8 +1299,7 @@ ImageFile::square (ImageFile& result) const vResult[ix][iy] = vLHS[ix][iy] * vLHS[ix][iy]; } } - - + return true; } @@ -1310,21 +1386,11 @@ ImageFile::importImage (const char* const pszFormat, const char* const pszFilena else if (iFormatID == IMPORT_FORMAT_PNG) return readImagePNG (pszFilename); #endif -#ifdef HAVE_CTN_DICOM - else if (iFormatID == IMPORT_FORMAT_DICOM) - return readImageDicom (pszFilename); -#endif sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::importImage]", pszFormat); return false; } -bool -ImageFile::readImageDicom (const char* const pszFile) -{ - return false; -} - void ImageFile::skipSpacePPM (FILE* fp) { @@ -1392,7 +1458,10 @@ ImageFile::readImagePPM (const char* const pszFile) } else skipSpacePPM (fp); // ascii may have comments + bool bMonochromeImage = false; double dMaxValue = iMaxValue; + double dMaxValue3 = iMaxValue * 3; + ImageFileArray v = getArray(); for (int iy = nRows - 1; iy >= 0; iy--) { for (int ix = 0; ix < nCols; ix++) { @@ -1419,23 +1488,37 @@ ImageFile::readImagePPM (const char* const pszFile) fclose(fp); return false; } - dR = iR / dMaxValue; - dG = iG / dMaxValue; - dB = iB / dMaxValue; - v[ix][iy] = colorToGrayscale (dR, dG, dB); + if (ix == 0 && iy == 0 && (iR == iG && iG == iB)) + bMonochromeImage = true; + if (bMonochromeImage) + v[ix][iy] = (iR + iG + iB) / dMaxValue3; + else { + dR = iR / dMaxValue; + dG = iG / dMaxValue; + dB = iB / dMaxValue; + v[ix][iy] = colorToGrayscale (dR, dG, dB); + } break; case '6': iR = fgetc(fp); iG = fgetc(fp); iB = fgetc(fp); + if (iB == EOF) { fclose(fp); return false; } - dR = iR / dMaxValue; - dG = iG / dMaxValue; - dB = iB / dMaxValue; - v[ix][iy] = colorToGrayscale (dR, dG, dB); + if (ix == 0 && iy == 0 && (iR == iG && iG == iB)) + bMonochromeImage = true; + + if (bMonochromeImage) + v[ix][iy] = (iR + iG + iB) / dMaxValue3; + else { + dR = iR / dMaxValue; + dG = iG / dMaxValue; + dB = iB / dMaxValue; + v[ix][iy] = colorToGrayscale (dR, dG, dB); + } break; } } @@ -1567,10 +1650,23 @@ ImageFile::exportImage (const char* const pszFormat, const char* const pszFilena return writeImagePGM (pszFilename, nxcell, nycell, densmin, densmax); else if (iFormatID == EXPORT_FORMAT_PGMASCII) return writeImagePGMASCII (pszFilename, nxcell, nycell, densmin, densmax); + else if (iFormatID == EXPORT_FORMAT_TEXT) + return writeImageText (pszFilename); +#ifdef HAVE_PNG else if (iFormatID == EXPORT_FORMAT_PNG) return writeImagePNG (pszFilename, 8, nxcell, nycell, densmin, densmax); else if (iFormatID == EXPORT_FORMAT_PNG16) return writeImagePNG (pszFilename, 16, nxcell, nycell, densmin, densmax); +#endif +#ifdef HAVE_CTN_DICOM + else if (iFormatID == EXPORT_FORMAT_DICOM) { + DicomExporter dicomExport (this); + bool bSuccess = dicomExport.writeFile (pszFilename); + if (! bSuccess) + sys_error (ERR_SEVERE, dicomExport.failMessage().c_str()); + return bSuccess; + } +#endif sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat); return false; @@ -1654,6 +1750,36 @@ ImageFile::writeImagePGMASCII (const char* const outfile, int nxcell, int nycell return true; } +bool +ImageFile::writeImageText (const char* const outfile) +{ + FILE *fp; + int nx = m_nx; + int ny = m_ny; + ImageFileArray v = getArray(); + ImageFileArray vImag = getImaginaryArray(); + + if ((fp = fopen (outfile, "w")) == NULL) + return false; + + for (int irow = ny - 1; irow >= 0; irow--) { + for (int icol = 0; icol < nx; icol++) { + if (isComplex()) { + if (vImag[icol][irow] >= 0) + fprintf (fp, "%.9g+%.9gi ", v[icol][irow], vImag[icol][irow]); + else + fprintf (fp, "%.9g-%.9gi ", v[icol][irow], -vImag[icol][irow]); + } else + fprintf (fp, "%12.8g ", v[icol][irow]); + } + fprintf(fp, "\n"); + } + + fclose(fp); + + return true; +} + #ifdef HAVE_PNG bool