r311: image comparison functions
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Dec 2000 04:18:30 +0000 (04:18 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Dec 2000 04:18:30 +0000 (04:18 +0000)
13 files changed:
ChangeLog
configure.in
include/imagefile.h
libctsim/imagefile.cpp
msvc/ctsim/ctsim.plg
src/ctsim.cpp
src/ctsim.h
src/dialogs.cpp
src/dialogs.h
src/docs.h
src/views.cpp
src/views.h
tools/if2.cpp

index 63c618d9feffedda14a80cff231cad6dd0572889..3788ecdc438e140a7c66c41e9fff09dd0d72a5f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,22 @@
-2.5.1 - Released 12/30/00
+3.0alpha1 - Released 12/30/00
 
-       * Added PlotFile class
-       * Added plotting of rows & columns to ctsim
-       * Updated if2 to output plot files
-       * Added y-axis scaling to plotting in ctsim
-       * Reworked statistics to share between imagefile and plotfile class
-       * Fixed scaling bug in rasterizing Phantom with nsample > 2
+       * Added PlotFile class to system, used by if2 and ctsim
+
+       * ctsim: Added image comparison statistics and image subtraction
+
+       * ctsim: Added plotting of rows & columns with y-axis scaling 
+
+       * ctsim: Added row and column plot comparisons between two image
+       files.
+
+       * Reworked statistics algorithm to share between imagefile and
+       plotfile classes.
+
+       * imagefile.cpp: Fixed scaling bug when rasterizing Phantom with
+       nsamples > 2.  Added image math functions. 
+
+       * if2: Updated to output plot files and use new ImageFile class
+       math functions
        
 2.5.0 - 12/18/00 
    First Microsoft Windows GUI version
index 403e5ef4831e49eaac7c7c4094d14609d5d06324..26a77793983e24db7808e8fcadc21f76a65a6eb5 100644 (file)
@@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
 AC_INIT(src/ctsim.cpp)
-AM_INIT_AUTOMAKE(ctsim,2.5.0)
+AM_INIT_AUTOMAKE(ctsim,3.0.0-alpha1)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
index 443bf33a78547703a8a4edcbe7b118dc464fb3dc..a7e69d75f54dba97efacc239d0de3ec7b57cfbb7 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: imagefile.h,v 1.22 2000/12/16 06:12:47 kevin Exp $
+**  $Id: imagefile.h,v 1.23 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
@@ -52,8 +52,8 @@ public:
   kfloat32** getArray (void)
       { return (kfloat32**) (m_arrayData); }
 
-  const kfloat32* const * getArray (void) const
-       { return (const kfloat32**) (m_arrayData); }
+  kfloat32** const getArray (void) const
+       { return (kfloat32** const) (m_arrayData); }
 
 #ifdef HAVE_MPI
   MPI::Datatype getMPIDataType (void) const
@@ -76,8 +76,8 @@ class F64Image : public Array2dFile
   kfloat64** getArray (void)
       { return (kfloat64**) (m_arrayData); }
 
-  const kfloat64* const * getArray (void) const
-      { return (const kfloat64**) (m_arrayData); }
+  kfloat64** const getArray (void) const
+      { return (kfloat64** const) (m_arrayData); }
 
 #ifdef HAVE_MPI
   MPI::Datatype getMPIDataType (void) const
@@ -94,13 +94,15 @@ typedef F64Image   ImageFileBase;
 typedef kfloat64   ImageFileValue;
 typedef kfloat64*  ImageFileColumn;
 typedef kfloat64** ImageFileArray;
-typedef const kfloat64* const * ImageFileArrayConst;
+typedef kfloat64** const ImageFileArrayConst;\r
+typedef const kfloat64* ImageFileColumnConst;
 #else
 typedef F32Image   ImageFileBase;
 typedef kfloat32   ImageFileValue;
 typedef kfloat32*  ImageFileColumn;
 typedef kfloat32** ImageFileArray;
-typedef const kfloat32* const * ImageFileArrayConst;
+typedef kfloat32** const ImageFileArrayConst;
+typedef const kfloat32* ImageFileColumnConst;\r
 #endif
 
 
@@ -126,7 +128,15 @@ class ImageFile : public ImageFileBase
   bool comparativeStatistics (const ImageFile& imComp, double& d, double& r, double& e) const;
 
   bool printComparativeStatistics (const ImageFile& imComp, std::ostream& os) const;
-
+\r
+  bool subtractImages (const ImageFile& rRHS, ImageFile& result) const;\r
+
+  bool addImages (const ImageFile& rRHS, ImageFile& result) const;\r
+\r
+  bool multiplyImages (const ImageFile& rRHS, ImageFile& result) const;\r
+\r
+  bool divideImages (const ImageFile& rRHS, ImageFile& result) const;\r
+\r
   int display (void) const;
 
   int displayScaling (const int scaleFactor, ImageFileValue pmin, ImageFileValue pmax) const;
index b86ff794ae9cd0242201c21e33184bca9c513e3f..a5e9bec75e34ea2442152be631e318c1a93b897f 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -266,7 +266,104 @@ ImageFile::getMinMax (double& min, double& max) const
                }
     }
 }
+\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)
 {
index 9ec4c1f38718235d3f628eb96eb15af013905970..ec7bd1a8e99bb845d66e070fdcc927507a52cb1f 100644 (file)
@@ -6,13 +6,13 @@
 --------------------Configuration: ctsim - Win32 Debug--------------------\r
 </h3>\r
 <h3>Command Lines</h3>\r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1EF.tmp" with contents\r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP432.tmp" with contents\r
 [\r
 /nologo /G6 /MTd /W3 /Gm /GR /GX /ZI /Od /I "\wx2\include" /I "." /I "..\..\include" /I "..\..\getopt" /I "..\..\..\lpng108" /I "..\..\..\zlib" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"2.5.0\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"2.5.0\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c \r
-"C:\ctsim-2.0.6\src\views.cpp"\r
+"C:\ctsim-2.0.6\src\ctsim.cpp"\r
 ]\r
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1EF.tmp" \r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1F0.tmp" with contents\r
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP432.tmp" \r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP433.tmp" with contents\r
 [\r
 comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libctsim/Debug/libctsim.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\lpng108\msvc\win32\libpng\lib_dbg\libpng.lib ..\..\..\lpng108\msvc\win32\zlib\lib_dbg\zlib.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib ../../../wx2/lib/wxd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrtd.lib" /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"..\..\..\lpng108\msvc\win32\libpng\lib" /libpath:"..\..\..\lpng108\msvc\win32\zlib\lib" \r
 ".\Debug\ctsim.obj"\r
@@ -27,14 +27,14 @@ comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib w
 "\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib"\r
 "\wx2\lib\wxd.lib"\r
 ]\r
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1F0.tmp"\r
+Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP433.tmp"\r
 <h3>Output Window</h3>\r
 Compiling...\r
-views.cpp\r
+ctsim.cpp\r
 Linking...\r
 Creating command line "bscmake.exe /nologo /o"Debug/ctsim.bsc"  ".\Debug\ctsim.sbr" ".\Debug\dialogs.sbr" ".\Debug\dlgprojections.sbr" ".\Debug\dlgreconstruct.sbr" ".\Debug\docs.sbr" ".\Debug\views.sbr""\r
 Creating browse info file...\r
-BSCMAKE: warning BK4503 : minor error in .SBR file '.\Debug\views.sbr' ignored\r
+BSCMAKE: warning BK4503 : minor error in .SBR file '.\Debug\ctsim.sbr' ignored\r
 <h3>Output Window</h3>\r
 \r
 \r
index bdd8a5909d626e72d5decf57b431597a4442f78f..b128641a90be1fa3bffc42bc206995b4af14ec2e 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsim.cpp,v 1.19 2000/12/20 14:39:09 kevin Exp $
+**  $Id: ctsim.cpp,v 1.20 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
@@ -61,7 +61,7 @@
 #endif
 #endif
 \r
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.19 2000/12/20 14:39:09 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.20 2000/12/22 04:18:00 kevin Exp $";
 
 class CTSimApp* theApp = NULL;
 
@@ -285,6 +285,27 @@ MainFrame::OnCreatePhantom(wxCommandEvent& WXUNUSED(event))
     
 }
 
+void\r
+CTSimApp::getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF)\r
+{\r
+  const ImageFile& rIF = pIFDoc->getImageFile();\r
+  int nx = rIF.nx();\r
+  int ny = rIF.ny();\r
+  wxList& rListDocs = m_docManager->GetDocuments();\r
+  std::vector<std::string> vecFilename;\r
+  for (wxNode* pNode = rListDocs.GetFirst(); pNode != NULL; pNode = pNode->GetNext()) {\r
+    wxDocument* pDoc = reinterpret_cast<wxDocument*>(pNode->GetData());\r
+    ImageFileDocument* pIFCompareDoc = dynamic_cast<ImageFileDocument*>(pDoc);\r
+    if (pIFCompareDoc && (pIFDoc != pIFCompareDoc)) {\r
+      const ImageFile& rCompareIF = pIFCompareDoc->getImageFile();\r
+      if (rCompareIF.nx() == nx && rCompareIF.ny() == ny) {\r
+        std::string strFilename = pDoc->GetFilename();\r
+        vecIF.push_back (pIFCompareDoc);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
 void 
 MainFrame::OnHelpContents(wxCommandEvent& WXUNUSED(event) )
 {
index 486224bafc3a02b50442062a9497c0f4152fa12a..dddf2105547c339dab97cf758d431ba826b3f128 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsim.h,v 1.11 2000/12/21 03:40:58 kevin Exp $
+**  $Id: ctsim.h,v 1.12 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
 #endif
 
 class wxMenu;
-class wxDocument;
+class wxDocument;\r
+class ImageFileDocument;\r
+#include <vector>\r
+
 #include "wx/docview.h"\r
 
 // Define a new frame for main window
@@ -106,6 +109,8 @@ public:
        { return m_docManager; }
 
     wxString getUntitledFilename();
+\r
+    void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);\r
 
 private:
     wxDocManager* m_docManager;
@@ -136,7 +141,9 @@ enum {
        IFMENU_PLOT_COL,
     IFMENU_VIEW_SCALE_AUTO,
     IFMENU_VIEW_SCALE_MINMAX,\r
-       IFMENU_COMPARE_IMAGES,
+       IFMENU_COMPARE_IMAGES,\r
+       IFMENU_COMPARE_ROW,\r
+       IFMENU_COMPARE_COL,\r
     PHMMENU_PROCESS_RASTERIZE,
     PHMMENU_PROCESS_PROJECTIONS,\r
        PLOTMENU_VIEW_SCALE_MINMAX,\r
index 66191bb761ddd90d8a67d18ce577e18838574fe2..7d8c0ecab7e7dbf3fd526e644476806382a40e6f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dialogs.cpp,v 1.19 2000/12/21 03:40:58 kevin Exp $
+**  $Id: dialogs.cpp,v 1.20 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
@@ -53,6 +53,9 @@
 #include "phantom.h"
 #include "filter.h"
 #include "backprojectors.h"
+#include "docs.h"\r
+#include "views.h"\r
+#include "imagefile.h"\r
 
 #if defined(MSVC) || HAVE_SSTREAM\r
 #include <sstream>\r
@@ -127,6 +130,73 @@ DialogGetPhantom::getPhantom(void)
 }
 
 \r
+///////////////////////////////////////////////////////////////////////\r
+// CLASS IMPLEMENTATION\r
+//    DialogGetComparisonImage\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+DialogGetComparisonImage::DialogGetComparisonImage (wxFrame* pParent, const char* const pszTitle, const std::vector<ImageFileDocument*>& rVecIF, bool bShowMakeDifference)\r
+: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rVecIF(rVecIF)\r
+{\r
+  wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);\r
+  \r
+  pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxALL, 5);\r
+  \r
+  pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);\r
+  \r
+  int iNImages = m_rVecIF.size();\r
+  wxString* pstrImages = new wxString [iNImages];\r
+  for (int i = 0; i < iNImages; i++) {\r
+    ImageFileView* pView = dynamic_cast<ImageFileView*>(m_rVecIF[i]->GetFirstView());\r
+    if (pView)\r
+      pstrImages[i] = pView->getFrame()->GetTitle();\r
+  }\r
+\r
+  m_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE);\r
+  delete [] pstrImages;\r
+\r
+  m_pListBoxImageChoices->SetSelection (0);\r
+  pTopSizer->Add (m_pListBoxImageChoices, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
+  \r
+  if (bShowMakeDifference) {\r
+    m_pMakeDifferenceImage = new wxCheckBox (this, -1, "Make Difference Image");\r
+    m_pMakeDifferenceImage->SetValue (FALSE);\r
+    pTopSizer->Add (m_pMakeDifferenceImage, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
+  } else\r
+    m_pMakeDifferenceImage = NULL;\r
+\r
+  pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
+  \r
+  wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);\r
+  wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");\r
+  wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");\r
+  pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);\r
+  pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);\r
+  \r
+  pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);\r
+  \r
+  SetAutoLayout (true);\r
+  SetSizer (pTopSizer);\r
+  pTopSizer->Fit (this);\r
+  pTopSizer->SetSizeHints (this);\r
+}\r
+\r
+ImageFileDocument*\r
+DialogGetComparisonImage::getImageFileDocument(void)\r
+{\r
+  return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ];\r
+}\r
+\r
+bool\r
+DialogGetComparisonImage::getMakeDifferenceImage()\r
+{\r
+  if (m_pMakeDifferenceImage)\r
+    return m_pMakeDifferenceImage->GetValue();\r
+  else\r
+    return false;\r
+}\r
+\r
+\r
 /////////////////////////////////////////////////////////////////////\r
 // CLASS DiaglogGetMinMax Implementation\r
 /////////////////////////////////////////////////////////////////////\r
index c4c66473ec7f82ca12cdd1e7a5cb5b503a8c0475..4441ca0abf322f2461d5e23d73c569956bcae948 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dialogs.h,v 1.15 2000/12/21 03:40:58 kevin Exp $
+**  $Id: dialogs.h,v 1.16 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
@@ -67,6 +67,25 @@ class DialogGetPhantom : public wxDialog
     StringValueAndTitleListBox* m_pListBoxPhantom;
 };
 \r
+\r
+#include <vector>\r
+class ImageFileDocument;\r
+class DialogGetComparisonImage : public wxDialog\r
+{\r
+ public:\r
+   DialogGetComparisonImage (wxFrame* pParent, const char* const pszTitle, const std::vector<ImageFileDocument*>& rVecIF, bool bShowMakeDifference);\r
+    virtual ~DialogGetComparisonImage () {}\r
+\r
+    ImageFileDocument* getImageFileDocument ();\r
+\r
+    bool getMakeDifferenceImage();\r
+\r
+ private:\r
+    wxListBox* m_pListBoxImageChoices;\r
+    wxCheckBox* m_pMakeDifferenceImage;\r
+    const std::vector<ImageFileDocument*>& m_rVecIF;\r
+};\r
+\r
 
 
 class ImageFile;
index 7b337bb891d5c049fcc3b0623ed17f4f9b5d9219..116347ccdd2fe3198d5072d654b7eb68c1c2af9f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: docs.h,v 1.7 2000/12/20 14:39:09 kevin Exp $
+**  $Id: docs.h,v 1.8 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
@@ -37,7 +37,7 @@
 #include "imagefile.h"
 #include "phantom.h"
 #include "projections.h"
-
+#include "plotfile.h"
 
 class ImageFileDocument: public wxDocument
 {
@@ -121,7 +121,8 @@ public:
     virtual bool IsModified () const;
     virtual void Modify (bool mod);
 };
-
+\r
+\r
 class PlotFileDocument: public wxDocument
 {
     DECLARE_DYNAMIC_CLASS(PlotFileDocument)
index 68b03759361524e097517c4725b87ba3d5c27741..740c81c03615fca0236f43947be4c453041d817c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.35 2000/12/21 03:40:58 kevin Exp $
+**  $Id: views.cpp,v 1.36 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
@@ -71,90 +71,90 @@ END_EVENT_TABLE()
 ImageFileCanvas::ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
 : wxScrolledWindow(frame, -1, pos, size, style)
 {
-    m_pView = v;\r
-       m_xCursor = -1;\r
-       m_yCursor = -1;
+  m_pView = v;\r
+  m_xCursor = -1;\r
+  m_yCursor = -1;
 }
 
 void 
 ImageFileCanvas::OnDraw(wxDC& dc)
 {
-    if (m_pView)
-        m_pView->OnDraw(& dc);
+  if (m_pView)
+    m_pView->OnDraw(& dc);
 }\r
 \r
 void \r
 ImageFileCanvas::DrawRubberBandCursor (wxDC& dc, int x, int y)\r
 {\r
-       const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
-       ImageFileArrayConst v = rIF.getArray();\r
-       int nx = rIF.nx();\r
-       int ny = rIF.ny();\r
-       \r
-       dc.SetLogicalFunction (wxINVERT);\r
-       dc.SetPen (*wxGREEN_PEN);\r
-       dc.DrawLine (0, y, nx, y);\r
-       dc.DrawLine (x, 0, x, ny);\r
-       dc.SetLogicalFunction (wxCOPY);\r
+  const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
+  ImageFileArrayConst v = rIF.getArray();\r
+  int nx = rIF.nx();\r
+  int ny = rIF.ny();\r
+  \r
+  dc.SetLogicalFunction (wxINVERT);\r
+  dc.SetPen (*wxGREEN_PEN);\r
+  dc.DrawLine (0, y, nx, y);\r
+  dc.DrawLine (x, 0, x, ny);\r
+  dc.SetLogicalFunction (wxCOPY);\r
 }\r
 \r
 bool\r
 ImageFileCanvas::GetCurrentCursor (int& x, int& y)\r
 {\r
-       x = m_xCursor;\r
-       y = m_yCursor;\r
-       \r
-       if (m_xCursor >= 0 && m_yCursor >= 0)\r
-               return true;\r
-       else\r
-               return false;\r
+  x = m_xCursor;\r
+  y = m_yCursor;\r
+  \r
+  if (m_xCursor >= 0 && m_yCursor >= 0)\r
+    return true;\r
+  else\r
+    return false;\r
 }
 \r
 void 
 ImageFileCanvas::OnMouseEvent(wxMouseEvent& event)
 {
-    if (! m_pView)
-        return;
-    
-    wxClientDC dc(this);
-    PrepareDC(dc);
-    
-    wxPoint pt(event.GetLogicalPosition(dc));
-       \r
-    if (event.RightIsDown()) {\r
-               const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
-               ImageFileArrayConst v = rIF.getArray();\r
-               int nx = rIF.nx();\r
-               int ny = rIF.ny();\r
-               \r
-               if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
-                       std::ostringstream os;\r
-                       os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n";\r
-                       *theApp->getLog() << os.str().c_str();\r
-               } else\r
-                       *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
-    }\r
-    else if (event.LeftIsDown() || event.LeftUp()) {\r
-               const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
-               ImageFileArrayConst v = rIF.getArray();\r
-               int nx = rIF.nx();\r
-               int ny = rIF.ny();\r
-               \r
-               if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
-                       if (m_xCursor >= 0 && m_yCursor >= 0) {\r
-                               DrawRubberBandCursor (dc, m_xCursor, m_yCursor);\r
-                       }\r
-                       DrawRubberBandCursor (dc, pt.x, pt.y);\r
-                       m_xCursor = pt.x;\r
-                       m_yCursor = pt.y;\r
-               } else\r
-                       *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
-       }\r
-    if (event.LeftUp()) {\r
-                       std::ostringstream os;\r
-                       os << "Selected column" << pt.x << " and row" << pt.y << "\n";\r
-                       *theApp->getLog() << os.str().c_str();\r
-    }\r
+  if (! m_pView)
+    return;
+  
+  wxClientDC dc(this);
+  PrepareDC(dc);
+  
+  wxPoint pt(event.GetLogicalPosition(dc));
+  \r
+  if (event.RightIsDown()) {\r
+    const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
+    ImageFileArrayConst v = rIF.getArray();\r
+    int nx = rIF.nx();\r
+    int ny = rIF.ny();\r
+    \r
+    if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
+      std::ostringstream os;\r
+      os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n";\r
+      *theApp->getLog() << os.str().c_str();\r
+    } else\r
+      *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+  }\r
+  else if (event.LeftIsDown() || event.LeftUp()) {\r
+    const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
+    ImageFileArrayConst v = rIF.getArray();\r
+    int nx = rIF.nx();\r
+    int ny = rIF.ny();\r
+    \r
+    if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
+      if (m_xCursor >= 0 && m_yCursor >= 0) {\r
+        DrawRubberBandCursor (dc, m_xCursor, m_yCursor);\r
+      }\r
+      DrawRubberBandCursor (dc, pt.x, pt.y);\r
+      m_xCursor = pt.x;\r
+      m_yCursor = pt.y;\r
+    } else\r
+      *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+  }\r
+  if (event.LeftUp()) {\r
+    std::ostringstream os;\r
+    os << "Selected column" << pt.x << " and row" << pt.y << "\n";\r
+    *theApp->getLog() << os.str().c_str();\r
+  }\r
 }
 
 // ImageFileView
@@ -166,6 +166,8 @@ EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
 EVT_MENU(IFMENU_VIEW_SCALE_MINMAX, ImageFileView::OnScaleMinMax)
 EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto)\r
 EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare)\r
+EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow)\r
+EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol)\r
 EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow)\r
 EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol)\r
 END_EVENT_TABLE()
@@ -182,368 +184,498 @@ ImageFileView::~ImageFileView(void)
 void
 ImageFileView::OnProperties (wxCommandEvent& event)
 {
-       double min, max, mean, mode, median, stddev;
-       const ImageFile& rIF = GetDocument()->getImageFile();
-       if (rIF.nx() == 0 || rIF.ny() == 0)
-               *theApp->getLog() << "Properties: empty imagefile\n";
-       else {
-               const std::string& rFilename = rIF.getFilename();
-               rIF.statistics (min, max, mean, mode, median, stddev);
-               std::ostringstream os;
-               os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmedian: "<<median<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
-               *theApp->getLog() << os.str().c_str();
-               wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION);
-               dialogMsg.ShowModal();
-       }
+  double min, max, mean, mode, median, stddev;
+  const ImageFile& rIF = GetDocument()->getImageFile();
+  if (rIF.nx() == 0 || rIF.ny() == 0)
+    *theApp->getLog() << "Properties: empty imagefile\n";
+  else {
+    const std::string& rFilename = rIF.getFilename();
+    rIF.statistics (min, max, mean, mode, median, stddev);
+    std::ostringstream os;
+    os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmedian: "<<median<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
+    *theApp->getLog() << os.str().c_str();
+    wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Imagefile Properties", wxOK | wxICON_INFORMATION);
+    dialogMsg.ShowModal();
+  }
 }
 
 void 
 ImageFileView::OnScaleAuto (wxCommandEvent& event)
 {
-    const ImageFile& rIF = GetDocument()->getImageFile();
-    double min, max, mean, mode, median, stddev;\r
-       rIF.statistics(min, max, mean, mode, median, stddev);\r
-    DialogAutoScaleParameters dialogAutoScale (m_frame, mean, mode, median, stddev, m_dAutoScaleFactor);
-    int iRetVal = dialogAutoScale.ShowModal();
-    if (iRetVal == wxID_OK) {
-               m_bMinSpecified = true;
-               m_bMaxSpecified = true;
-               double dMin, dMax;\r
-               if (dialogAutoScale.getMinMax (&dMin, &dMax)) {
-                       m_dMinPixel = dMin;
-                       m_dMaxPixel = dMax;
-                       m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
-                       OnUpdate (this, NULL);\r
-               }
+  const ImageFile& rIF = GetDocument()->getImageFile();
+  double min, max, mean, mode, median, stddev;\r
+  rIF.statistics(min, max, mean, mode, median, stddev);\r
+  DialogAutoScaleParameters dialogAutoScale (m_frame, mean, mode, median, stddev, m_dAutoScaleFactor);
+  int iRetVal = dialogAutoScale.ShowModal();
+  if (iRetVal == wxID_OK) {
+    m_bMinSpecified = true;
+    m_bMaxSpecified = true;
+    double dMin, dMax;\r
+    if (dialogAutoScale.getMinMax (&dMin, &dMax)) {
+      m_dMinPixel = dMin;
+      m_dMaxPixel = dMax;
+      m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
+      OnUpdate (this, NULL);\r
     }
+  }
 }
 
 void 
 ImageFileView::OnScaleMinMax (wxCommandEvent& event)
 {
-    const ImageFile& rIF = GetDocument()->getImageFile();
-    double min, max;
-    if (! m_bMinSpecified && ! m_bMaxSpecified)
-               rIF.getMinMax (min, max);
-       
-    if (m_bMinSpecified)
-               min = m_dMinPixel;
-    if (m_bMaxSpecified)
-               max = m_dMaxPixel;
-       
-    DialogGetMinMax dialogMinMax (m_frame, "Set Image Minimum & Maximum", min, max);
-    int retVal = dialogMinMax.ShowModal();
-    if (retVal == wxID_OK) {
-               m_bMinSpecified = true;
-               m_bMaxSpecified = true;
-               m_dMinPixel = dialogMinMax.getMinimum();
-               m_dMaxPixel = dialogMinMax.getMaximum();
-               OnUpdate (this, NULL);
-    }
+  const ImageFile& rIF = GetDocument()->getImageFile();
+  double min, max;
+  if (! m_bMinSpecified && ! m_bMaxSpecified)
+    rIF.getMinMax (min, max);
+  
+  if (m_bMinSpecified)
+    min = m_dMinPixel;
+  if (m_bMaxSpecified)
+    max = m_dMaxPixel;
+  
+  DialogGetMinMax dialogMinMax (m_frame, "Set Image Minimum & Maximum", min, max);
+  int retVal = dialogMinMax.ShowModal();
+  if (retVal == wxID_OK) {
+    m_bMinSpecified = true;
+    m_bMaxSpecified = true;
+    m_dMinPixel = dialogMinMax.getMinimum();
+    m_dMaxPixel = dialogMinMax.getMaximum();
+    OnUpdate (this, NULL);
+  }
 }
 \r
 void\r
 ImageFileView::OnCompare (wxCommandEvent& event)\r
 {\r
-  wxList& rListDocs = theApp->getDocManager()->GetDocuments();\r
   std::vector<ImageFileDocument*> vecIF;\r
-  std::vector<std::string> vecFilename;\r
-  int nCompares = 0;\r
-  for (wxNode* pNode = rListDocs.GetFirst(); pNode != NULL; pNode = pNode->GetNext()) {\r
-    wxDocument* pDoc = reinterpret_cast<wxDocument*>(pNode->GetData());\r
-       ImageFileDocument* pIFDoc = dynamic_cast<ImageFileDocument*>(pDoc);\r
-       if (pIFDoc) {\r
-               if (pIFDoc->GetFirstView() != this) {\r
-                       std::string strFilename = pDoc->GetFilename();\r
-                       vecIF.push_back (pIFDoc);\r
-                       vecFilename.push_back (strFilename);\r
-                       nCompares++;\r
-               }\r
-       }\r
-  }\r
-  for (int i = 0; i < nCompares; i++) {\r
-         const std::string& s = vecFilename[i];\r
-         *theApp->getLog() << s.c_str() << "\n";\r
+  theApp->getCompatibleImages (GetDocument(), vecIF);\r
+\r
+  if (vecIF.size() == 0) {\r
+    wxMessageBox("There are no compatible image files open for comparision", "No comparison images");\r
+  } else {\r
+    DialogGetComparisonImage dialogGetCompare(m_frame, "Get Comparison Image", vecIF, true);\r
+\r
+    if (dialogGetCompare.ShowModal() == wxID_OK) {\r
+      ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();\r
+      const ImageFile& rIF = GetDocument()->getImageFile();\r
+      const ImageFile& rCompareIF = pCompareDoc->getImageFile();\r
+      std::ostringstream os;\r
+      double min, max, mean, mode, median, stddev;\r
+      rIF.statistics (min, max, mean, mode, median, stddev);\r
+      os << rIF.getFilename() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n";\r
+      rCompareIF.statistics (min, max, mean, mode, median, stddev);\r
+      os << rCompareIF.getFilename() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n";\r
+      os << "\n";\r
+      double d, r, e;\r
+      rIF.comparativeStatistics (rCompareIF, d, r, e);\r
+      os << "Comparative Statistics: d=" << d << ", r=" << r << ", e=" << e << "\n";\r
+      *theApp->getLog() << os.str().c_str();\r
+      if (dialogGetCompare.getMakeDifferenceImage()) {\r
+        ImageFileDocument* pDifferenceDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
+        if (! pDifferenceDoc) {\r
+          sys_error (ERR_SEVERE, "Unable to create image file");\r
+          return;\r
+        }\r
+        ImageFile& differenceImage = pDifferenceDoc->getImageFile();\r
+      \r
+        differenceImage.setArraySize (rIF.nx(), rIF.ny());\r
+        if (! rIF.subtractImages (rCompareIF, differenceImage)) {\r
+          pDifferenceDoc->DeleteAllViews();\r
+          return;\r
+        }\r
+\r
+        pDifferenceDoc->Modify(true);\r
+        pDifferenceDoc->UpdateAllViews(this);\r
+        pDifferenceDoc->GetFirstView()->OnUpdate (this, NULL);\r
+      }\r
+      wxMessageBox(os.str().c_str(), "Image Comparison");\r
+    }\r
   }\r
 }
 
 ImageFileCanvas* 
 ImageFileView::CreateCanvas (wxView *view, wxFrame *parent)
 {
-    ImageFileCanvas* pCanvas;
-    int width, height;
-    parent->GetClientSize(&width, &height);
-    
-    pCanvas = new ImageFileCanvas (dynamic_cast<ImageFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
-    
-    pCanvas->SetScrollbars(20, 20, 50, 50);
-    pCanvas->SetBackgroundColour(*wxWHITE);
-    pCanvas->Clear();
-    
-    return pCanvas;
+  ImageFileCanvas* pCanvas;
+  int width, height;
+  parent->GetClientSize(&width, &height);
+  
+  pCanvas = new ImageFileCanvas (dynamic_cast<ImageFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
+  
+  pCanvas->SetScrollbars(20, 20, 50, 50);
+  pCanvas->SetBackgroundColour(*wxWHITE);
+  pCanvas->Clear();
+  
+  return pCanvas;
 }
 
 wxFrame*
 ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 {
-    wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
-    
-    wxMenu *file_menu = new wxMenu;
-    
-    file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
-    file_menu->Append(wxID_OPEN, "&Open...");
-    file_menu->Append(wxID_SAVE, "&Save");
-    file_menu->Append(wxID_SAVEAS, "Save &As...");
-    file_menu->Append(wxID_CLOSE, "&Close");
-    
-    file_menu->AppendSeparator();
-    file_menu->Append(IFMENU_FILE_PROPERTIES, "P&roperties");
-       
-    file_menu->AppendSeparator();
-    file_menu->Append(wxID_PRINT, "&Print...");
-    file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
-    file_menu->Append(wxID_PREVIEW, "Print Pre&view");
-    
-    wxMenu *view_menu = new wxMenu;
-    view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");
-    view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");
-    \r
-       wxMenu *plot_menu = new wxMenu;\r
-       plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row");\r
-       plot_menu->Append (IFMENU_PLOT_COL, "Plot &Column");\r
-       
-       wxMenu *compare_menu = new wxMenu;\r
-       compare_menu->Append (IFMENU_COMPARE_IMAGES, "&Compare Images");\r
+  wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "ImageFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+  
+  wxMenu *file_menu = new wxMenu;
+  
+  file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
+  file_menu->Append(wxID_OPEN, "&Open...");
+  file_menu->Append(wxID_SAVE, "&Save");
+  file_menu->Append(wxID_SAVEAS, "Save &As...");
+  file_menu->Append(wxID_CLOSE, "&Close");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(IFMENU_FILE_PROPERTIES, "P&roperties");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(wxID_PRINT, "&Print...");
+  file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
+  file_menu->Append(wxID_PREVIEW, "Print Pre&view");
+  
+  wxMenu *view_menu = new wxMenu;
+  view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");
+  view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");
+  \r
+  wxMenu *plot_menu = new wxMenu;\r
+  plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row");\r
+  plot_menu->Append (IFMENU_PLOT_COL, "Plot &Column");\r
+  
+  wxMenu *compare_menu = new wxMenu;\r
+  compare_menu->Append (IFMENU_COMPARE_IMAGES, "Compare &Images...");\r
+  compare_menu->Append (IFMENU_COMPARE_ROW, "Compare &Row");\r
+  compare_menu->Append (IFMENU_COMPARE_COL, "Compare &Column");\r
 \r
-    wxMenu *help_menu = new wxMenu;
-    help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
-    
-    wxMenuBar *menu_bar = new wxMenuBar;
-    
-    menu_bar->Append(file_menu, "&File");
-    menu_bar->Append(view_menu, "&View");\r
-       menu_bar->Append(plot_menu, "&Plot");\r
-       menu_bar->Append(compare_menu, "&Compare");
-    menu_bar->Append(help_menu, "&Help");
-    
-    subframe->SetMenuBar(menu_bar);
-    
-    subframe->Centre(wxBOTH);
-    
-    return subframe;
+  wxMenu *help_menu = new wxMenu;
+  help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+  
+  wxMenuBar *menu_bar = new wxMenuBar;
+  
+  menu_bar->Append(file_menu, "&File");
+  menu_bar->Append(view_menu, "&View");\r
+  menu_bar->Append(plot_menu, "&Plot");\r
+  menu_bar->Append(compare_menu, "&Compare");
+  menu_bar->Append(help_menu, "&Help");
+  
+  subframe->SetMenuBar(menu_bar);
+  
+  subframe->Centre(wxBOTH);
+  
+  return subframe;
 }
 
 
 bool 
 ImageFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
-    m_frame = CreateChildFrame(doc, this);
-    SetFrame (m_frame);
-    
-    m_bMinSpecified = false;
-    m_bMaxSpecified = false;
-    m_dAutoScaleFactor = 1.;
-       
-    int width, height;
-    m_frame->GetClientSize (&width, &height);
-    m_frame->SetTitle("ImageFileView");
-    m_canvas = CreateCanvas (this, m_frame);
-       
-    int x, y;  // X requires a forced resize
-    m_frame->GetSize(&x, &y);
-    m_frame->SetSize(-1, -1, x, y);
-       m_frame->SetFocus();\r
-       m_frame->Show(true);
-    Activate(true);
-    
-    return true;
+  m_frame = CreateChildFrame(doc, this);
+  SetFrame (m_frame);
+  
+  m_bMinSpecified = false;
+  m_bMaxSpecified = false;
+  m_dAutoScaleFactor = 1.;
+  
+  int width, height;
+  m_frame->GetClientSize (&width, &height);
+  m_frame->SetTitle("ImageFileView");
+  m_canvas = CreateCanvas (this, m_frame);
+  
+  int x, y;  // X requires a forced resize
+  m_frame->GetSize(&x, &y);
+  m_frame->SetSize(-1, -1, x, y);
+  m_frame->SetFocus();\r
+  m_frame->Show(true);
+  Activate(true);
+  
+  return true;
 }
 
 void 
 ImageFileView::OnDraw (wxDC* dc)
 {
-       if (m_bitmap.Ok())
-               dc->DrawBitmap(m_bitmap, 0, 0, false);
-       \r
-       int xCursor, yCursor;\r
-       if (m_canvas->GetCurrentCursor (xCursor, yCursor))\r
-               m_canvas->DrawRubberBandCursor (*dc, xCursor, yCursor);\r
+  if (m_bitmap.Ok())
+    dc->DrawBitmap(m_bitmap, 0, 0, false);
+  \r
+  int xCursor, yCursor;\r
+  if (m_canvas->GetCurrentCursor (xCursor, yCursor))\r
+    m_canvas->DrawRubberBandCursor (*dc, xCursor, yCursor);\r
 }
 
 
 void 
 ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-    const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();
-    ImageFileArrayConst v = rIF.getArray();
-    int nx = rIF.nx();
-    int ny = rIF.ny();
-    if (v != NULL && nx != 0 && ny != 0) {
-               if (! m_bMinSpecified || ! m_bMaxSpecified) {
-                       double min, max;
-                       rIF.getMinMax (min, max);
-                       if (! m_bMinSpecified)
-                               m_dMinPixel = min;
-                       if (! m_bMaxSpecified)
-                               m_dMaxPixel = max;
-               }
-               double scaleWidth = m_dMaxPixel - m_dMinPixel;
-               
-               unsigned char* imageData = new unsigned char [nx * ny * 3];
-               for (int ix = 0; ix < nx; ix++) {
-                       for (int iy = 0; iy < ny; iy++) {
-                               double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255;
-                               int intensity = static_cast<int>(scaleValue + 0.5);
-                               intensity = clamp (intensity, 0, 255);
-                               int baseAddr = ((ny - 1 - iy) * nx + ix) * 3;
-                               imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
-                       }
-               }
-               wxImage image (nx, ny, imageData, true);
-               m_bitmap = image.ConvertToBitmap();
-               delete imageData;
-               int xSize = nx;
-               int ySize = ny;
-               xSize = clamp (xSize, 0, 800);
-               ySize = clamp (ySize, 0, 800);
-               m_frame->SetClientSize (xSize, ySize);
-               m_canvas->SetScrollbars(20, 20, nx/20, ny/20);
-               m_canvas->SetBackgroundColour(*wxWHITE);\r
-    
-       
-    if (m_canvas)
-               m_canvas->Refresh();
+  const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();
+  ImageFileArrayConst v = rIF.getArray();
+  int nx = rIF.nx();
+  int ny = rIF.ny();
+  if (v != NULL && nx != 0 && ny != 0) {
+    if (! m_bMinSpecified || ! m_bMaxSpecified) {
+      double min, max;
+      rIF.getMinMax (min, max);
+      if (! m_bMinSpecified)
+        m_dMinPixel = min;
+      if (! m_bMaxSpecified)
+        m_dMaxPixel = max;
+    }
+    double scaleWidth = m_dMaxPixel - m_dMinPixel;
+    
+    unsigned char* imageData = new unsigned char [nx * ny * 3];
+    for (int ix = 0; ix < nx; ix++) {
+      for (int iy = 0; iy < ny; iy++) {
+        double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255;
+        int intensity = static_cast<int>(scaleValue + 0.5);
+        intensity = clamp (intensity, 0, 255);
+        int baseAddr = ((ny - 1 - iy) * nx + ix) * 3;
+        imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
+      }
+    }
+    wxImage image (nx, ny, imageData, true);
+    m_bitmap = image.ConvertToBitmap();
+    delete imageData;
+    int xSize = nx;
+    int ySize = ny;
+    xSize = clamp (xSize, 0, 800);
+    ySize = clamp (ySize, 0, 800);
+    m_frame->SetClientSize (xSize, ySize);
+    m_canvas->SetScrollbars(20, 20, nx/20, ny/20);
+    m_canvas->SetBackgroundColour(*wxWHITE);\r
+  } 
+  
+  if (m_canvas)
+    m_canvas->Refresh();
 }
 
 bool 
 ImageFileView::OnClose (bool deleteWindow)
 {
-    if (!GetDocument()->Close())
-        return false;
-       
-    m_canvas->Clear();
-    m_canvas->m_pView = NULL;
-    m_canvas = NULL;
-    wxString s(theApp->GetAppName());
-    if (m_frame)
-               m_frame->SetTitle(s);
-    SetFrame(NULL);
-       
-    Activate(false);
-    
-    if (deleteWindow) {
-        delete m_frame;
-        return true;
-    }
+  if (!GetDocument()->Close())
+    return false;
+  
+  m_canvas->Clear();
+  m_canvas->m_pView = NULL;
+  m_canvas = NULL;
+  wxString s(theApp->GetAppName());
+  if (m_frame)
+    m_frame->SetTitle(s);
+  SetFrame(NULL);
+  
+  Activate(false);
+  
+  if (deleteWindow) {
+    delete m_frame;
     return true;
+  }
+  return true;
 }
 \r
-#include "wx/plot.h"\r
 \r
 void\r
 ImageFileView::OnPlotRow (wxCommandEvent& event)\r
 {\r
-       int xCursor, yCursor;\r
-       if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
-               *theApp->getLog() << "No row selected. Please use left mouse button on image to select row\n";\r
-               return;\r
-       }\r
-       \r
-    const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();\r
-    ImageFileArrayConst v = rIF.getArray();\r
+  int xCursor, yCursor;\r
+  if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
+    wxMessageBox ("No row selected. Please use left mouse button on image to select column","Error");\r
+    return;\r
+  }\r
+  \r
+  const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();\r
+  ImageFileArrayConst v = rIF.getArray();\r
+  int nx = rIF.nx();\r
+  int ny = rIF.ny();\r
+  \r
+  if (v != NULL && yCursor < ny) {\r
+    double* pX = new double [nx];\r
+    double* pY = new double [nx];\r
+    for (int i = 0; i < nx; i++) {\r
+      pX[i] = i;\r
+      pY[i] = v[i][yCursor];\r
+    }\r
+    PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
+    if (! pPlotDoc) {\r
+      sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
+    } else {\r
+      PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
+      std::ostringstream title;\r
+      title << "Row " << yCursor;\r
+      rPlotFile.setTitle(title.str());\r
+      rPlotFile.setXLabel("Column");\r
+      rPlotFile.setYLabel("Pixel Value");\r
+      rPlotFile.setCurveSize (2, nx);\r
+      rPlotFile.addColumn (0, pX);\r
+      rPlotFile.addColumn (1, pY);\r
+    }\r
+    delete pX;\r
+    delete pY;\r
+    pPlotDoc->Modify(true);\r
+  }\r
+  \r
+}\r
+
+void\r
+ImageFileView::OnPlotCol (wxCommandEvent& event)\r
+{\r
+  int xCursor, yCursor;\r
+  if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
+    wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");\r
+    return;\r
+  }\r
+  \r
+  const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();\r
+  ImageFileArrayConst v = rIF.getArray();\r
+  int nx = rIF.nx();\r
+  int ny = rIF.ny();\r
+  \r
+  if (v != NULL && xCursor < nx) {\r
+    double* pX = new double [ny];\r
+    double* pY = new double [ny];\r
+    for (int i = 0; i < ny; i++) {\r
+      pX[i] = i;\r
+      pY[i] = v[xCursor][i];\r
+    }\r
+    PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
+    if (! pPlotDoc) {\r
+      sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
+    } else {\r
+      PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
+      std::ostringstream title;\r
+      title << "Column " << xCursor;\r
+      rPlotFile.setTitle(title.str());\r
+      rPlotFile.setXLabel("Row");\r
+      rPlotFile.setYLabel("Pixel Value");\r
+      rPlotFile.setCurveSize (2, nx);\r
+      rPlotFile.addColumn (0, pX);\r
+      rPlotFile.addColumn (1, pY);\r
+    }\r
+    delete pX;\r
+    delete pY;\r
+    pPlotDoc->Modify(true);\r
+  }\r
+}\r
+\r
+void\r
+ImageFileView::OnCompareCol (wxCommandEvent& event)\r
+{\r
+  int xCursor, yCursor;\r
+  if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
+    wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");\r
+    return;\r
+  }\r
+  \r
+  std::vector<ImageFileDocument*> vecIFDoc;\r
+  theApp->getCompatibleImages (GetDocument(), vecIFDoc);\r
+  \r
+  DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false);\r
+  \r
+  if (dialogGetCompare.ShowModal() == wxID_OK) {\r
+    ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();\r
+    const ImageFile& rIF = GetDocument()->getImageFile();\r
+    const ImageFile& rCompareIF = pCompareDoc->getImageFile();\r
+    \r
+    ImageFileArrayConst v1 = rIF.getArray();\r
+    ImageFileArrayConst v2 = rCompareIF.getArray();\r
     int nx = rIF.nx();\r
     int ny = rIF.ny();\r
-       \r
-    if (v != NULL && yCursor < ny) {\r
-               double* pX = new double [nx];\r
-               double* pY = new double [nx];\r
-               for (int i = 0; i < nx; i++) {\r
-                       pX[i] = i;\r
-                       pY[i] = v[i][yCursor];\r
-               }\r
-               PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
-               if (! pPlotDoc) {\r
-                       sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
-               } else {\r
-                       PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
-                       std::ostringstream title;\r
-                       title << "Row " << yCursor;\r
-                       rPlotFile.setTitle(title.str());\r
-                       rPlotFile.setXLabel("Column");\r
-                       rPlotFile.setYLabel("Pixel Value");\r
-                       rPlotFile.setCurveSize (2, nx);\r
-                       rPlotFile.addColumn (0, pX);\r
-                       rPlotFile.addColumn (1, pY);\r
-               }\r
-               delete pX;\r
-               delete pY;\r
-               pPlotDoc->Modify(true);\r
-       }\r
-       \r
+    \r
+    if (v1 != NULL && xCursor < nx) {\r
+      double* pX = new double [ny];\r
+      double* pY1 = new double [ny];\r
+      double* pY2 = new double [ny];\r
+      for (int i = 0; i < ny; i++) {\r
+        pX[i] = i;\r
+        pY1[i] = v1[xCursor][i];\r
+        pY2[i] = v2[xCursor][i];\r
+      }\r
+      PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
+      if (! pPlotDoc) {\r
+        sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
+      } else {\r
+        PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
+        std::ostringstream title;\r
+        title << "Comparison of Column " << xCursor;\r
+        rPlotFile.setTitle(title.str());\r
+        rPlotFile.setXLabel("Row");\r
+        rPlotFile.setYLabel("Pixel Value");\r
+        rPlotFile.setCurveSize (3, nx);\r
+        rPlotFile.addColumn (0, pX);\r
+        rPlotFile.addColumn (1, pY1);\r
+        rPlotFile.addColumn (2, pY2);\r
+      }\r
+      delete pX;\r
+      delete pY1;\r
+      delete pY2;\r
+      pPlotDoc->Modify(true);\r
+    }\r
+  }\r
 }\r
 
 void\r
-ImageFileView::OnPlotCol (wxCommandEvent& event)\r
+ImageFileView::OnCompareRow (wxCommandEvent& event)\r
 {\r
-       int xCursor, yCursor;\r
-       if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
-               // os << "No column selected. Please use left mouse button on image to select column\n";\r
-               return;\r
-       }\r
-       \r
-    const ImageFile& rIF = dynamic_cast<ImageFileDocument*>(GetDocument())->getImageFile();\r
-    ImageFileArrayConst v = rIF.getArray();\r
+  int xCursor, yCursor;\r
+  if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) {\r
+    wxMessageBox ("No column selected. Please use left mouse button on image to select column","Error");\r
+    return;\r
+  }\r
+  \r
+  std::vector<ImageFileDocument*> vecIFDoc;\r
+  theApp->getCompatibleImages (GetDocument(), vecIFDoc);\r
+  \r
+  DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false);\r
+  \r
+  if (dialogGetCompare.ShowModal() == wxID_OK) {\r
+    ImageFileDocument* pCompareDoc = dialogGetCompare.getImageFileDocument();\r
+    const ImageFile& rIF = GetDocument()->getImageFile();\r
+    const ImageFile& rCompareIF = pCompareDoc->getImageFile();\r
+    \r
+    ImageFileArrayConst v1 = rIF.getArray();\r
+    ImageFileArrayConst v2 = rCompareIF.getArray();\r
     int nx = rIF.nx();\r
     int ny = rIF.ny();\r
-       \r
-    if (v != NULL && xCursor < nx) {\r
-               double* pX = new double [ny];\r
-               double* pY = new double [ny];\r
-               double minVal = v[xCursor][0];\r
-               double maxVal = minVal;\r
-               for (int i = 0; i < ny; i++) {\r
-                       double y = v[xCursor][i];\r
-                       if (minVal < y)\r
-                               minVal = y;\r
-                       else if (maxVal > y)\r
-                               maxVal = y;\r
-                       pX[i] = i;\r
-                       pY[i] = y;\r
-               }\r
-               PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
-               if (! pPlotDoc) {\r
-                       sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
-               } else {\r
-                       PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
-                       std::ostringstream title;\r
-                       title << "Column " << xCursor;\r
-                       rPlotFile.setTitle(title.str());\r
-                       rPlotFile.setXLabel("Row");\r
-                       rPlotFile.setYLabel("Pixel Value");\r
-                       rPlotFile.setCurveSize (2, nx);\r
-                       rPlotFile.addColumn (0, pX);\r
-                       rPlotFile.addColumn (1, pY);\r
-               }\r
-               delete pX;\r
-               delete pY;\r
-               pPlotDoc->Modify(true);\r
-       }\r
+    \r
+    if (v1 != NULL && yCursor < ny) {\r
+      double* pX = new double [nx];\r
+      double* pY1 = new double [nx];\r
+      double* pY2 = new double [nx];\r
+      for (int i = 0; i < nx; i++) {\r
+        pX[i] = i;\r
+        pY1[i] = v1[i][yCursor];\r
+        pY2[i] = v2[i][yCursor];\r
+      }\r
+      PlotFileDocument* pPlotDoc = dynamic_cast<PlotFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT));\r
+      if (! pPlotDoc) {\r
+        sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
+      } else {\r
+        PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
+        std::ostringstream title;\r
+        title << "Comparison of Row " << yCursor;\r
+        rPlotFile.setTitle(title.str());\r
+        rPlotFile.setXLabel("Column");\r
+        rPlotFile.setYLabel("Pixel Value");\r
+        rPlotFile.setCurveSize (3, ny);\r
+        rPlotFile.addColumn (0, pX);\r
+        rPlotFile.addColumn (1, pY1);\r
+        rPlotFile.addColumn (2, pY2);\r
+      }\r
+      delete pX;\r
+      delete pY1;\r
+      delete pY2;\r
+      pPlotDoc->Modify(true);\r
+    }\r
+  }\r
 }\r
 \r
-
+\r
 // PhantomCanvas
 
 PhantomCanvas::PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
 : wxScrolledWindow(frame, -1, pos, size, style)
 {
-    m_pView = v;
+  m_pView = v;
 }
 
 void 
 PhantomCanvas::OnDraw(wxDC& dc)
 {
-    if (m_pView)
-        m_pView->OnDraw(& dc);
+  if (m_pView)
+    m_pView->OnDraw(& dc);
 }
 
 
@@ -560,14 +692,14 @@ END_EVENT_TABLE()
 PhantomView::PhantomView(void) 
 : wxView(), m_canvas(NULL), m_frame(NULL)
 {
-    m_iDefaultNDet = 367;
-    m_iDefaultNView = 320;
-    m_iDefaultNSample = 2;
-    m_dDefaultRotation = 2;
-    m_dDefaultFocalLength = 2;
-    m_dDefaultFieldOfView = 1;
-    m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
-    m_iDefaultTrace = Trace::TRACE_NONE;
+  m_iDefaultNDet = 367;
+  m_iDefaultNView = 320;
+  m_iDefaultNSample = 2;
+  m_dDefaultRotation = 2;
+  m_dDefaultFocalLength = 2;
+  m_dDefaultFieldOfView = 1;
+  m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
+  m_iDefaultTrace = Trace::TRACE_NONE;
 }
 
 PhantomView::~PhantomView(void)
@@ -577,14 +709,14 @@ PhantomView::~PhantomView(void)
 void
 PhantomView::OnProperties (wxCommandEvent& event)
 {
-       const int idPhantom = GetDocument()->getPhantomID();
-       const wxString& namePhantom = GetDocument()->getPhantomName();
-       std::ostringstream os;
-       os << "Phantom " << namePhantom.c_str() << " (" << idPhantom << ")\n";
-       *theApp->getLog() << os.str().c_str();
+  const int idPhantom = GetDocument()->getPhantomID();
+  const wxString& namePhantom = GetDocument()->getPhantomName();
+  std::ostringstream os;
+  os << "Phantom " << namePhantom.c_str() << " (" << idPhantom << ")\n";
+  *theApp->getLog() << os.str().c_str();
 #if DEBUG
-       const Phantom& rPhantom = GetDocument()->getPhantom();
-       rPhantom.print();
+  const Phantom& rPhantom = GetDocument()->getPhantom();
+  rPhantom.print();
 #endif
 }
 
@@ -592,254 +724,254 @@ PhantomView::OnProperties (wxCommandEvent& event)
 void
 PhantomView::OnProjections (wxCommandEvent& event)
 {
-       DialogGetProjectionParameters dialogProjection (m_frame, m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView, m_iDefaultGeometry, m_iDefaultTrace);
-       int retVal = dialogProjection.ShowModal();
-       if (retVal == wxID_OK) {
-               m_iDefaultNDet = dialogProjection.getNDet();
-               m_iDefaultNView = dialogProjection.getNView();
-               m_iDefaultNSample = dialogProjection.getNSamples();
-               m_iDefaultTrace = dialogProjection.getTrace();
-               m_dDefaultRotation = dialogProjection.getRotAngle();
-               m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
-               m_dDefaultFieldOfView = dialogProjection.getFieldOfViewRatio();
-               wxString sGeometry = dialogProjection.getGeometry();
-               m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str());
-               
-               if (m_iDefaultNDet > 0 && m_iDefaultNView > 0 && sGeometry != "") {
-                       const Phantom& rPhantom = GetDocument()->getPhantom();
-                       ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));\r
-                       if (! pProjectionDoc) {\r
-                               sys_error (ERR_SEVERE, "Unable to create projection document");\r
-                               return;\r
-                       }
-                       Projections& rProj = pProjectionDoc->getProjections();
-                       Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView);
-                       if (theScanner.fail()) {
-                               *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n";
-                               return;
-                       }
-                       rProj.initFromScanner (theScanner);
-                       m_dDefaultRotation /= PI;  // convert back to PI units
-                       
-                       if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
-                               ProjectionsDialog dialogProjections (theScanner, rProj, rPhantom, m_iDefaultTrace, dynamic_cast<wxWindow*>(m_frame));
-                               for (int iView = 0; iView < rProj.nView(); iView++) {
-                                       ::wxYield();
-                                       ::wxYield();
-                                       if (dialogProjections.isCancelled() || ! dialogProjections.projectView (iView)) {
-                                               pProjectionDoc->DeleteAllViews();
-                                               return;
-                                       }
-                                       ::wxYield();
-                                       ::wxYield();
-                                       while (dialogProjections.isPaused()) {
-                                               ::wxYield();
-                                               ::wxUsleep(50);
-                                       }
-                               }
-                       } else {
-                               wxProgressDialog dlgProgress (wxString("Projection"), wxString("Projection Progress"), rProj.nView() + 1, m_frame, wxPD_CAN_ABORT);
-                               for (int i = 0; i < rProj.nView(); i++) {
-                                       theScanner.collectProjections (rProj, rPhantom, i, 1, true, m_iDefaultTrace);
-                                       if (! dlgProgress.Update (i+1)) {
-                                               pProjectionDoc->DeleteAllViews();
-                                               return;
-                                       }
-                               }
-                       }
-                       
-                       std::ostringstream os;
-                       os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength << ", FieldOfViewRatio=" << m_dDefaultFieldOfView << ", Geometry=" << sGeometry.c_str();
-                       rProj.setRemark (os.str());
-                       *theApp->getLog() << os.str().c_str() << "\n";
-                       
-                       m_frame->Lower();
-                       ::wxYield();
-                       ProjectionFileView* projView = dynamic_cast<ProjectionFileView*>(pProjectionDoc->GetFirstView());\r
-                       if (projView) {\r
-                               projView->getFrame()->SetFocus();\r
-                               projView->OnUpdate (projView, NULL);\r
-                       }\r
-                       if (wxView* pView = pProjectionDoc->GetFirstView()) {
-                               if (wxFrame* pFrame = pView->GetFrame()) {
-                                       pFrame->SetFocus();
-                                       pFrame->Raise();
-                               }
-                               theApp->getDocManager()->ActivateView (pView, true, false);
-                       }
-                       ::wxYield();
-                       pProjectionDoc->Modify(true);
-                       pProjectionDoc->UpdateAllViews(this);
-               }
-       }
+  DialogGetProjectionParameters dialogProjection (m_frame, m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView, m_iDefaultGeometry, m_iDefaultTrace);
+  int retVal = dialogProjection.ShowModal();
+  if (retVal == wxID_OK) {
+    m_iDefaultNDet = dialogProjection.getNDet();
+    m_iDefaultNView = dialogProjection.getNView();
+    m_iDefaultNSample = dialogProjection.getNSamples();
+    m_iDefaultTrace = dialogProjection.getTrace();
+    m_dDefaultRotation = dialogProjection.getRotAngle();
+    m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
+    m_dDefaultFieldOfView = dialogProjection.getFieldOfViewRatio();
+    wxString sGeometry = dialogProjection.getGeometry();
+    m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str());
+    
+    if (m_iDefaultNDet > 0 && m_iDefaultNView > 0 && sGeometry != "") {
+      const Phantom& rPhantom = GetDocument()->getPhantom();
+      ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));\r
+      if (! pProjectionDoc) {\r
+        sys_error (ERR_SEVERE, "Unable to create projection document");\r
+        return;\r
+      }
+      Projections& rProj = pProjectionDoc->getProjections();
+      Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView);
+      if (theScanner.fail()) {
+        *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n";
+        return;
+      }
+      rProj.initFromScanner (theScanner);
+      m_dDefaultRotation /= PI;  // convert back to PI units
+      
+      if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
+        ProjectionsDialog dialogProjections (theScanner, rProj, rPhantom, m_iDefaultTrace, dynamic_cast<wxWindow*>(m_frame));
+        for (int iView = 0; iView < rProj.nView(); iView++) {
+          ::wxYield();
+          ::wxYield();
+          if (dialogProjections.isCancelled() || ! dialogProjections.projectView (iView)) {
+            pProjectionDoc->DeleteAllViews();
+            return;
+          }
+          ::wxYield();
+          ::wxYield();
+          while (dialogProjections.isPaused()) {
+            ::wxYield();
+            ::wxUsleep(50);
+          }
+        }
+      } else {
+        wxProgressDialog dlgProgress (wxString("Projection"), wxString("Projection Progress"), rProj.nView() + 1, m_frame, wxPD_CAN_ABORT);
+        for (int i = 0; i < rProj.nView(); i++) {
+          theScanner.collectProjections (rProj, rPhantom, i, 1, true, m_iDefaultTrace);
+          if (! dlgProgress.Update (i+1)) {
+            pProjectionDoc->DeleteAllViews();
+            return;
+          }
+        }
+      }
+      
+      std::ostringstream os;
+      os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength << ", FieldOfViewRatio=" << m_dDefaultFieldOfView << ", Geometry=" << sGeometry.c_str();
+      rProj.setRemark (os.str());
+      *theApp->getLog() << os.str().c_str() << "\n";
+      
+      m_frame->Lower();
+      ::wxYield();
+      ProjectionFileView* projView = dynamic_cast<ProjectionFileView*>(pProjectionDoc->GetFirstView());\r
+      if (projView) {\r
+        projView->getFrame()->SetFocus();\r
+        projView->OnUpdate (projView, NULL);\r
+      }\r
+      if (wxView* pView = pProjectionDoc->GetFirstView()) {
+        if (wxFrame* pFrame = pView->GetFrame()) {
+          pFrame->SetFocus();
+          pFrame->Raise();
+        }
+        theApp->getDocManager()->ActivateView (pView, true, false);
+      }
+      ::wxYield();
+      pProjectionDoc->Modify(true);
+      pProjectionDoc->UpdateAllViews(this);
+    }
+  }
 }
 
 
 void
 PhantomView::OnRasterize (wxCommandEvent& event)
 {
-       DialogGetRasterParameters dialogRaster (m_frame, 256, 256, 1);
-       int retVal = dialogRaster.ShowModal();
-       if (retVal == wxID_OK) {
-               int xSize = dialogRaster.getXSize();
-               int ySize = dialogRaster.getYSize();
-               int nSamples = dialogRaster.getNSamples();
-               if (nSamples < 1)
-                       nSamples = 1;
-               if (xSize > 0 && ySize > 0) {
-                       const Phantom& rPhantom = GetDocument()->getPhantom();
-                       ImageFileDocument* pRasterDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
-                       if (! pRasterDoc) {\r
-                               sys_error (ERR_SEVERE, "Unable to create image file");\r
-                               return;\r
-                       }
-                       ImageFile& imageFile = pRasterDoc->getImageFile();
-                       
-                       imageFile.setArraySize (xSize, ySize);
-                       wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), imageFile.nx() + 1, m_frame, wxPD_CAN_ABORT);
-                       for (unsigned int i = 0; i < imageFile.nx(); i++) {
-                               rPhantom.convertToImagefile (imageFile, nSamples, Trace::TRACE_NONE, i, 1, true);
-                               if (! dlgProgress.Update(i+1)) {
-                                       pRasterDoc->DeleteAllViews();
-                                       return;
-                               }
-                       }
-                       pRasterDoc->Modify(true);
-                       pRasterDoc->UpdateAllViews(this);
-                       ImageFileView* rasterView = dynamic_cast<ImageFileView*>(pRasterDoc->GetFirstView());\r
-                       if (rasterView) {\r
-                               rasterView->getFrame()->SetFocus();\r
-                               rasterView->OnUpdate (rasterView, NULL);\r
-                       }\r
-                       
-                       std::ostringstream os;
-                       os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n";
-                       *theApp->getLog() << os.str().c_str();
-               }\r
-       }
+  DialogGetRasterParameters dialogRaster (m_frame, 256, 256, 1);
+  int retVal = dialogRaster.ShowModal();
+  if (retVal == wxID_OK) {
+    int xSize = dialogRaster.getXSize();
+    int ySize = dialogRaster.getYSize();
+    int nSamples = dialogRaster.getNSamples();
+    if (nSamples < 1)
+      nSamples = 1;
+    if (xSize > 0 && ySize > 0) {
+      const Phantom& rPhantom = GetDocument()->getPhantom();
+      ImageFileDocument* pRasterDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
+      if (! pRasterDoc) {\r
+        sys_error (ERR_SEVERE, "Unable to create image file");\r
+        return;\r
+      }
+      ImageFile& imageFile = pRasterDoc->getImageFile();
+      
+      imageFile.setArraySize (xSize, ySize);
+      wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), imageFile.nx() + 1, m_frame, wxPD_CAN_ABORT);
+      for (unsigned int i = 0; i < imageFile.nx(); i++) {
+        rPhantom.convertToImagefile (imageFile, nSamples, Trace::TRACE_NONE, i, 1, true);
+        if (! dlgProgress.Update(i+1)) {
+          pRasterDoc->DeleteAllViews();
+          return;
+        }
+      }
+      pRasterDoc->Modify(true);
+      pRasterDoc->UpdateAllViews(this);
+      ImageFileView* rasterView = dynamic_cast<ImageFileView*>(pRasterDoc->GetFirstView());\r
+      if (rasterView) {\r
+        rasterView->getFrame()->SetFocus();\r
+        rasterView->OnUpdate (rasterView, NULL);\r
+      }\r
+      
+      std::ostringstream os;
+      os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n";
+      *theApp->getLog() << os.str().c_str();
+    }\r
+  }
 }
 
 
 PhantomCanvas* 
 PhantomView::CreateCanvas (wxView *view, wxFrame *parent)
 {
-    PhantomCanvas* pCanvas;
-    int width, height;
-    parent->GetClientSize(&width, &height);
-    
-    pCanvas = new PhantomCanvas (dynamic_cast<PhantomView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
-    
-    pCanvas->SetBackgroundColour(*wxWHITE);
-    pCanvas->Clear();
-    
-    return pCanvas;
+  PhantomCanvas* pCanvas;
+  int width, height;
+  parent->GetClientSize(&width, &height);
+  
+  pCanvas = new PhantomCanvas (dynamic_cast<PhantomView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
+  
+  pCanvas->SetBackgroundColour(*wxWHITE);
+  pCanvas->Clear();
+  
+  return pCanvas;
 }
 
 wxFrame*
 PhantomView::CreateChildFrame(wxDocument *doc, wxView *view)
 {
-    wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
-    
-    wxMenu *file_menu = new wxMenu;
-    
-    file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
-    file_menu->Append(wxID_OPEN, "&Open...");
-    file_menu->Append(wxID_CLOSE, "&Close");
-    
-    file_menu->AppendSeparator();
-    file_menu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties");
-       
-    file_menu->AppendSeparator();
-    file_menu->Append(wxID_PRINT, "&Print...");
-    file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
-    file_menu->Append(wxID_PREVIEW, "Print Pre&view");
-    
-    wxMenu *process_menu = new wxMenu;
-    process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...");
-    process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...");
-       
-    wxMenu *help_menu = new wxMenu;
-    help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
-    help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
-    
-    wxMenuBar *menu_bar = new wxMenuBar;
-    
-    menu_bar->Append(file_menu, "&File");
-    menu_bar->Append(process_menu, "&Process");
-    menu_bar->Append(help_menu, "&Help");
-    
-    subframe->SetMenuBar(menu_bar);
-    
-    subframe->Centre(wxBOTH);
-    
-    return subframe;
+  wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
+  
+  wxMenu *file_menu = new wxMenu;
+  
+  file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
+  file_menu->Append(wxID_OPEN, "&Open...");
+  file_menu->Append(wxID_CLOSE, "&Close");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(PHMMENU_FILE_PROPERTIES, "P&roperties");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(wxID_PRINT, "&Print...");
+  file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
+  file_menu->Append(wxID_PREVIEW, "Print Pre&view");
+  
+  wxMenu *process_menu = new wxMenu;
+  process_menu->Append(PHMMENU_PROCESS_RASTERIZE, "&Rasterize...");
+  process_menu->Append(PHMMENU_PROCESS_PROJECTIONS, "&Projections...");
+  
+  wxMenu *help_menu = new wxMenu;
+  help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
+  help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+  
+  wxMenuBar *menu_bar = new wxMenuBar;
+  
+  menu_bar->Append(file_menu, "&File");
+  menu_bar->Append(process_menu, "&Process");
+  menu_bar->Append(help_menu, "&Help");
+  
+  subframe->SetMenuBar(menu_bar);
+  
+  subframe->Centre(wxBOTH);
+  
+  return subframe;
 }
 
 
 bool 
 PhantomView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
-    m_frame = CreateChildFrame(doc, this);
-    SetFrame(m_frame);
-       
-    int width, height;
-    m_frame->GetClientSize(&width, &height);
-    m_frame->SetTitle("PhantomView");
-    m_canvas = CreateCanvas(this, m_frame);
-       
+  m_frame = CreateChildFrame(doc, this);
+  SetFrame(m_frame);
+  
+  int width, height;
+  m_frame->GetClientSize(&width, &height);
+  m_frame->SetTitle("PhantomView");
+  m_canvas = CreateCanvas(this, m_frame);
+  
 #ifdef __X__
-    int x, y;  // X requires a forced resize
-    m_frame->GetSize(&x, &y);
-    m_frame->SetSize(-1, -1, x, y);
+  int x, y;  // X requires a forced resize
+  m_frame->GetSize(&x, &y);
+  m_frame->SetSize(-1, -1, x, y);
 #endif
-       
-    m_frame->Show(true);
-    Activate(true);
-       
-    return true;
+  
+  m_frame->Show(true);
+  Activate(true);
+  
+  return true;
 }
 
 
 void 
 PhantomView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-    if (m_canvas)
-               m_canvas->Refresh();
+  if (m_canvas)
+    m_canvas->Refresh();
 }
 
 bool 
 PhantomView::OnClose (bool deleteWindow)
 {
-    if (!GetDocument()->Close())
-        return false;
-       
-    m_canvas->Clear();
-    m_canvas->m_pView = NULL;
-    m_canvas = NULL;
-    wxString s(wxTheApp->GetAppName());
-    if (m_frame)
-               m_frame->SetTitle(s);
-    SetFrame(NULL);
-       
-    Activate(false);
-    
-    if (deleteWindow) {
-        delete m_frame;
-        return true;
-    }
+  if (!GetDocument()->Close())
+    return false;
+  
+  m_canvas->Clear();
+  m_canvas->m_pView = NULL;
+  m_canvas = NULL;
+  wxString s(wxTheApp->GetAppName());
+  if (m_frame)
+    m_frame->SetTitle(s);
+  SetFrame(NULL);
+  
+  Activate(false);
+  
+  if (deleteWindow) {
+    delete m_frame;
     return true;
+  }
+  return true;
 }
 
 void
 PhantomView::OnDraw (wxDC* dc)
 {
-       int xsize, ysize;
-       m_canvas->GetClientSize (&xsize, &ysize);
-       SGPDriver driver (dc, xsize, ysize);
-       SGP sgp (driver);
-       const Phantom& rPhantom = GetDocument()->getPhantom();
-       sgp.setColor (C_RED);
-       rPhantom.show (sgp);
+  int xsize, ysize;
+  m_canvas->GetClientSize (&xsize, &ysize);
+  SGPDriver driver (dc, xsize, ysize);
+  SGP sgp (driver);
+  const Phantom& rPhantom = GetDocument()->getPhantom();
+  sgp.setColor (C_RED);
+  rPhantom.show (sgp);
 }
 
 // ProjectionCanvas
@@ -847,14 +979,14 @@ PhantomView::OnDraw (wxDC* dc)
 ProjectionFileCanvas::ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
 : wxScrolledWindow(frame, -1, pos, size, style)
 {
-    m_pView = v;
+  m_pView = v;
 }
 
 void 
 ProjectionFileCanvas::OnDraw(wxDC& dc)
 {
-    if (m_pView)
-        m_pView->OnDraw(& dc);
+  if (m_pView)
+    m_pView->OnDraw(& dc);
 }
 
 // ProjectionFileView
@@ -869,22 +1001,22 @@ END_EVENT_TABLE()
 ProjectionFileView::ProjectionFileView(void) 
 : wxView(), m_canvas(NULL), m_frame(NULL)
 {
-    m_iDefaultNX = 256;
-    m_iDefaultNY = 256;
-       m_iDefaultFilter = SignalFilter::FILTER_ABS_BANDLIMIT;
-       m_dDefaultFilterParam = 1.;
+  m_iDefaultNX = 256;
+  m_iDefaultNY = 256;
+  m_iDefaultFilter = SignalFilter::FILTER_ABS_BANDLIMIT;
+  m_dDefaultFilterParam = 1.;
 #if HAVE_FFTW
-       m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_RFFTW;
-       m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_INVERSE_FOURIER;
+  m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_RFFTW;
+  m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_INVERSE_FOURIER;
 #else
-       m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_CONVOLUTION;
-       m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT;
+  m_iDefaultFilterMethod = ProcessSignal::FILTER_METHOD_CONVOLUTION;
+  m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT;
 #endif
-       m_iDefaultZeropad = 1;
-       m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF3;
-       m_iDefaultInterpolation = Backprojector::INTERP_LINEAR;
-       m_iDefaultInterpParam = 1;
-       m_iDefaultTrace = Trace::TRACE_NONE;
+  m_iDefaultZeropad = 1;
+  m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF3;
+  m_iDefaultInterpolation = Backprojector::INTERP_LINEAR;
+  m_iDefaultInterpParam = 1;
+  m_iDefaultTrace = Trace::TRACE_NONE;
 }
 
 ProjectionFileView::~ProjectionFileView(void)
@@ -894,279 +1026,279 @@ ProjectionFileView::~ProjectionFileView(void)
 void
 ProjectionFileView::OnProperties (wxCommandEvent& event)
 {
-       const Projections& rProj = GetDocument()->getProjections();
-       std::ostringstream os;
-       rProj.printScanInfo(os);
-       *theApp->getLog() << os.str().c_str();
-       wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Projection File Properties", wxOK | wxICON_INFORMATION);
-       dialogMsg.ShowModal();
+  const Projections& rProj = GetDocument()->getProjections();
+  std::ostringstream os;
+  rProj.printScanInfo(os);
+  *theApp->getLog() << os.str().c_str();
+  wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Projection File Properties", wxOK | wxICON_INFORMATION);
+  dialogMsg.ShowModal();
 }
 
 
 void
 ProjectionFileView::OnReconstruct (wxCommandEvent& event)
 {
-       DialogGetReconstructionParameters dialogReconstruction (m_frame, m_iDefaultNX, m_iDefaultNY, m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, m_iDefaultTrace);
-       
-       int retVal = dialogReconstruction.ShowModal();
-       if (retVal == wxID_OK) {
-               m_iDefaultNX = dialogReconstruction.getXSize();
-               m_iDefaultNY = dialogReconstruction.getYSize();
-               wxString optFilterName = dialogReconstruction.getFilterName();
-               m_iDefaultFilter = SignalFilter::convertFilterNameToID (optFilterName.c_str());
-               m_dDefaultFilterParam = dialogReconstruction.getFilterParam();
-               wxString optFilterMethodName = dialogReconstruction.getFilterMethodName();
-               m_iDefaultFilterMethod = ProcessSignal::convertFilterMethodNameToID(optFilterMethodName.c_str());
-               m_iDefaultZeropad = dialogReconstruction.getZeropad();
-               wxString optFilterGenerationName = dialogReconstruction.getFilterGenerationName();
-               m_iDefaultFilterGeneration = ProcessSignal::convertFilterGenerationNameToID (optFilterGenerationName.c_str());
-               wxString optInterpName = dialogReconstruction.getInterpName();
-               m_iDefaultInterpolation = Backprojector::convertInterpNameToID (optInterpName.c_str());
-               m_iDefaultInterpParam = dialogReconstruction.getInterpParam();
-               wxString optBackprojectName = dialogReconstruction.getBackprojectName();
-               m_iDefaultBackprojector = Backprojector::convertBackprojectNameToID (optBackprojectName.c_str());
-               m_iDefaultTrace = dialogReconstruction.getTrace();
-               if (m_iDefaultNX > 0 && m_iDefaultNY > 0) {
-                       ImageFileDocument* pReconDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
-                       if (pReconDoc) {\r
-                               sys_error (ERR_SEVERE, "Unable to create image file");\r
-                               return;\r
-                       }
-                       ImageFile& imageFile = pReconDoc->getImageFile();
-                       const Projections& rProj = GetDocument()->getProjections();
-                       imageFile.setArraySize (m_iDefaultNX, m_iDefaultNY);
-                       
-                       if (m_iDefaultFilterMethod != ProcessSignal::FILTER_METHOD_CONVOLUTION && m_iDefaultFilterGeneration == ProcessSignal::FILTER_GENERATION_DIRECT && rProj.geometry() != Scanner::GEOMETRY_PARALLEL) {
-                               wxMessageBox ("Sorry!\nCurrently, frequency-based filtering with direct filter generation is not support for geometries other than parallel.\nAborting command.", "Not Supported", wxOK | wxICON_WARNING, m_frame);
-                               return;
-                       }
+  DialogGetReconstructionParameters dialogReconstruction (m_frame, m_iDefaultNX, m_iDefaultNY, m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, m_iDefaultTrace);
+  
+  int retVal = dialogReconstruction.ShowModal();
+  if (retVal == wxID_OK) {
+    m_iDefaultNX = dialogReconstruction.getXSize();
+    m_iDefaultNY = dialogReconstruction.getYSize();
+    wxString optFilterName = dialogReconstruction.getFilterName();
+    m_iDefaultFilter = SignalFilter::convertFilterNameToID (optFilterName.c_str());
+    m_dDefaultFilterParam = dialogReconstruction.getFilterParam();
+    wxString optFilterMethodName = dialogReconstruction.getFilterMethodName();
+    m_iDefaultFilterMethod = ProcessSignal::convertFilterMethodNameToID(optFilterMethodName.c_str());
+    m_iDefaultZeropad = dialogReconstruction.getZeropad();
+    wxString optFilterGenerationName = dialogReconstruction.getFilterGenerationName();
+    m_iDefaultFilterGeneration = ProcessSignal::convertFilterGenerationNameToID (optFilterGenerationName.c_str());
+    wxString optInterpName = dialogReconstruction.getInterpName();
+    m_iDefaultInterpolation = Backprojector::convertInterpNameToID (optInterpName.c_str());
+    m_iDefaultInterpParam = dialogReconstruction.getInterpParam();
+    wxString optBackprojectName = dialogReconstruction.getBackprojectName();
+    m_iDefaultBackprojector = Backprojector::convertBackprojectNameToID (optBackprojectName.c_str());
+    m_iDefaultTrace = dialogReconstruction.getTrace();
+    if (m_iDefaultNX > 0 && m_iDefaultNY > 0) {
+      ImageFileDocument* pReconDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
+      if (pReconDoc) {\r
+        sys_error (ERR_SEVERE, "Unable to create image file");\r
+        return;\r
+      }
+      ImageFile& imageFile = pReconDoc->getImageFile();
+      const Projections& rProj = GetDocument()->getProjections();
+      imageFile.setArraySize (m_iDefaultNX, m_iDefaultNY);
+      
+      if (m_iDefaultFilterMethod != ProcessSignal::FILTER_METHOD_CONVOLUTION && m_iDefaultFilterGeneration == ProcessSignal::FILTER_GENERATION_DIRECT && rProj.geometry() != Scanner::GEOMETRY_PARALLEL) {
+        wxMessageBox ("Sorry!\nCurrently, frequency-based filtering with direct filter generation is not support for geometries other than parallel.\nAborting command.", "Not Supported", wxOK | wxICON_WARNING, m_frame);
+        return;
+      }
 #if 0
-                       SGPDriver* pSGPDriver = NULL;
-                       SGP* pSGP = NULL;
-                       wxMemoryDC* pDCPlot = NULL;
-                       wxBitmap bitmap;
-                       if (m_iDefaultTrace >= Trace::TRACE_PLOT) {
-                               bitmap.Create (500, 500);
-                               pDCPlot = new wxMemoryDC;
-                               pDCPlot->SelectObject (bitmap);
-                               pSGPDriver = new SGPDriver (dynamic_cast<wxDC*>pDCPlot, 500, 500);
-                               pSGP = new SGP (*pSGPDriver);
-                       }
-                       Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace, pSGP);
-                       delete pSGP;
+      SGPDriver* pSGPDriver = NULL;
+      SGP* pSGP = NULL;
+      wxMemoryDC* pDCPlot = NULL;
+      wxBitmap bitmap;
+      if (m_iDefaultTrace >= Trace::TRACE_PLOT) {
+        bitmap.Create (500, 500);
+        pDCPlot = new wxMemoryDC;
+        pDCPlot->SelectObject (bitmap);
+        pSGPDriver = new SGPDriver (dynamic_cast<wxDC*>pDCPlot, 500, 500);
+        pSGP = new SGP (*pSGPDriver);
+      }
+      Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace, pSGP);
+      delete pSGP;
 #else
-                       Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace);
+      Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace);
 #endif
-                       \r
-                       Timer timerRecon;
-                       if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
-                               ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstruct, rProj, imageFile, m_iDefaultTrace, m_frame);
-                               for (int iView = 0; iView < rProj.nView(); iView++) {
-                                       ::wxYield();
-                                       ::wxYield();
-                                       if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView)) {
-                                               delete pDlgReconstruct;
-                                               delete pReconstruct;
-                                               pReconDoc->DeleteAllViews();
-                                               return;
-                                       }
-                                       ::wxYield();
-                                       ::wxYield();
-                                       while (pDlgReconstruct->isPaused()) {
-                                               ::wxYield();
-                                               ::wxUsleep(50);
-                                       }
-                               }
-                               delete pDlgReconstruct;
-                       } else {
-                               wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, m_frame, wxPD_CAN_ABORT);
-                               for (int i = 0; i < rProj.nView(); i++) {
-                                       pReconstruct->reconstructView (i, 1);
-                                       if (! dlgProgress.Update(i + 1)) {
-                                               delete pReconstruct;
-                                               pReconDoc->DeleteAllViews();
-                                               return;
-                                       }
-                               }
-                       }
-                       delete pReconstruct;
-                       pReconDoc->Modify(true);
-                       pReconDoc->UpdateAllViews(this);
-                       ImageFileView* rasterView = dynamic_cast<ImageFileView*>(pReconDoc->GetFirstView());\r
-                       if (rasterView) {\r
-                               rasterView->getFrame()->SetFocus();\r
-                               rasterView->OnUpdate (rasterView, NULL);\r
-                       }\r
-                       std::ostringstream os;
-                       os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str();
-                       *theApp->getLog() << os.str().c_str() << "\n";
-                       imageFile.labelAdd (rProj.getLabel());
-                       imageFile.labelAdd (Array2dFileLabel::L_HISTORY, os.str().c_str(), timerRecon.timerEnd());
-               }
-       }
+      \r
+      Timer timerRecon;
+      if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
+        ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstruct, rProj, imageFile, m_iDefaultTrace, m_frame);
+        for (int iView = 0; iView < rProj.nView(); iView++) {
+          ::wxYield();
+          ::wxYield();
+          if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView)) {
+            delete pDlgReconstruct;
+            delete pReconstruct;
+            pReconDoc->DeleteAllViews();
+            return;
+          }
+          ::wxYield();
+          ::wxYield();
+          while (pDlgReconstruct->isPaused()) {
+            ::wxYield();
+            ::wxUsleep(50);
+          }
+        }
+        delete pDlgReconstruct;
+      } else {
+        wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, m_frame, wxPD_CAN_ABORT);
+        for (int i = 0; i < rProj.nView(); i++) {
+          pReconstruct->reconstructView (i, 1);
+          if (! dlgProgress.Update(i + 1)) {
+            delete pReconstruct;
+            pReconDoc->DeleteAllViews();
+            return;
+          }
+        }
+      }
+      delete pReconstruct;
+      pReconDoc->Modify(true);
+      pReconDoc->UpdateAllViews(this);
+      ImageFileView* rasterView = dynamic_cast<ImageFileView*>(pReconDoc->GetFirstView());\r
+      if (rasterView) {\r
+        rasterView->getFrame()->SetFocus();\r
+        rasterView->OnUpdate (rasterView, NULL);\r
+      }\r
+      std::ostringstream os;
+      os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str();
+      *theApp->getLog() << os.str().c_str() << "\n";
+      imageFile.labelAdd (rProj.getLabel());
+      imageFile.labelAdd (Array2dFileLabel::L_HISTORY, os.str().c_str(), timerRecon.timerEnd());
+    }
+  }
 }
 
 
 ProjectionFileCanvas* 
 ProjectionFileView::CreateCanvas (wxView *view, wxFrame *parent)
 {
-    ProjectionFileCanvas* pCanvas;
-    int width, height;
-    parent->GetClientSize(&width, &height);
-    
-    pCanvas = new ProjectionFileCanvas (dynamic_cast<ProjectionFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
-    
-    pCanvas->SetScrollbars(20, 20, 50, 50);
-    pCanvas->SetBackgroundColour(*wxWHITE);
-    pCanvas->Clear();
-    
-    return pCanvas;
+  ProjectionFileCanvas* pCanvas;
+  int width, height;
+  parent->GetClientSize(&width, &height);
+  
+  pCanvas = new ProjectionFileCanvas (dynamic_cast<ProjectionFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
+  
+  pCanvas->SetScrollbars(20, 20, 50, 50);
+  pCanvas->SetBackgroundColour(*wxWHITE);
+  pCanvas->Clear();
+  
+  return pCanvas;
 }
 
 wxFrame*
 ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 {
-    wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
-    
-    wxMenu *file_menu = new wxMenu;
-    
-    file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
-    file_menu->Append(wxID_OPEN, "&Open...");
-    file_menu->Append(wxID_SAVE, "&Save");
-    file_menu->Append(wxID_SAVEAS, "Save &As...");
-    file_menu->Append(wxID_CLOSE, "&Close");
-    
-    file_menu->AppendSeparator();
-    file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
-       
-    file_menu->AppendSeparator();
-    file_menu->Append(wxID_PRINT, "&Print...");
-    file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
-    file_menu->Append(wxID_PREVIEW, "Print Pre&view");
-    
-    wxMenu *process_menu = new wxMenu;
-    process_menu->Append(PJMENU_PROCESS_RECONSTRUCT, "R&econstruct...");
-       
-    wxMenu *help_menu = new wxMenu;
-    help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
-    help_menu->AppendSeparator();
-    help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
-    
-    wxMenuBar *menu_bar = new wxMenuBar;
-    
-    menu_bar->Append(file_menu, "&File");
-    menu_bar->Append(process_menu, "&Process");
-    menu_bar->Append(help_menu, "&Help");
-    
-    subframe->SetMenuBar(menu_bar);
-    
-    subframe->Centre(wxBOTH);
-    
-    return subframe;
+  wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Projection Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+  
+  wxMenu *file_menu = new wxMenu;
+  
+  file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
+  file_menu->Append(wxID_OPEN, "&Open...");
+  file_menu->Append(wxID_SAVE, "&Save");
+  file_menu->Append(wxID_SAVEAS, "Save &As...");
+  file_menu->Append(wxID_CLOSE, "&Close");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(wxID_PRINT, "&Print...");
+  file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
+  file_menu->Append(wxID_PREVIEW, "Print Pre&view");
+  
+  wxMenu *process_menu = new wxMenu;
+  process_menu->Append(PJMENU_PROCESS_RECONSTRUCT, "R&econstruct...");
+  
+  wxMenu *help_menu = new wxMenu;
+  help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
+  help_menu->AppendSeparator();
+  help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+  
+  wxMenuBar *menu_bar = new wxMenuBar;
+  
+  menu_bar->Append(file_menu, "&File");
+  menu_bar->Append(process_menu, "&Process");
+  menu_bar->Append(help_menu, "&Help");
+  
+  subframe->SetMenuBar(menu_bar);
+  
+  subframe->Centre(wxBOTH);
+  
+  return subframe;
 }
 
 
 bool 
 ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
-    m_frame = CreateChildFrame(doc, this);
-    SetFrame(m_frame);
-    
-    int width, height;
-    m_frame->GetClientSize(&width, &height);
-    m_frame->SetTitle("ProjectionFileView");
-    m_canvas = CreateCanvas(this, m_frame);
-       
+  m_frame = CreateChildFrame(doc, this);
+  SetFrame(m_frame);
+  
+  int width, height;
+  m_frame->GetClientSize(&width, &height);
+  m_frame->SetTitle("ProjectionFileView");
+  m_canvas = CreateCanvas(this, m_frame);
+  
 #ifdef __X__
-    int x, y;  // X requires a forced resize
-    m_frame->GetSize(&x, &y);
-    m_frame->SetSize(-1, -1, x, y);
+  int x, y;  // X requires a forced resize
+  m_frame->GetSize(&x, &y);
+  m_frame->SetSize(-1, -1, x, y);
 #endif
-       
-    m_frame->Show(true);
-    Activate(true);
-    
-    return true;
+  
+  m_frame->Show(true);
+  Activate(true);
+  
+  return true;
 }
 
 void 
 ProjectionFileView::OnDraw (wxDC* dc)
 {
-    if (m_bitmap.Ok())
-               dc->DrawBitmap (m_bitmap, 0, 0, false);
+  if (m_bitmap.Ok())
+    dc->DrawBitmap (m_bitmap, 0, 0, false);
 }
 
 
 void 
 ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-    const Projections& rProj = GetDocument()->getProjections();
-    const int nDet = rProj.nDet();
-    const int nView = rProj.nView();
-    if (nDet != 0 && nView != 0) {
-               const DetectorArray& detarray = rProj.getDetectorArray(0);
-               const DetectorValue* detval = detarray.detValues();
-               double min = detval[0];
-               double max = detval[0];
-               for (int iy = 0; iy < nView; iy++) {
-                       const DetectorArray& detarray = rProj.getDetectorArray(iy);
-                       const DetectorValue* detval = detarray.detValues();
-                       for (int ix = 0; ix < nDet; ix++) {
-                               if (min > detval[ix])
-                                       min = detval[ix];
-                               else if (max < detval[ix])
-                                       max = detval[ix];
-                       }
-               }
-               
-               unsigned char* imageData = new unsigned char [nDet * nView * 3];
-               double scale = (max - min) / 255;
-               for (int iy2 = 0; iy2 < nView; iy2++) {
-                       const DetectorArray& detarray = rProj.getDetectorArray (iy2);
-                       const DetectorValue* detval = detarray.detValues();
-                       for (int ix = 0; ix < nDet; ix++) {
-                               int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
-                               intensity = clamp(intensity, 0, 255);
-                               int baseAddr = (iy2 * nDet + ix) * 3;
-                               imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
-                       }
-               }
-               wxImage image (nDet, nView, imageData, true);
-               m_bitmap = image.ConvertToBitmap();
-               delete imageData;
-               int xSize = nDet;
-               int ySize = nView;
-               xSize = clamp (xSize, 0, 800);
-               ySize = clamp (ySize, 0, 800);
-               m_frame->SetClientSize (xSize, ySize);
-               m_canvas->SetScrollbars (20, 20, nDet/20, nView/20);
+  const Projections& rProj = GetDocument()->getProjections();
+  const int nDet = rProj.nDet();
+  const int nView = rProj.nView();
+  if (nDet != 0 && nView != 0) {
+    const DetectorArray& detarray = rProj.getDetectorArray(0);
+    const DetectorValue* detval = detarray.detValues();
+    double min = detval[0];
+    double max = detval[0];
+    for (int iy = 0; iy < nView; iy++) {
+      const DetectorArray& detarray = rProj.getDetectorArray(iy);
+      const DetectorValue* detval = detarray.detValues();
+      for (int ix = 0; ix < nDet; ix++) {
+        if (min > detval[ix])
+          min = detval[ix];
+        else if (max < detval[ix])
+          max = detval[ix];
+      }
+    }
+    
+    unsigned char* imageData = new unsigned char [nDet * nView * 3];
+    double scale = (max - min) / 255;
+    for (int iy2 = 0; iy2 < nView; iy2++) {
+      const DetectorArray& detarray = rProj.getDetectorArray (iy2);
+      const DetectorValue* detval = detarray.detValues();
+      for (int ix = 0; ix < nDet; ix++) {
+        int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
+        intensity = clamp(intensity, 0, 255);
+        int baseAddr = (iy2 * nDet + ix) * 3;
+        imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
+      }
     }
-       
-    if (m_canvas)
-               m_canvas->Refresh();
+    wxImage image (nDet, nView, imageData, true);
+    m_bitmap = image.ConvertToBitmap();
+    delete imageData;
+    int xSize = nDet;
+    int ySize = nView;
+    xSize = clamp (xSize, 0, 800);
+    ySize = clamp (ySize, 0, 800);
+    m_frame->SetClientSize (xSize, ySize);
+    m_canvas->SetScrollbars (20, 20, nDet/20, nView/20);
+  }
+  
+  if (m_canvas)
+    m_canvas->Refresh();
 }
 
 bool 
 ProjectionFileView::OnClose (bool deleteWindow)
 {
-    if (!GetDocument()->Close())
-        return false;
-       
-    m_canvas->Clear();
-    m_canvas->m_pView = NULL;
-    m_canvas = NULL;
-    wxString s(wxTheApp->GetAppName());
-    if (m_frame)
-               m_frame->SetTitle(s);
-    SetFrame(NULL);
-       
-    Activate(false);
-    
-    if (deleteWindow) {
-        delete m_frame;
-        return true;
-    }
+  if (!GetDocument()->Close())
+    return false;
+  
+  m_canvas->Clear();
+  m_canvas->m_pView = NULL;
+  m_canvas = NULL;
+  wxString s(wxTheApp->GetAppName());
+  if (m_frame)
+    m_frame->SetTitle(s);
+  SetFrame(NULL);
+  
+  Activate(false);
+  
+  if (deleteWindow) {
+    delete m_frame;
     return true;
+  }
+  return true;
 }
 
 
@@ -1175,14 +1307,14 @@ ProjectionFileView::OnClose (bool deleteWindow)
 PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style)
 : wxScrolledWindow(frame, -1, pos, size, style)
 {
-    m_pView = v;
+  m_pView = v;
 }
 
 void 
 PlotFileCanvas::OnDraw(wxDC& dc)
 {
-    if (m_pView)
-        m_pView->OnDraw(& dc);
+  if (m_pView)
+    m_pView->OnDraw(& dc);
 }\r
 
 
@@ -1208,242 +1340,242 @@ PlotFileView::~PlotFileView(void)
 void
 PlotFileView::OnProperties (wxCommandEvent& event)
 {
-       const PlotFile& rProj = GetDocument()->getPlotFile();
-       std::ostringstream os;\r
-       os << "Columns: " << rProj.getNumColumns() << ", Records: " << rProj.getNumRecords() << "\n";
-       *theApp->getLog() << os.str().c_str();
-       wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Plot File Properties", wxOK | wxICON_INFORMATION);
-       dialogMsg.ShowModal();
+  const PlotFile& rProj = GetDocument()->getPlotFile();
+  std::ostringstream os;\r
+  os << "Columns: " << rProj.getNumColumns() << ", Records: " << rProj.getNumRecords() << "\n";
+  *theApp->getLog() << os.str().c_str();
+  wxMessageDialog dialogMsg (m_frame, os.str().c_str(), "Plot File Properties", wxOK | wxICON_INFORMATION);
+  dialogMsg.ShowModal();
 }
 
 
 void \r
 PlotFileView::OnScaleAuto (wxCommandEvent& event)\r
 {\r
-       const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
-       double min, max, mean, mode, median, stddev;\r
-       rPlotFile.statistics (1, min, max, mean, mode, median, stddev);\r
-       DialogAutoScaleParameters dialogAutoScale (m_frame, mean, mode, median, stddev, m_dAutoScaleFactor);\r
-    int iRetVal = dialogAutoScale.ShowModal();\r
-    if (iRetVal == wxID_OK) {\r
-               m_bMinSpecified = true;\r
-               m_bMaxSpecified = true;\r
-               double dMin, dMax;\r
-               if (dialogAutoScale.getMinMax (&dMin, &dMax)) {\r
-                       m_dMinPixel = dMin;\r
-                       m_dMaxPixel = dMax;\r
-                       m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();\r
-                       OnUpdate (this, NULL);\r
-               }\r
+  const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
+  double min, max, mean, mode, median, stddev;\r
+  rPlotFile.statistics (1, min, max, mean, mode, median, stddev);\r
+  DialogAutoScaleParameters dialogAutoScale (m_frame, mean, mode, median, stddev, m_dAutoScaleFactor);\r
+  int iRetVal = dialogAutoScale.ShowModal();\r
+  if (iRetVal == wxID_OK) {\r
+    m_bMinSpecified = true;\r
+    m_bMaxSpecified = true;\r
+    double dMin, dMax;\r
+    if (dialogAutoScale.getMinMax (&dMin, &dMax)) {\r
+      m_dMinPixel = dMin;\r
+      m_dMaxPixel = dMax;\r
+      m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();\r
+      OnUpdate (this, NULL);\r
     }\r
+  }\r
 }\r
 \r
 void \r
 PlotFileView::OnScaleMinMax (wxCommandEvent& event)\r
 {\r
-       const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
-    double min, max;\r
-\r
-    if (! m_bMinSpecified && ! m_bMaxSpecified) {\r
-               if (! rPlotFile.getMinMax (1, min, max)) {\r
-                       *theApp->getLog() << "Error: unable to find Min/Max\n";\r
-                       return;\r
-       }\r
-       }\r
-       \r
-    if (m_bMinSpecified)\r
-               min = m_dMinPixel;\r
-    if (m_bMaxSpecified)\r
-               max = m_dMaxPixel;\r
-       \r
-    DialogGetMinMax dialogMinMax (m_frame, "Set Y-axis Minimum & Maximum", min, max);\r
-    int retVal = dialogMinMax.ShowModal();\r
-    if (retVal == wxID_OK) {\r
-               m_bMinSpecified = true;\r
-               m_bMaxSpecified = true;\r
-               m_dMinPixel = dialogMinMax.getMinimum();\r
-               m_dMaxPixel = dialogMinMax.getMaximum();\r
-               OnUpdate (this, NULL);\r
+  const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
+  double min, max;\r
+  \r
+  if (! m_bMinSpecified && ! m_bMaxSpecified) {\r
+    if (! rPlotFile.getMinMax (1, min, max)) {\r
+      *theApp->getLog() << "Error: unable to find Min/Max\n";\r
+      return;\r
     }\r
+  }\r
+  \r
+  if (m_bMinSpecified)\r
+    min = m_dMinPixel;\r
+  if (m_bMaxSpecified)\r
+    max = m_dMaxPixel;\r
+  \r
+  DialogGetMinMax dialogMinMax (m_frame, "Set Y-axis Minimum & Maximum", min, max);\r
+  int retVal = dialogMinMax.ShowModal();\r
+  if (retVal == wxID_OK) {\r
+    m_bMinSpecified = true;\r
+    m_bMaxSpecified = true;\r
+    m_dMinPixel = dialogMinMax.getMinimum();\r
+    m_dMaxPixel = dialogMinMax.getMaximum();\r
+    OnUpdate (this, NULL);\r
+  }\r
 }\r
 \r
 \r
 PlotFileCanvas* 
 PlotFileView::CreateCanvas (wxView *view, wxFrame *parent)
 {
-    PlotFileCanvas* pCanvas;
-    int width, height;
-    parent->GetClientSize(&width, &height);
-    
-    pCanvas = new PlotFileCanvas (dynamic_cast<PlotFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
-    
-    pCanvas->SetBackgroundColour(*wxWHITE);
-    pCanvas->Clear();
-    
-    return pCanvas;
+  PlotFileCanvas* pCanvas;
+  int width, height;
+  parent->GetClientSize(&width, &height);
+  
+  pCanvas = new PlotFileCanvas (dynamic_cast<PlotFileView*>(view), parent, wxPoint(0, 0), wxSize(width, height), 0);
+  
+  pCanvas->SetBackgroundColour(*wxWHITE);
+  pCanvas->Clear();
+  
+  return pCanvas;
 }
 
 wxFrame*
 PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 {
-    wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
-    
-    wxMenu *file_menu = new wxMenu;
-    
-    file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
-    file_menu->Append(wxID_OPEN, "&Open...");
-    file_menu->Append(wxID_SAVE, "&Save");
-    file_menu->Append(wxID_SAVEAS, "Save &As...");
-    file_menu->Append(wxID_CLOSE, "&Close");
-    
-    file_menu->AppendSeparator();
-    file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
-       
-    file_menu->AppendSeparator();
-    file_menu->Append(wxID_PRINT, "&Print...");
-    file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
-    file_menu->Append(wxID_PREVIEW, "Print Pre&view");
-    
-    wxMenu *view_menu = new wxMenu;\r
-    view_menu->Append(PLOTMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");\r
-    view_menu->Append(PLOTMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");\r
-    \r
-    wxMenu *help_menu = new wxMenu;
-    help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
-    help_menu->AppendSeparator();
-    help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
-    
-    wxMenuBar *menu_bar = new wxMenuBar;
-    
-    menu_bar->Append(file_menu, "&File");\r
-       menu_bar->Append(view_menu, "&View");
-    menu_bar->Append(help_menu, "&Help");
-    
-    subframe->SetMenuBar(menu_bar);
-    
-    subframe->Centre(wxBOTH);
-    
-    return subframe;
+  wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(10, 10), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+  
+  wxMenu *file_menu = new wxMenu;
+  
+  file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...");
+  file_menu->Append(wxID_OPEN, "&Open...");
+  file_menu->Append(wxID_SAVE, "&Save");
+  file_menu->Append(wxID_SAVEAS, "Save &As...");
+  file_menu->Append(wxID_CLOSE, "&Close");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(PJMENU_FILE_PROPERTIES, "P&roperties");
+  
+  file_menu->AppendSeparator();
+  file_menu->Append(wxID_PRINT, "&Print...");
+  file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
+  file_menu->Append(wxID_PREVIEW, "Print Pre&view");
+  
+  wxMenu *view_menu = new wxMenu;\r
+  view_menu->Append(PLOTMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");\r
+  view_menu->Append(PLOTMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");\r
+  \r
+  wxMenu *help_menu = new wxMenu;
+  help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");
+  help_menu->AppendSeparator();
+  help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+  
+  wxMenuBar *menu_bar = new wxMenuBar;
+  
+  menu_bar->Append(file_menu, "&File");\r
+  menu_bar->Append(view_menu, "&View");
+  menu_bar->Append(help_menu, "&Help");
+  
+  subframe->SetMenuBar(menu_bar);
+  
+  subframe->Centre(wxBOTH);
+  
+  return subframe;
 }
 
 
 bool 
 PlotFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
-    m_frame = CreateChildFrame(doc, this);
-    SetFrame(m_frame);
-    
-       m_bMinSpecified = false;\r
-       m_bMaxSpecified = false;\r
-    m_dAutoScaleFactor = 1.;\r
-\r
-    int width, height;
-    m_frame->GetClientSize(&width, &height);
-    m_frame->SetTitle ("Plot File");
-    m_canvas = CreateCanvas (this, m_frame);
-       
+  m_frame = CreateChildFrame(doc, this);
+  SetFrame(m_frame);
+  
+  m_bMinSpecified = false;\r
+  m_bMaxSpecified = false;\r
+  m_dAutoScaleFactor = 1.;\r
+  \r
+  int width, height;
+  m_frame->GetClientSize(&width, &height);
+  m_frame->SetTitle ("Plot File");
+  m_canvas = CreateCanvas (this, m_frame);
+  
 #ifdef __X__
-    int x, y;  // X requires a forced resize
-    m_frame->GetSize(&x, &y);
-    m_frame->SetSize(-1, -1, x, y);
+  int x, y;  // X requires a forced resize
+  m_frame->GetSize(&x, &y);
+  m_frame->SetSize(-1, -1, x, y);
 #endif
-       
-    m_frame->Show(true);
-    Activate(true);
-    
-    return true;
+  
+  m_frame->Show(true);
+  Activate(true);
+  
+  return true;
 }
 
 void 
 PlotFileView::OnDraw (wxDC* dc)
 {
-    const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
-    const int iNColumns = rPlotFile.getNumColumns();\r
-       const int iNRecords = rPlotFile.getNumRecords();\r
-       \r
-       if (iNColumns > 0 && iNRecords > 0) {\r
-               int xsize, ysize;\r
-               m_canvas->GetClientSize (&xsize, &ysize);\r
-               SGPDriver driver (dc, xsize, ysize);\r
-               SGP sgp (driver);\r
-               const PlotFile& rPhantom = GetDocument()->getPlotFile();\r
-               EZPlot plot (sgp);\r
-               \r
-               if (! rPlotFile.getTitle().empty()) {\r
-                       std::string s("title ");\r
-                       s += rPlotFile.getTitle();\r
-                       plot.ezset (s);\r
-               }\r
-               if (! rPlotFile.getXLabel().empty()) {\r
-                       std::string s("xlabel ");\r
-                       s += rPlotFile.getXLabel();\r
-                       plot.ezset (s);\r
-               }\r
-               if (! rPlotFile.getYLabel().empty()) {\r
-                       std::string s("ylabel ");\r
-                       s += rPlotFile.getYLabel();\r
-                       plot.ezset (s);\r
-               }\r
-               \r
-               if (m_bMinSpecified) {\r
-                       std::ostringstream os;\r
-                       os << "ymin " << m_dMinPixel;\r
-                       plot.ezset (os.str());\r
-               }\r
-\r
-               if (m_bMaxSpecified) {\r
-                       std::ostringstream os;\r
-                       os << "ymax " << m_dMaxPixel;\r
-                       plot.ezset (os.str());\r
-               }\r
-\r
-               plot.ezset("box");\r
-               plot.ezset("grid");\r
-               \r
-               double* pdXaxis = new double [iNRecords];\r
-               rPlotFile.getColumn (0, pdXaxis);\r
-               \r
-               double* pdY = new double [iNRecords];\r
-               for (int iCol = 1; iCol < iNColumns; iCol++) {\r
-                       rPlotFile.getColumn (iCol, pdY);\r
-                       plot.addCurve (pdXaxis, pdY, iNRecords);\r
-               }\r
-               \r
-               delete pdXaxis;\r
-               delete pdY;\r
-               \r
-               plot.plot();\r
-       }\r
+  const PlotFile& rPlotFile = GetDocument()->getPlotFile();\r
+  const int iNColumns = rPlotFile.getNumColumns();\r
+  const int iNRecords = rPlotFile.getNumRecords();\r
+  \r
+  if (iNColumns > 0 && iNRecords > 0) {\r
+    int xsize, ysize;\r
+    m_canvas->GetClientSize (&xsize, &ysize);\r
+    SGPDriver driver (dc, xsize, ysize);\r
+    SGP sgp (driver);\r
+    const PlotFile& rPhantom = GetDocument()->getPlotFile();\r
+    EZPlot plot (sgp);\r
+    \r
+    if (! rPlotFile.getTitle().empty()) {\r
+      std::string s("title ");\r
+      s += rPlotFile.getTitle();\r
+      plot.ezset (s);\r
+    }\r
+    if (! rPlotFile.getXLabel().empty()) {\r
+      std::string s("xlabel ");\r
+      s += rPlotFile.getXLabel();\r
+      plot.ezset (s);\r
+    }\r
+    if (! rPlotFile.getYLabel().empty()) {\r
+      std::string s("ylabel ");\r
+      s += rPlotFile.getYLabel();\r
+      plot.ezset (s);\r
+    }\r
+    \r
+    if (m_bMinSpecified) {\r
+      std::ostringstream os;\r
+      os << "ymin " << m_dMinPixel;\r
+      plot.ezset (os.str());\r
+    }\r
+    \r
+    if (m_bMaxSpecified) {\r
+      std::ostringstream os;\r
+      os << "ymax " << m_dMaxPixel;\r
+      plot.ezset (os.str());\r
+    }\r
+    \r
+    plot.ezset("box");\r
+    plot.ezset("grid");\r
+    \r
+    double* pdXaxis = new double [iNRecords];\r
+    rPlotFile.getColumn (0, pdXaxis);\r
+    \r
+    double* pdY = new double [iNRecords];\r
+    for (int iCol = 1; iCol < iNColumns; iCol++) {\r
+      rPlotFile.getColumn (iCol, pdY);\r
+      plot.addCurve (pdXaxis, pdY, iNRecords);\r
+    }\r
+    \r
+    delete pdXaxis;\r
+    delete pdY;\r
+    \r
+    plot.plot();\r
+  }\r
 }
 
 
 void 
 PlotFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-    if (m_canvas)
-               m_canvas->Refresh();
+  if (m_canvas)
+    m_canvas->Refresh();
 }
 
 bool 
 PlotFileView::OnClose (bool deleteWindow)
 {
-    if (!GetDocument()->Close())
-        return false;
-       
-    m_canvas->Clear();
-    m_canvas->m_pView = NULL;
-    m_canvas = NULL;
-    wxString s(wxTheApp->GetAppName());
-    if (m_frame)
-               m_frame->SetTitle(s);
-    SetFrame(NULL);
-       
-    Activate(false);
-    
-    if (deleteWindow) {
-               delete m_frame;
-               return true;
-    }
+  if (!GetDocument()->Close())
+    return false;
+  
+  m_canvas->Clear();
+  m_canvas->m_pView = NULL;
+  m_canvas = NULL;
+  wxString s(wxTheApp->GetAppName());
+  if (m_frame)
+    m_frame->SetTitle(s);
+  SetFrame(NULL);
+  
+  Activate(false);
+  
+  if (deleteWindow) {
+    delete m_frame;
     return true;
+  }
+  return true;
 }
 
index d06ffa38f4fedf3dc7c61a9a3024e876d340ee8a..1457e8431b7a598328aa0e78682240bb81498f26 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.h,v 1.15 2000/12/21 03:40:58 kevin Exp $
+**  $Id: views.h,v 1.16 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
@@ -68,8 +68,10 @@ public:
     void OnCompare (wxCommandEvent& event);\r
     void OnScaleAuto (wxCommandEvent& event);
     void OnScaleMinMax (wxCommandEvent& event);
-       void OnPlotRow (wxCommandEvent& event);\r
-       void OnPlotCol (wxCommandEvent& event);\r
+         void OnPlotRow (wxCommandEvent& event);\r
+         void OnPlotCol (wxCommandEvent& event);\r
+    void OnCompareRow (wxCommandEvent& event);\r
+    void OnCompareCol (wxCommandEvent& event);\r
 \r
        wxFrame* getFrame()\r
        { return m_frame; }\r
index db92c228aee511cbc53b788b4f0e65539f5a4db7..c49b5a4e482ddd555c8483fe54ef8b256977c609 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: if2.cpp,v 1.3 2000/12/19 21:37:51 kevin Exp $
+**  $Id: if2.cpp,v 1.4 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
 #include "ct.h"
 #include "timer.h"
 
-enum {O_ADD, O_SUB, O_MUL, O_COMP, O_ROW_PLOT, O_COLUMN_PLOT, O_VERBOSE, O_HELP, O_VERSION};
+enum {O_ADD, O_SUB, O_MUL, O_DIVIDE, O_COMP, O_ROW_PLOT, O_COLUMN_PLOT, O_VERBOSE, O_HELP, O_VERSION};
 
 static struct option my_options[] =
 {
   {"add", 0, 0, O_ADD},
   {"sub", 0, 0, O_SUB},
-  {"mul", 0, 0, O_MUL},
+  {"multiply", 0, 0, O_MUL},
+  {"divide", 0, 0, O_DIVIDE},\r
   {"comp", 0, 0, O_COMP},
   {"column-plot", 1, 0, O_COLUMN_PLOT},
   {"row-plot", 1, 0, O_ROW_PLOT},
@@ -45,7 +46,7 @@ static struct option my_options[] =
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: if2.cpp,v 1.3 2000/12/19 21:37:51 kevin Exp $";
+static const char* g_szIdStr = "$Id: if2.cpp,v 1.4 2000/12/22 04:18:00 kevin Exp $";
 
 void 
 if2_usage (const char *program)
@@ -79,21 +80,22 @@ if2_main (int argc, char *const argv[])
   int opt_verbose = 0;
   int opt_add = 0;
   int opt_sub = 0;
-  int opt_mul = 0;
+  int opt_mul = 0;\r
+  bool opt_divide = false;
   int opt_comp = 0;
   bool opt_bImageOutputFile = false;
   bool opt_bPlotOutputFile = false;
   int opt_rowPlot = -1;
   int opt_columnPlot = -1;
   Timer timerProgram;
-
+  
   while (1) {
     char* endptr;
     int c = getopt_long (argc, argv, "", my_options, NULL);
-      
+    
     if (c == -1)
       break;
-      
+    
     switch (c) {
     case O_ADD:
       opt_add = 1;
@@ -103,21 +105,25 @@ if2_main (int argc, char *const argv[])
       opt_sub = 1;
       opt_bImageOutputFile = true;
       break;
-    case O_MUL:
-      opt_mul = 1;
-      opt_bImageOutputFile = true;
-      break;
+    case O_MUL:\r
+      opt_mul = 1;\r
+      opt_bImageOutputFile = true;\r
+      break;\r
+    case O_DIVIDE:\r
+      opt_divide = true;\r
+      opt_bImageOutputFile = true;\r
+      break;\r
     case O_ROW_PLOT:
       opt_rowPlot = strtol(optarg, &endptr, 10);
       if (endptr != optarg + strlen(optarg)) {
-       if2_usage(argv[0]);
+        if2_usage(argv[0]);
       }
       opt_bPlotOutputFile = true;
       break;
     case O_COLUMN_PLOT:
       opt_columnPlot = strtol(optarg, &endptr, 10);
       if (endptr != optarg + strlen(optarg)) {
-       if2_usage(argv[0]);
+        if2_usage(argv[0]);
       }
       opt_bPlotOutputFile = true;
       break;
@@ -143,7 +149,7 @@ if2_main (int argc, char *const argv[])
       return (1);
     }
   }
-
+  
   if ((opt_bImageOutputFile || opt_bPlotOutputFile) && (optind + 3 != argc)) {
     if2_usage(argv[0]);
     return (1);
@@ -157,31 +163,31 @@ if2_main (int argc, char *const argv[])
   in_file2 = argv[optind + 1];
   if (opt_bImageOutputFile || opt_bPlotOutputFile)
     strOutFile = argv[optind + 2];
-
+  
   pim_in1 = new ImageFile ();
   pim_in2 = new ImageFile ();
   ImageFile& im_in1 = *pim_in1;
   ImageFile& im_in2 = *pim_in2;
-
+  
   if (! im_in1.fileRead(in_file1) || ! im_in2.fileRead(in_file2)) {
-      sys_error (ERR_WARNING, "Error reading an image");
-      return (1);
+    sys_error (ERR_WARNING, "Error reading an image");
+    return (1);
   }
-
+  
   if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
     sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
-           im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
+      im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
     return(1);
   }
   if (im_in1.nx() < 0 || im_in1.ny() < 0) {
-      sys_error (ERR_SEVERE, "Error: Size of image < 0");
-      return(1);
+    sys_error (ERR_SEVERE, "Error: Size of image < 0");
+    return(1);
   }
-
+  
   ImageFileArray v1 = im_in1.getArray();
   ImageFileArray v2 = im_in2.getArray();
   ImageFileArray vout = NULL;
-
+  
   if (opt_bImageOutputFile && opt_bPlotOutputFile) {
     sys_error (ERR_SEVERE, "Both Image and Plot output files can not be selected simultaneously");
     return (1);
@@ -190,47 +196,32 @@ if2_main (int argc, char *const argv[])
     pim_out = new ImageFile (im_in1.nx(), im_in1.ny());
     vout = pim_out->getArray();
   }
-
+  
   std::string strOperation;
   int nx = im_in1.nx();
   int ny = im_in1.ny();
   int nx2 = im_in2.nx();
   int ny2 = im_in2.ny();
-
+  
   if (opt_add) {
     strOperation = "Add Images";
-    for (int ix = 0; ix < nx; ix++) {
-      ImageFileColumn in1 = v1[ix];
-      ImageFileColumn in2 = v2[ix];
-      ImageFileColumn out = vout[ix];
-      for (int iy = 0; iy < ny; iy++)
-       *out++ = *in1++ + *in2++;
-    }
+    im_in1.addImages (im_in2, *pim_out);\r
   } else if (opt_sub) {
-    strOperation = "Subtract Images";
-    for (int ix = 0; ix < nx; ix++) {
-      ImageFileColumn in1 = v1[ix];
-      ImageFileColumn in2 = v2[ix];
-      ImageFileColumn out = vout[ix];
-      for (int iy = 0; iy < ny; iy++)
-         *out++ = *in1++ - *in2++;
-    }
-  } else if (opt_mul) {
-    strOperation = "Multiply Images";
-    for (int ix = 0; ix < nx; ix++) {
-      ImageFileColumn in1 = v1[ix];
-      ImageFileColumn in2 = v2[ix];
-      ImageFileColumn out = vout[ix];
-      for (int iy = 0; iy < ny; iy++)
-       *out++ = *in1++ * *in2++;
-    }
-  }
+    strOperation = "Subtract Images";\r
+    im_in1.subtractImages (im_in2, *pim_out);\r
+  } else if (opt_mul) {\r
+    strOperation = "Multiply Images";\r
+    im_in1.multiplyImages (im_in2, *pim_out);\r
+  } else if (opt_divide) {\r
+    strOperation = "Divide Images";\r
+    im_in1.divideImages (im_in2, *pim_out);\r
+  }\r
   if (opt_comp) {
     double d, r, e;
     im_in1.comparativeStatistics (im_in2, d, r, e);
     std::cout << "d=" << d << ", r=" << r << ", e=" << e << std::endl;
   }
-\r
+  \r
   int i;
   if (opt_columnPlot > 0) {
     if (opt_columnPlot >= nx || opt_columnPlot >= nx2) {
@@ -240,18 +231,18 @@ if2_main (int argc, char *const argv[])
     double* plot_xaxis = new double [nx];
     for (i = 0; i < nx; i++)
       plot_xaxis[i] = i;
-\r
+    \r
     PlotFile plotFile (3, nx);\r
-\r
+    \r
     plotFile.addColumn (0, plot_xaxis);\r
     plotFile.addColumn (1, v1[opt_columnPlot]);\r
     plotFile.addColumn (2, v2[opt_columnPlot]);\r
     plotFile.setTitle ("Column Plot");\r
     plotFile.setXLabel ("Column");\r
     plotFile.setYLabel ("Pixel Value");\r
-\r
+    \r
     plotFile.fileWrite (strOutFile.c_str());\r
-\r
+    \r
 #if HAVE_SGP
     SGPDriver driver ("Column Plot");
     SGP sgp (driver);
@@ -271,7 +262,7 @@ if2_main (int argc, char *const argv[])
 #endif
     delete plot_xaxis;
   }
-
+  
   if (opt_rowPlot > 0) {
     if (opt_rowPlot >= ny || opt_rowPlot >= ny2) {
       sys_error (ERR_SEVERE, "row_plot > ny");
@@ -279,26 +270,26 @@ if2_main (int argc, char *const argv[])
     }
     double* plot_xaxis = new double [ny];
     double* v1Row = new double [ny];\r
-       double* v2Row = new double [ny2];
-
+    double* v2Row = new double [ny2];
+    
     for (i = 0; i < ny; i++)
       plot_xaxis[i] = i;
     for (i = 0; i < ny; i++)
       v1Row[i] = v1[i][opt_rowPlot];
     for (i = 0; i < ny2; i++)
       v2Row[i] = v2[i][opt_rowPlot];
-
+    
     PlotFile plotFile (3, ny);
-
+    
     plotFile.addColumn (0, plot_xaxis);
     plotFile.addColumn (1, v1Row);
     plotFile.addColumn (2, v2Row);
     plotFile.setTitle ("Row Plot");
     plotFile.setXLabel ("Row");
     plotFile.setYLabel ("Pixel Value");
-
+    
     plotFile.fileWrite (strOutFile.c_str());
-
+    
 #if HAVE_SGP
     SGPDriver driver ("Row Plot");
     SGP sgp (driver);
@@ -316,18 +307,18 @@ if2_main (int argc, char *const argv[])
     std::cout << "Press enter to continue" << flush;
     cio_kb_getc();
 #endif
-       delete plot_xaxis;\r
-       delete v1Row;\r
-       delete v2Row;\r
+    delete plot_xaxis;\r
+    delete v1Row;\r
+    delete v2Row;\r
   }
-
+  
   if (opt_bImageOutputFile) {
     pim_out->labelsCopy (im_in1, "if2 file 1: ");
     pim_out->labelsCopy (im_in2, "if2 file 2: ");
     pim_out->labelAdd (Array2dFileLabel::L_HISTORY, strOperation.c_str(), timerProgram.timerEnd());
     pim_out->fileWrite (strOutFile);
   }
-\r
+  \r
   return (0);
 }
 
@@ -336,7 +327,7 @@ int
 main (int argc, char *const argv[])
 {
   int retval = 1;
-
+  
   try {
     retval = if2_main(argc, argv);
   } catch (exception e) {
@@ -344,7 +335,7 @@ main (int argc, char *const argv[])
   } catch (...) {
     std::cerr << "Unknown exception\n";
   }
-
+  
   return (retval);
 }
 #endif