]> Creatis software - clitk.git/commitdiff
remove debug, new orientation option
authordsarrut <dsarrut>
Wed, 15 Dec 2010 08:50:00 +0000 (08:50 +0000)
committerdsarrut <dsarrut>
Wed, 15 Dec 2010 08:50:00 +0000 (08:50 +0000)
itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx

index 64172228925a692155d549e9237c61311b7f3833..3a82ee22f9f379955874b42c8677c51a013ed527 100644 (file)
@@ -23,7 +23,7 @@
 #include "clitkFilterBase.h"
 
 // itk
-#include "itkPasteImageFilter.h"
+#include <itkPasteImageFilter.h>
 
 // itk ENST
 #include "RelativePositionPropImageFilter.h"
@@ -90,6 +90,8 @@ namespace clitk {
     // Options
     void SetOrientationType(OrientationTypeEnumeration orientation);
     itkGetConstMacro(OrientationType, OrientationTypeEnumeration);
+    void SetOrientationTypeString(std::string s);
+    itkGetConstMacro(OrientationTypeString, std::string);
 
     void SetAngle1(double a);
     void SetAngle2(double a);
@@ -112,15 +114,20 @@ namespace clitk {
     itkGetConstMacro(ObjectBackgroundValue, PixelType);
     itkSetMacro(ObjectBackgroundValue, PixelType);
 
-    itkGetConstMacro(AutoCrop, bool);
-    itkSetMacro(AutoCrop, bool);
-    itkBooleanMacro(AutoCrop);
+    itkGetConstMacro(AutoCropFlag, bool);
+    itkSetMacro(AutoCropFlag, bool);
+    itkBooleanMacro(AutoCropFlag);
+
+    itkGetConstMacro(NotFlag, bool);
+    itkSetMacro(NotFlag, bool);
+    itkBooleanMacro(NotFlag);
 
   protected:
     AddRelativePositionConstraintToLabelImageFilter();
     virtual ~AddRelativePositionConstraintToLabelImageFilter() {}
     
     OrientationTypeEnumeration m_OrientationType;
+    std::string m_OrientationTypeString;
     double m_IntermediateSpacing;
     double m_FuzzyThreshold;
     PixelType m_BackgroundValue;
@@ -128,7 +135,8 @@ namespace clitk {
     double m_Angle1;
     double m_Angle2;
     bool m_ResampleBeforeRelativePositionFilter;
-    bool m_AutoCrop;
+    bool m_AutoCropFlag;
+    bool m_NotFlag;
 
     virtual void GenerateOutputInformation();
     virtual void GenerateInputRequestedRegion();
index 1e06168877a91929bf2ed06444e4e4da9d06735e..83993831fa4f2f86606b89025378ea27b1bed884 100644 (file)
@@ -49,7 +49,8 @@ AddRelativePositionConstraintToLabelImageFilter():
   SetOrientationType(LeftTo);
   ResampleBeforeRelativePositionFilterOn();
   SetIntermediateSpacing(10);
-  AutoCropOn();
+  AutoCropFlagOn();
+  NotFlagOff();
 }
 //--------------------------------------------------------------------
 
@@ -78,6 +79,23 @@ SetInputObject(const ImageType * image)
 //--------------------------------------------------------------------
   
 
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
+SetOrientationTypeString(std::string t) 
+{
+  SetOrientationType(Angle);
+  if (t[0] == 'L') SetOrientationType(LeftTo);
+  if (t[0] == 'R') SetOrientationType(RightTo);
+  if (t[0] == 'A') SetOrientationType(AntTo);
+  if (t[0] == 'P') SetOrientationType(PostTo);
+  if (t[0] == 'S') SetOrientationType(SupTo);
+  if (t[0] == 'I') SetOrientationType(InfTo);
+}
+//--------------------------------------------------------------------
+  
+
 //--------------------------------------------------------------------
 template <class ImageType>
 void 
@@ -166,6 +184,18 @@ void
 clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType>::
 GenerateData() 
 {
+  // Print Option
+  /*
+    DD(GetFuzzyThreshold());
+    DD((int)GetBackgroundValue());
+    DD((int)GetObjectBackgroundValue());
+    DD(GetOrientationType());
+    DD(GetResampleBeforeRelativePositionFilter());
+    DD(GetIntermediateSpacing());
+    DD(GetAutoCropFlag());
+    DD(GetNotFlag());
+  */
+
   // Get input pointer
   input = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
   object = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(1));
@@ -308,12 +338,15 @@ GenerateData()
     // resampleFilter->SetVerboseOptions(true);
     resampleFilter->Update();
     working_image = resampleFilter->GetOutput();
-  StopCurrentStep<ImageType>(working_image);
+    StopCurrentStep<ImageType>(working_image);
   }
 
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------
   // Pre Step 6: pad if not the same size : it can occur when downsample and upsample
+  // DD(working_image->GetLargestPossibleRegion());
+  // DD(input->GetLargestPossibleRegion());
+  //if (!HaveSameSizeAndSpacing(working_image, input)) {
   if (working_image->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) {
     StartNewStep("Pad to get the same size than input");
     typename ImageType::Pointer temp = ImageType::New();
@@ -324,6 +357,7 @@ GenerateData()
     typename PadFilterType::Pointer padFilter2 = PadFilterType::New();
     padFilter2->SetSourceImage(working_image);
     padFilter2->SetDestinationImage(temp);
+    // DD(input->GetLargestPossibleRegion().GetIndex());
     padFilter2->SetDestinationIndex(input->GetLargestPossibleRegion().GetIndex());
     padFilter2->SetSourceRegion(working_image->GetLargestPossibleRegion());
     padFilter2->Update();
@@ -346,11 +380,14 @@ GenerateData()
   combineFilter->SetForegroundValue(m_BackgroundValue+1);
   combineFilter->SetInput1(input);
   combineFilter->SetInput2(working_image);
-  combineFilter->SetOperationType(BoolFilterType::And);
+  if (GetNotFlag())
+    combineFilter->SetOperationType(BoolFilterType::AndNot);
+  else
+    combineFilter->SetOperationType(BoolFilterType::And);
   combineFilter->InPlaceOn();
   combineFilter->Update(); 
   working_image = combineFilter->GetOutput();
+
   combineFilter = BoolFilterType::New();
   combineFilter->SetInput1(working_image);
   combineFilter->SetInput2(object);
@@ -364,7 +401,7 @@ GenerateData()
   //--------------------------------------------------------------------
   //--------------------------------------------------------------------
   // Step 7: autocrop
-  if (GetAutoCrop()) {
+  if (GetAutoCropFlag()) {
     StartNewStep("Final AutoCrop");
     typedef clitk::AutoCropFilter<ImageType> CropFilterType;
     typename CropFilterType::Pointer cropFilter = CropFilterType::New();
@@ -380,6 +417,7 @@ GenerateData()
   
   // Final Step -> set output
   this->SetNthOutput(0, working_image);
+  //  this->GraftOutput(working_image);
   return;
 }
 //--------------------------------------------------------------------