]> Creatis software - clitk.git/commitdiff
Resize fuzzymap is spacing enabled
authorDavid Sarrut <david.sarrut@gmail.com>
Tue, 20 Mar 2012 13:07:37 +0000 (14:07 +0100)
committerDavid Sarrut <david.sarrut@gmail.com>
Tue, 20 Mar 2012 13:07:37 +0000 (14:07 +0100)
itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx

index e151f6b682ab43d6be50f2ca20542ccc6076e5c5..99465547695d6403dea2c271e55ffba93da8c14b 100644 (file)
@@ -177,6 +177,7 @@ namespace clitk {
     virtual void GenerateData();
 
     typedef itk::PasteImageFilter<ImageType,ImageType> PasteFilterType;
+    typedef itk::PasteImageFilter<FloatImageType,FloatImageType> PasteFloatFilterType;
     typename ImageType::Pointer working_image;
     typename ImageType::Pointer object_resampled;
     typename FloatImageType::Pointer relPos;
index e27ce18c4ee215c4ba3c31dcf8522d94c6fe9ad2..6d536186fbf5084da969d0750e05a4cc8cd3c8fb 100644 (file)
@@ -432,7 +432,43 @@ GenerateData()
 
   relPos = m_FuzzyMap;
   StopCurrentStep<FloatImageType>(relPos);
-  if (GetFuzzyMapOnlyFlag()) return;
+  if (GetFuzzyMapOnlyFlag()) {
+    // If the spacing is used, recompute fuzzy map with the input size/spacing
+    if (m_IntermediateSpacingFlag) {
+      StartNewStep("Resample FuzzyMap to come back to the same sampling than input");
+      typedef clitk::ResampleImageWithOptionsFilter<FloatImageType> ResampleFilterType;
+      typename ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New();
+      resampleFilter->SetDefaultPixelValue(0.0); //Default fuzzymap value FIXME
+      resampleFilter->SetInput(relPos);
+      resampleFilter->SetOutputSpacing(input->GetSpacing());
+      resampleFilter->SetGaussianFilteringEnabled(false);
+      resampleFilter->Update();
+      relPos = m_FuzzyMap = resampleFilter->GetOutput();
+
+      // Need to put exactly the same size
+      if (relPos->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) {
+        StartNewStep("Pad to get the same size than input");
+        typename FloatImageType::Pointer temp = FloatImageType::New();
+        temp->CopyInformation(input);
+        temp->SetRegions(input->GetLargestPossibleRegion()); // Do not forget !!
+        temp->Allocate();
+        temp->FillBuffer(0.0); // Default fuzzymap value FIXME
+        typename PasteFloatFilterType::Pointer padFilter2 = PasteFloatFilterType::New();
+        padFilter2->SetSourceImage(relPos);
+        padFilter2->SetDestinationImage(temp);
+        padFilter2->SetDestinationIndex(input->GetLargestPossibleRegion().GetIndex());
+        padFilter2->SetSourceRegion(relPos->GetLargestPossibleRegion());
+        padFilter2->Update();
+        relPos = padFilter2->GetOutput();
+        StopCurrentStep<FloatImageType>(relPos);
+        m_FuzzyMap = relPos;
+      }     
+    }
+    else {
+      StopCurrentStep<FloatImageType>(relPos);
+    }
+    return;
+  }
                
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------