]> Creatis software - clitk.git/commitdiff
*** empty log message ***
authordsarrut <dsarrut>
Mon, 1 Feb 2010 15:53:41 +0000 (15:53 +0000)
committerdsarrut <dsarrut>
Mon, 1 Feb 2010 15:53:41 +0000 (15:53 +0000)
filters/clitkBinarizeImageGenericFilter.txx
tools/CMakeLists.txt
tools/clitkBinarizeImage.ggo [deleted file]
vv/vvToolBinarize.cxx

index a41f33a0b4609a586b6390acad6663f45aa8c41f..6b993e56ae97e7f73656a29e615823013150d847 100644 (file)
@@ -10,6 +10,8 @@
  * 
  ===================================================*/
 
+#include "itkMaskImageFilter.h"
+
 namespace clitk
 {
   
@@ -17,9 +19,9 @@ namespace clitk
   template<class args_info_type>
   BinarizeImageGenericFilter<args_info_type>::BinarizeImageGenericFilter():
     ImageToImageGenericFilter<Self>("Binarize") {
-    InitializeImageType<2>();
+    //    InitializeImageType<2>();
     InitializeImageType<3>();
-    InitializeImageType<4>();
+    //InitializeImageType<4>();
   }
   //--------------------------------------------------------------------
 
@@ -28,10 +30,10 @@ namespace clitk
   template<class args_info_type>
   template<unsigned int Dim>
   void BinarizeImageGenericFilter<args_info_type>::InitializeImageType() {      
-    ADD_IMAGE_TYPE(Dim, char);
+    //ADD_IMAGE_TYPE(Dim, char);
     ADD_IMAGE_TYPE(Dim, short);
-    ADD_IMAGE_TYPE(Dim, int);
-    ADD_IMAGE_TYPE(Dim, float);
+    //ADD_IMAGE_TYPE(Dim, int);
+    //ADD_IMAGE_TYPE(Dim, float);
   }
   //--------------------------------------------------------------------
   
@@ -73,6 +75,13 @@ namespace clitk
     typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
     typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
     thresholdFilter->SetInput(input);
+
+    if (mArgsInfo.setFG_flag) {
+      double fg = mArgsInfo.fg_arg;
+      mArgsInfo.fg_arg = mArgsInfo.bg_arg;
+      mArgsInfo.bg_arg = fg;
+    }
+
     if(mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
     if(mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
 
@@ -81,19 +90,37 @@ namespace clitk
     DD(mArgsInfo.lower_arg);
     DD(mArgsInfo.upper_arg);
 
-    DD(mArgsInfo.inside_arg);
-    DD(mArgsInfo.outside_arg);
-    DD(mArgsInfo.inside_given);
-    DD(mArgsInfo.outside_given);
+    DD(mArgsInfo.fg_arg);
+    DD(mArgsInfo.bg_arg);
+    DD(mArgsInfo.fg_given);
+    DD(mArgsInfo.bg_given);
 
-    thresholdFilter->SetInsideValue(mArgsInfo.inside_arg);
-    thresholdFilter->SetOutsideValue(mArgsInfo.outside_arg);
+    thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
+    thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
 
     thresholdFilter->Update();
-  
-    // Write/Save results
-    typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
-    this->template SetNextOutput<OutputImageType>(outputImage);
+
+    // If no BG or no FG : new image, copy input with MaskImageFilter
+    // If setFG -> FG BG have been changed
+    if (0) {
+      if (mArgsInfo.setBG_flag || mArgsInfo.setFG_flag) {
+        DD("set BG!!!!");
+        //if ()
+        typedef itk::MaskImageFilter<InputImageType,OutputImageType> maskFilterType;
+        typename maskFilterType::Pointer maskFilter = maskFilterType::New();
+        maskFilter->SetInput1(input);
+        maskFilter->SetInput2(thresholdFilter->GetOutput());
+        maskFilter->Update();
+        typename InputImageType::Pointer outputImage = maskFilter->GetOutput();
+        // Write/Save results
+        this->template SetNextOutput<InputImageType>(outputImage);
+      }
+    }
+    else {
+      typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+      // Write/Save results
+      this->template SetNextOutput<OutputImageType>(outputImage);
+    }
   }
   //--------------------------------------------------------------------
 
index ef6e50da8e5eb6ed75a7e9d7aa447f64d1ba16ab..c2ee433f42f98ad36c9946412b54d738afb0e024 100644 (file)
@@ -5,7 +5,7 @@ INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake)
 
 SET(clitkGGO_SRC
   clitkImageResample_ggo.c
-  clitkBinarizeImage_ggo.c
+  # ../filters/clitkBinarizeImage_ggo.c
   )  
 
 ADD_LIBRARY(clitkGGO STATIC ${clitkGGO_SRC})
@@ -84,5 +84,5 @@ ADD_EXECUTABLE(clitkGuerreroVentilation clitkGuerreroVentilation.cxx
 TARGET_LINK_LIBRARIES(clitkGuerreroVentilation clitkCommon ITKIO ITKBasicFilters
 clitkFilters)
 
-ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx clitkBinarizeImage_ggo.c)
+ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx)
 TARGET_LINK_LIBRARIES(clitkBinarizeImage ITKIO clitkCommon) 
diff --git a/tools/clitkBinarizeImage.ggo b/tools/clitkBinarizeImage.ggo
deleted file mode 100644 (file)
index c974fe4..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#File clitkBinarizeImage.ggo
-Package "clitkBinarizeImage"
-version "1.0"
-purpose ""
-
-option "config"                -       "Config file"                     string        no
-option "imagetypes"    -       "Verbose available image type"    flag          off
-option "verbose"       v       "Verbose"                         flag          off
-
-option "input"         i       "Input image filename"            string        yes
-option "output"        o       "Output image filename"           string        yes
-option "lower"         l       "Lower intensity (default=min)"   double        no
-option "upper"         u       "Upper intensity (default=max)"   double        no
-option "inside"        -       "Inside value"                    double        no      default="1"
-option "outside"       -       "Outside value"                   double        no      default="0"
index a7579d8895d601f5234f37ffc40da235cf23c1da..05af4958d9002f3d2ba3f78c034e65a0e38e6669 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBinarize.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/01/29 13:54:37 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/02/01 15:54:25 $
+  Version:   $Revision: 1.2 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -267,14 +267,16 @@ void vvToolBinarize::GetArgsInfoFromGUI() {
     }
   }
 
-  mArgsInfo.inside_arg = mFGSlider->GetValue();
-  mArgsInfo.outside_arg = mBGSlider->GetValue();
+  mArgsInfo.fg_arg = mFGSlider->GetValue();
+  mArgsInfo.bg_arg = mBGSlider->GetValue();
   if (inverseBGandFG) {
-    mArgsInfo.inside_arg = mBGSlider->GetValue();
-    mArgsInfo.outside_arg = mFGSlider->GetValue();
+    mArgsInfo.fg_arg = mBGSlider->GetValue();
+    mArgsInfo.bg_arg = mFGSlider->GetValue();
   }
-  mArgsInfo.inside_given = 1;
-  mArgsInfo.outside_given = 1;
+  mArgsInfo.fg_given = 1;
+  mArgsInfo.bg_given = 1;
+
+  mArgsInfo.setBG_flag = true;
 
   mArgsInfo.verbose_flag = true;