]> Creatis software - clitk.git/commitdiff
Added clitkSum to take the sum in one direction, corrected clitkFooImage
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Mon, 7 Dec 2015 12:07:19 +0000 (13:07 +0100)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Mon, 7 Dec 2015 12:07:19 +0000 (13:07 +0100)
and removed it from compilation

tools/CMakeLists.txt
tools/clitkFooImage.cxx
tools/clitkFooImage.ggo
tools/clitkFooImageGenericFilter.h
tools/clitkFooImageGenericFilter.txx
tools/clitkSum.cxx [new file with mode: 0644]
tools/clitkSum.ggo [new file with mode: 0644]
tools/clitkSumGenericFilter.h [new file with mode: 0644]
tools/clitkSumGenericFilter.txx [new file with mode: 0644]

index 6bd72a3e62b55397fbaa4fb98de1aa2ce9e9a0a2..3bf89482b7c98064a3fc9a5ba1f975f2009f7806 100644 (file)
@@ -153,11 +153,6 @@ if(CLITK_BUILD_TOOLS)
   target_link_libraries(clitkUnsharpMask clitkCommon )
   set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkUnsharpMask)
 
-  WRAP_GGO(clitkFooImage_GGO_C clitkFooImage.ggo)
-  add_executable(clitkFooImage clitkFooImage.cxx ${clitkFooImage_GGO_C})
-  target_link_libraries(clitkFooImage clitkCommon )
-  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkFooImage)
-
   WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
   add_executable(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
   target_link_libraries(clitkMedianImageFilter clitkMedianImageFilterLib clitkCommon)
@@ -251,6 +246,11 @@ if(CLITK_BUILD_TOOLS)
   target_link_libraries(clitkMIP clitkMIPLib clitkCommon)
   set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMIP)
 
+  WRAP_GGO(clitkSum_GGO_C clitkSum.ggo)
+  add_executable(clitkSum clitkSum.cxx ${clitkSum_GGO_C})
+  target_link_libraries(clitkSum clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSum)
+
   WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo)
   add_executable(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C})
   target_link_libraries(clitkTransformLandmarks clitkCommon)
index 51d00ba4814f84d10e4d5dcef4d218db4be12573..046f6aab8b3b1e536f9acb20c46aad6b3b36b9ad 100644 (file)
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
 
-/* =================================================
- * @file   clitkFooImageGenericFilter.txx
- * @author xxx <xxx@creatis.insa-lyon.fr>
- * @date   29 June 2029
- *
- * @brief FooImage an image
- *
- ===================================================*/
-
 // clitk
 #include "clitkFooImage_ggo.h"
 #include "clitkFooImageGenericFilter.h"
index 3d0c8dbf97d92ef173713193fba0761dcbf7a9a5..d85977318e339b55a582840972986bf8c0bda215 100644 (file)
@@ -10,9 +10,4 @@ option "imagetypes"   -       "Display allowed image types"     flag          off
 
 option "input"         i       "Input image filename"            string        required
 option "output"        o       "Output image filename"           string        required
-option "lower"         l       "Lower intensity (default=min), fg is greater than this value"    double        optional
-option "upper"         u       "Upper intensity (default=max), fg is lower than this value"      double        optional
 
-option "fg"                    -       "Foreground (FG) or 'inside' value"               double        optional        default="1"
-option "bg"                    -       "Background (BG) or 'ouside' value"               double        optional        default="0"
-option "mode"          -       "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both"  default="both" optional
index e230f91b47f793e2549b44a7dd3d037fb9529c56..7578411864512546a8d46e2840a377154a037590 100644 (file)
@@ -15,8 +15,8 @@
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
-#ifndef CLITKFooIMAGEGENERICFILTER_H
-#define CLITKFooIMAGEGENERICFILTER_H
+#ifndef clitkFooImageGenericFilter_h
+#define clitkFooImageGenericFilter_h
 #include "clitkIO.h"
 #include "clitkImageToImageGenericFilter.h"
 
index 88473a02a0f65e3b234d0eb24c0384912ad9ff90..1724454b17a10776e711227679ed46c999f17f27 100644 (file)
 #ifndef clitkFooImageGenericFilter_txx
 #define clitkFooImageGenericFilter_txx
 
-/* =================================================
- * @file   clitkFooImageGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date   29 june 2009
- *
- * @brief
- *
- ===================================================*/
-
 // itk include
 #include "itkBinaryThresholdImageFilter.h"
 #include "itkMaskImageFilter.h"
@@ -95,40 +86,11 @@ FooImageGenericFilter<args_info_type>::UpdateWithInputImageType()
   typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
   typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
   thresholdFilter->SetInput(input);
-  thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
-
-  if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
-  if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
-
-  if (mArgsInfo.mode_arg == std::string("both")) {
-    thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
-    thresholdFilter->Update();
-
-    typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
-    this->template SetNextOutput<OutputImageType>(outputImage);
-  } else {
-    typename InputImageType::Pointer outputImage;
-    thresholdFilter->SetOutsideValue(0);
-    if (mArgsInfo.mode_arg == std::string("BG")) {
-      typedef itk::MaskImageFilter<InputImageType,OutputImageType> maskFilterType;
-      typename maskFilterType::Pointer maskFilter = maskFilterType::New();
-      maskFilter->SetInput1(input);
-      maskFilter->SetInput2(thresholdFilter->GetOutput());
-      maskFilter->SetOutsideValue(mArgsInfo.bg_arg);
-      maskFilter->Update();
-      outputImage = maskFilter->GetOutput();
-    } else {
-      typedef itk::MaskNegatedImageFilter<InputImageType,OutputImageType> maskFilterType;
-      typename maskFilterType::Pointer maskFilter = maskFilterType::New();
-      maskFilter->SetInput1(input);
-      maskFilter->SetInput2(thresholdFilter->GetOutput());
-      maskFilter->SetOutsideValue(mArgsInfo.fg_arg);
-      maskFilter->Update();
-      outputImage = maskFilter->GetOutput();
-    }
-    // Write/Save results
-    this->template SetNextOutput<InputImageType>(outputImage);
-  }
+  // Set filter members
+
+  // Write/Save results
+  typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+  this->template SetNextOutput<OutputImageType>(outputImage);
 }
 //--------------------------------------------------------------------
 
diff --git a/tools/clitkSum.cxx b/tools/clitkSum.cxx
new file mode 100644 (file)
index 0000000..6a4e185
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+// clitk
+#include "clitkSum_ggo.h"
+#include "clitkSumGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkSum, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::SumGenericFilter<args_info_clitkSum> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  try {
+    filter->Update();
+  } catch(std::runtime_error e) {
+    std::cout << e.what() << std::endl;
+  }
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkSum.ggo b/tools/clitkSum.ggo
new file mode 100644 (file)
index 0000000..e9938f2
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkSum.ggo
+package "clitkSum"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+option "dimension"     d       "Dimension along which to sum"    int           yes
diff --git a/tools/clitkSumGenericFilter.h b/tools/clitkSumGenericFilter.h
new file mode 100644 (file)
index 0000000..acebb90
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkSumGenericFilter_h
+#define clitkSumGenericFilter_h
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT SumGenericFilter:
+        public ImageToImageGenericFilter<SumGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    SumGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef SumGenericFilter                   Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(SumGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkSumGenericFilter.txx"
+#endif
+
+#endif // #define clitkSumGenericFilter_h
diff --git a/tools/clitkSumGenericFilter.txx b/tools/clitkSumGenericFilter.txx
new file mode 100644 (file)
index 0000000..f7fb5f0
--- /dev/null
@@ -0,0 +1,97 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkSumGenericFilter_txx
+#define clitkSumGenericFilter_txx
+
+// itk include
+#include <itkSumProjectionImageFilter.h>
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+SumGenericFilter<args_info_type>::SumGenericFilter():
+  ImageToImageGenericFilter<Self>("Sum")
+{
+  InitializeImageType<3>();
+  InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void SumGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void SumGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  this->SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input_given) {
+    this->SetInputFilename(mArgsInfo.input_arg);
+  }
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+  }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+SumGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+  // Reading input
+  typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+  // Main filter
+  typedef typename InputImageType::PixelType PixelType;
+  const int Dim = InputImageType::ImageDimension;
+  typedef itk::Image<PixelType,Dim> ImageType;
+  typedef itk::Image<PixelType,Dim-1> OutputImageType;
+
+  // Filter
+  typedef itk::SumProjectionImageFilter<ImageType,OutputImageType> FilterType;
+  typename FilterType::Pointer filter = FilterType::New();
+  filter->SetProjectionDimension(mArgsInfo.dimension_arg);
+  filter->SetInput(input);
+  filter->Update();
+  this->template SetNextOutput<OutputImageType>(filter->GetOutput());
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkSumGenericFilter_txx