]> Creatis software - clitk.git/blobdiff - tools/clitkGammaIndex.cxx
Add 2 options to clitkImage2Dicom
[clitk.git] / tools / clitkGammaIndex.cxx
index be0f8072218330f4b82a99ddc7c1b7f50419698e..1f5fd03f3a78c905ecd666dc2376569b674e9fa3 100644 (file)
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================*/
+
+#include "clitkGammaIndex_ggo.h"
+#include "clitkIO.h"
+#include "clitkDD.h"
+
+#include <iostream>
+#include <cmath>
+#include <cassert>
+
 #include <vtkPoints.h>
 #include <vtkCellArray.h>
 #include <vtkPointData.h>
 #include <vtkPNGReader.h>
 #include <vtkPolyData.h>
 #include <vtkCellLocator.h>
-#include <iostream>
-#include <cmath>
-#include <cassert>
-using std::endl;
-using std::cout;
-
-#include "clitkGammaIndex_ggo.h"
 
-#include <clitkIO.h>
 #include <vvImage.h>
 #include <vvImageReader.h>
 #include <vvImageWriter.h>
@@ -42,6 +43,9 @@ using std::cout;
 typedef itk::Image<double> OutputImageType;
 typedef itk::ImageRegionIterator<OutputImageType> OutputImageIterator;
 
+using std::endl;
+using std::cout;
+
 vtkImageData* loadImage(const std::string& filename)
 {
     vvImageReader::Pointer reader = vvImageReader::New();
@@ -225,6 +229,17 @@ int main(int argc,char * argv[])
     vtkImageData* reference = loadImage(reference_filename);
     assert(reference);
 
+    // translate target with arguments values
+    // reference is translated instead of target so that the output space stay the same as target
+    {
+       double reference_origin[3];
+        reference->GetOrigin(reference_origin);
+       reference_origin[0] -= args_info.translation_x_arg;
+       reference_origin[1] -= args_info.translation_y_arg;
+       reference_origin[2] -= args_info.translation_z_arg;
+       reference->SetOrigin(reference_origin);
+    }
+
     // intensity normalisation
     if (!use_dose_margin) {
        dose_margin = getMaximum(reference)*dose_rel_margin;
@@ -237,15 +252,19 @@ int main(int argc,char * argv[])
 
     vtkAbstractCellLocator *locator = vtkCellLocator::New();
     locator->SetDataSet(data);
-    data->Delete();
+    DD("here");
+    //    data->Delete();
     locator->CacheCellBoundsOn();
     locator->AutomaticOn();
+    DD("BuildLocator");
     locator->BuildLocator();
+    DD("end BuildLocator");
 
     // load target
     vtkImageData* target = loadImage(target_filename);
     assert(target);
 
+
     // allocate output
     OutputImageType::Pointer output = OutputImageType::New();
     {
@@ -265,6 +284,7 @@ int main(int argc,char * argv[])
     unsigned long over_one = 0;
     OutputImageIterator iter(output,output->GetLargestPossibleRegion());
     iter.GoToBegin();
+    DD("loop");
     while (!iter.IsAtEnd()) {
        double *point = target->GetPoint(kk);
        double value = target->GetPointData()->GetScalars()->GetTuple1(kk);
@@ -303,4 +323,3 @@ int main(int argc,char * argv[])
 
     return 0;
 }
-