]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorDavid Sarrut <david.sarrut@gmail.com>
Tue, 15 Nov 2011 09:57:31 +0000 (10:57 +0100)
committerDavid Sarrut <david.sarrut@gmail.com>
Tue, 15 Nov 2011 09:57:31 +0000 (10:57 +0100)
12 files changed:
cmake/gengetopt/CMakeLists.txt
cmake/gengetopt/include_cygwin/getopt.h [deleted file]
itk/clitkRelativePositionDataBase.cxx
itk/clitkRelativePositionDataBase.h
itk/itkBSplineInterpolateImageFunctionWithLUT.h
tools/CMakeLists.txt
tools/clitkCatImage.cxx [new file with mode: 0644]
tools/clitkCatImage.ggo [new file with mode: 0644]
tools/clitkCatImageGenericFilter.h [new file with mode: 0644]
tools/clitkCatImageGenericFilter.txx [new file with mode: 0644]
tools/clitkGammaIndex.cxx
tools/clitkGammaIndex.ggo

index 84443f01b5c32ee8be307e5f2acf6ab06d361d76..2f586f93acc526a5f4d86233b0e4813876ab214a 100644 (file)
@@ -5,12 +5,18 @@ ADD_DEFINITIONS(-DVERSION=\"2.22.4\")
 ADD_DEFINITIONS(-DHAVE_SSTREAM)
 ADD_DEFINITIONS(-DHAVE_NAMESPACES)
 
-IF(WIN32)
+# Remove compiler warnings
+STRING(REPLACE "/W3" "/w" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+STRING(REPLACE "/W3" "/w" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+STRING(REPLACE "-Wall" "-w" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+STRING(REPLACE "-Wall" "-w" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+
+# MSVC specific issues
+IF(MSVC)
   ADD_DEFINITIONS(-DHAVE_STRING_H)
   ADD_DEFINITIONS(-DYY_NO_UNISTD_H)
   ADD_DEFINITIONS(-Disatty=!)
-  INCLUDE_DIRECTORIES(include_cygwin)
-ENDIF(WIN32)
+ENDIF(MSVC)
 
 ADD_EXECUTABLE(gengetopt 
   ./cmdline.c
diff --git a/cmake/gengetopt/include_cygwin/getopt.h b/cmake/gengetopt/include_cygwin/getopt.h
deleted file mode 100644 (file)
index 0c1c8c9..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994, 1996
- *  The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *  This product includes software developed by the University of
- *  California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifdef _COMPILING_NEWLIB
-#include_next "getopt.h"
-#else
-#ifndef __GETOPT_H__
-#define __GETOPT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __INSIDE_CYGWIN__
-extern int __declspec(dllimport) opterr;       /* if error message should be printed */
-extern int __declspec(dllimport) optind;       /* index into parent argv vector */
-extern int __declspec(dllimport) optopt;       /* character checked for validity */
-extern int __declspec(dllimport) optreset;     /* reset getopt */
-extern char __declspec(dllimport) *optarg;     /* argument associated with option */
-#endif
-
-int getopt (int, char * const *, const char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __GETOPT_H__ */
-
-#ifndef __UNISTD_GETOPT__
-#ifndef __GETOPT_LONG_H__
-#define __GETOPT_LONG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct option {
-       const char *name;
-       int  has_arg;
-       int *flag;
-       int val;
-};
-
-int getopt_long (int, char *const *, const char *, const struct option *, int *);
-int getopt_long_only (int, char *const *, const char *, const struct option *, int *);
-
-#ifndef HAVE_DECL_GETOPT
-#define HAVE_DECL_GETOPT 1
-#endif
-
-#define no_argument             0
-#define required_argument       1
-#define optional_argument       2
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __GETOPT_LONG_H__ */
-#endif /* __UNISTD_GETOPT__ */
-#endif /*_INSIDE_NEWLIB*/
index a9b73273387f9beafc94934425fc58649292500a..1512e4c9059cfa1c9466d308473960cdfb4214bf 100644 (file)
@@ -231,7 +231,14 @@ namespace clitk {
     return true;
   }
   //--------------------------------------------------------------------
-  
+
+  //--------------------------------------------------------------------
+  std::ostream& operator<<(std::ostream & os, const clitk::RelativePositionInformationType & rp)
+  {
+    rp.Print(os);
+    return os;
+  }
+  //--------------------------------------------------------------------
 
 } // end namespace clitk
 //--------------------------------------------------------------------
index 57cdcec3f2ea70c93f6c5814b7d176efddaf420a..fa83a3ea3b3fe8dd9c07db2eabd5ffca8f50a010 100644 (file)
@@ -109,6 +109,7 @@ namespace clitk {
       os << std::endl;
     }
   };
+  std::ostream& operator<<(std::ostream & os, const clitk::RelativePositionInformationType & rp);
   //--------------------------------------------------------------------
 
 
index 5903828d9b7e38885eec3203ed4080dbf4f231a5..7fd7ab81e0686efcb26a4035d487958eaebaed22 100644 (file)
@@ -61,6 +61,14 @@ namespace itk {
     /** Set the input image.  This must be set by the user. */
     virtual void SetInputImage(const TImageType * inputData);
     
+    /** Evaluate the function at a ContinuousIndex position.
+  Overwritten for taking LUT into account (RP: multi-threading-compatible version, 
+  the threadID is actually ignored) */  
+    virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index, unsigned int /* threadID */ ) const
+    {
+      return this->EvaluateAtContinuousIndex( index );
+    }
+
     /** Evaluate the function at a ContinuousIndex position.
        Overwritten for taking LUT into account */  
     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
index bd565421b4a05493b26ef8bcf3df9b1466c75b4b..e71e7829a0d765b0c572103acd8a2c47532c3c66 100644 (file)
@@ -321,7 +321,7 @@ IF (CLITK_BUILD_TOOLS)
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkLabelImageOverlapMeasure)
 
   WRAP_GGO(clitkRelativePositionAnalyzer_GGO_C clitkRelativePositionAnalyzer.ggo)
-  ADD_EXECUTABLE(clitkRelativePositionAnalyzer clitkRelativePositionAnalyzer.cxx ${clitkRelativePositionAnalyzer_GGO_C})
+  ADD_EXECUTABLE(clitkRelativePositionAnalyzer ../itk/clitkRelativePositionDataBase.cxx clitkRelativePositionAnalyzer.cxx ${clitkRelativePositionAnalyzer_GGO_C})
   TARGET_LINK_LIBRARIES(clitkRelativePositionAnalyzer clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePositionAnalyzer)
 
@@ -331,7 +331,7 @@ IF (CLITK_BUILD_TOOLS)
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePositionDataBaseAnalyzer)
 
   WRAP_GGO(clitkRelativePositionDataBaseBuilder_GGO_C clitkRelativePositionDataBaseBuilder.ggo)
-  ADD_EXECUTABLE(clitkRelativePositionDataBaseBuilder clitkRelativePositionDataBaseBuilder.cxx ${clitkRelativePositionDataBaseBuilder_GGO_C})
+  ADD_EXECUTABLE(clitkRelativePositionDataBaseBuilder ../itk/clitkRelativePositionDataBase.cxx clitkRelativePositionDataBaseBuilder.cxx ${clitkRelativePositionDataBaseBuilder_GGO_C})
   TARGET_LINK_LIBRARIES(clitkRelativePositionDataBaseBuilder clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkRelativePositionDataBaseBuilder)
 
@@ -359,6 +359,11 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkPadImage clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkPadImage)
 
+  WRAP_GGO(clitkCatImage_GGO_C clitkCatImage.ggo)
+  ADD_EXECUTABLE(clitkCatImage clitkCatImage.cxx ${clitkCatImage_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkCatImage clitkCommon ${ITK_LIBRARIES})
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkCatImage)
+
   IF(CLITK_EXPERIMENTAL)
 
     WRAP_GGO(clitkBinaryImageToMesh_GGO_C clitkBinaryImageToMesh.ggo)
diff --git a/tools/clitkCatImage.cxx b/tools/clitkCatImage.cxx
new file mode 100644 (file)
index 0000000..e16e61b
--- /dev/null
@@ -0,0 +1,42 @@
+/*=========================================================================
+  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 "clitkCatImage_ggo.h"
+#include "clitkCatImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkCatImage, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::CatImageGenericFilter<args_info_clitkCatImage> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  CLITK_TRY_CATCH_EXIT(filter->Update());
+
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkCatImage.ggo b/tools/clitkCatImage.ggo
new file mode 100644 (file)
index 0000000..deb0058
--- /dev/null
@@ -0,0 +1,14 @@
+#File clitkCatImage.ggo
+package "clitkCatImage"
+version "1.0"
+purpose "Concatenate two images along chosen direction"
+
+option "config"                -       "Config file"                         string  optional
+option "verbose"       v "Verbose"                               flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input1"                  i     "First input image filename"    string  required
+option "input2"                  j     "Second input image filename"   string  required
+option "output"        o "Output image filename"       string  required
+option "dimension"  d "Dimension on which to concatenate" int required
diff --git a/tools/clitkCatImageGenericFilter.h b/tools/clitkCatImageGenericFilter.h
new file mode 100644 (file)
index 0000000..bee6ebc
--- /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 CLITKCatImageGENERICFILTER_H
+#define CLITKCatImageGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT CatImageGenericFilter:
+        public ImageToImageGenericFilter<CatImageGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    CatImageGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef CatImageGenericFilter         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(CatImageGenericFilter, 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 "clitkCatImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkCatImageGenericFilter_h
diff --git a/tools/clitkCatImageGenericFilter.txx b/tools/clitkCatImageGenericFilter.txx
new file mode 100644 (file)
index 0000000..0355bff
--- /dev/null
@@ -0,0 +1,121 @@
+/*=========================================================================
+  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 clitkCatImageGenericFilter_txx
+#define clitkCatImageGenericFilter_txx
+
+#include <itkConstantPadImageFilter.h>
+#include <itkPasteImageFilter.h>
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+CatImageGenericFilter<args_info_type>::CatImageGenericFilter():
+  ImageToImageGenericFilter<Self>("CatImage")
+{
+  InitializeImageType<2>();
+  InitializeImageType<3>();
+  InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void CatImageGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+  ADD_VEC_IMAGE_TYPE(2,2,float);
+  ADD_VEC_IMAGE_TYPE(2,3,float);
+  ADD_VEC_IMAGE_TYPE(3,3,float);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void CatImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input1_given)
+    AddInputFilename(mArgsInfo.input1_arg);
+  if (mArgsInfo.input2_given)
+    AddInputFilename(mArgsInfo.input2_arg);
+  if (mArgsInfo.output_given)
+    SetOutputFilename(mArgsInfo.output_arg);
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+CatImageGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+  // Reading input 1
+  typename InputImageType::Pointer input1 = this->template GetInput<InputImageType>(0);
+  typename InputImageType::Pointer input2 = this->template GetInput<InputImageType>(1);
+
+  // Main filter
+  typedef typename InputImageType::PixelType PixelType;
+  typedef itk::Image<char, InputImageType::ImageDimension> OutputImageType;
+
+  typename InputImageType::RegionType region;
+  region = input2->GetLargestPossibleRegion();
+
+  // Filter
+  typename InputImageType::SizeType upperBound;
+  upperBound.Fill(0);
+  upperBound[mArgsInfo.dimension_arg] = region.GetSize()[mArgsInfo.dimension_arg];
+  typedef itk::ConstantPadImageFilter<InputImageType, InputImageType> PadImageFilterType;
+  typename PadImageFilterType::Pointer pad= PadImageFilterType::New();
+  pad->SetInput(input1);
+  pad->SetPadUpperBound(upperBound);
+
+  typename InputImageType::IndexType index;
+  index.Fill(0);
+  index[mArgsInfo.dimension_arg] = input1->GetLargestPossibleRegion().GetSize(mArgsInfo.dimension_arg);
+
+  typedef itk::PasteImageFilter<InputImageType, InputImageType, InputImageType> PasteImageFilterType;
+  typename PasteImageFilterType::Pointer pasteFilter=PasteImageFilterType::New();
+  pasteFilter->SetSourceImage(input2);
+  pasteFilter->SetDestinationImage(pad->GetOutput());
+  pasteFilter->SetDestinationIndex(index);
+  pasteFilter->SetSourceRegion(region);
+  pasteFilter->InPlaceOn();
+  pasteFilter->Update();
+
+  typename InputImageType::Pointer output = pasteFilter->GetOutput();
+
+  this->template SetNextOutput<InputImageType>(output);
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkCatImageGenericFilter_txx
index be0f8072218330f4b82a99ddc7c1b7f50419698e..7e5a92eba7cf32d67775e1910d596290c8f5eee9 100644 (file)
@@ -224,6 +224,17 @@ int main(int argc,char * argv[])
     // load reference
     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) {
@@ -246,6 +257,7 @@ int main(int argc,char * argv[])
     vtkImageData* target = loadImage(target_filename);
     assert(target);
 
+
     // allocate output
     OutputImageType::Pointer output = OutputImageType::New();
     {
index 20c87f97b31c0fa99f6f6455411e7c83f2404e86..b41ba75472dde24713cb1f5c5808d054db0e2ba3 100644 (file)
@@ -12,4 +12,7 @@ option "output"    o  "Output image filename"   string   yes
 option "spatial-margin"   s    "Spatial margin [mm]"     double   yes
 option "relative-dose-margin"   r      "Dose margin relative to max dose in reference [%]"       double   no
 option "absolute-dose-margin"   d      "Absolute dose margin [Gray]"     double   no
+option "translation-x"   x     "Target relative position x [mm]"         double   default="0" no
+option "translation-y"   y     "Target relative position y [mm]"         double   default="0" no
+option "translation-z"   z     "Target relative position z [mm]"         double   default="0" no