]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 21 Feb 2012 14:36:40 +0000 (15:36 +0100)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 21 Feb 2012 14:36:40 +0000 (15:36 +0100)
common/vvImageReader.txx
itk/itkFlexibleBinaryFunctorImageFilter.h
itk/itkFlexibleBinaryFunctorImageFilter.txx
itk/itkFlexibleVectorCastImageFilter.h [new file with mode: 0644]

index e15e6d7688ff4a6a202e8f9e62bd42d133128ca5..6a4333ff3c59c055c704117954747e7f656a133b 100644 (file)
@@ -24,7 +24,7 @@
 #include <itkImageSeriesReader.h>
 #include <itkImageToVTKImageFilter.h>
 #include <itkAnalyzeImageIO.h>
-#include <itkVectorCastImageFilter.h>
+#include <itkFlexibleVectorCastImageFilter.h>
 
 #include <vtkTransform.h>
 
@@ -36,7 +36,12 @@ template<unsigned int VImageDimension>
 void vvImageReader::UpdateWithDim(std::string InputPixelType)
 {
   if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME)
-    UpdateWithDimAndInputVectorPixelType<itk::Vector<float,VImageDimension>,VImageDimension>();
+  {
+    if (VImageDimension == 4)
+      UpdateWithDimAndInputVectorPixelType<itk::Vector<float,3>,VImageDimension>();
+    else
+      UpdateWithDimAndInputVectorPixelType<itk::Vector<float,VImageDimension>,VImageDimension>();
+  }
   else if (InputPixelType == "short")
     UpdateWithDimAndInputPixelType<short,VImageDimension>();
   else if (InputPixelType == "unsigned_short")
@@ -235,14 +240,15 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType()
     }
     analyzeImageIO = dynamic_cast<itk::AnalyzeImageIO*>( reader->GetImageIO() );
   }
-
+  
   typedef itk::Image< itk::Vector<float , 3>, VImageDimension > VectorImageType;
-  typedef itk::VectorCastImageFilter<InputImageType, VectorImageType> CasterType;
+  typedef itk::FlexibleVectorCastImageFilter<InputImageType, VectorImageType> CasterType;
   typename VectorImageType::Pointer casted_input;
   typename CasterType::Pointer caster = CasterType::New();
   caster->SetInput(input);
+  caster->Update();
   casted_input = caster->GetOutput();
-
+  
   mImage = vvImageFromITK<VImageDimension, itk::Vector<float, 3> >(casted_input, mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME);
 
   // For unknown analyze orientations, we set identity
index c51ab0ce652d31c1d8be969af6449789f7c8303c..18062a2296302fbebc2f922cbc65e920e652d1bc 100644 (file)
@@ -145,8 +145,13 @@ protected:
    *
    * \sa ImageToImageFilter::ThreadedGenerateData(),
    *     ImageToImageFilter::GenerateData()  */
+#if ITK_VERSION_MAJOR >= 4  
+  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
+                            itk::ThreadIdType threadId );
+#else
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
                             int threadId );
+#endif
 
 private:
   FlexibleBinaryFunctorImageFilter(const Self&); //purposely not implemented
index 09147878ce69130bfeb093a81d06e5f2103a5d34..f8c7a753a1eeb0572975c7bb85ae493112b598ad 100644 (file)
@@ -98,7 +98,11 @@ template <class TInputImage1, class TInputImage2, class TOutputImage, class TFun
 void
 FlexibleBinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction>
 ::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread,
+#if ITK_VERSION_MAJOR >= 4  
+                        itk::ThreadIdType threadId )
+#else
                         int threadId)
+#endif
 {
   const unsigned int dim = Input1ImageType::ImageDimension;
   
diff --git a/itk/itkFlexibleVectorCastImageFilter.h b/itk/itkFlexibleVectorCastImageFilter.h
new file mode 100644 (file)
index 0000000..1e73a92
--- /dev/null
@@ -0,0 +1,113 @@
+/*=========================================================================
+
+  Program:   Insight Segmentation & Registration Toolkit
+  Module:    $RCSfile: itkFlexibleVectorCastImageFilter.h,v $
+  Language:  C++
+  Date:      $Date: 2008-10-17 16:30:53 $
+  Version:   $Revision: 1.16 $
+
+  Copyright (c) Insight Software Consortium. All rights reserved.
+  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef __itkFlexibleVectorCastImageFilter_h
+#define __itkFlexibleVectorCastImageFilter_h
+
+#include "itkUnaryFunctorImageFilter.h"
+#include "itkNumericTraitsFixedArrayPixel.h"
+
+namespace itk
+{
+  
+/** \class FlexibleVectorCastImageFilter
+ *
+ * \brief Casts input vector pixels to output vector pixel type.
+ *
+ * This filter is templated over the input image type and 
+ * output image type.
+ * 
+ * The filter expect both images to have the same number of dimensions,
+ * and that both the input and output have itk::Vector pixel types
+ * of the same VectorDimension.
+ *
+ * \sa Vector
+ *
+ * \ingroup IntensityImageFilters  Multithreaded
+ */
+namespace Functor {  
+  
+template< class TInput, class TOutput>
+class FlexibleVectorCast
+{
+public:
+  FlexibleVectorCast() {}
+  ~FlexibleVectorCast() {}
+  bool operator!=( const FlexibleVectorCast & ) const
+    {
+    return false;
+    }
+  bool operator==( const FlexibleVectorCast & other ) const
+    {
+    return !(*this != other);
+    }
+  inline TOutput operator()( const TInput & A ) const
+    {
+    typedef typename TOutput::ValueType OutputValueType;
+
+    TOutput value;
+    unsigned int k;
+    for( k = 0; k < TOutput::Dimension && k < TInput::Dimension; k++ )
+      {
+      value[k] = static_cast<OutputValueType>( A[k] );
+      }
+      
+    for (; k < TOutput::Dimension; k++)
+      value[k] = 0;
+    
+    return value;
+    }
+}; 
+}
+
+template <class TInputImage, class TOutputImage = itk::Vector<float, 3> >
+class ITK_EXPORT FlexibleVectorCastImageFilter :
+    public
+UnaryFunctorImageFilter<TInputImage,TOutputImage, 
+                        Functor::FlexibleVectorCast< typename TInputImage::PixelType, 
+                                             typename TOutputImage::PixelType>   >
+{
+public:
+  /** Standard class typedefs. */
+  typedef FlexibleVectorCastImageFilter                               Self;
+  typedef UnaryFunctorImageFilter<
+    TInputImage,TOutputImage, 
+    Functor::FlexibleVectorCast< typename TInputImage::PixelType, 
+                         typename TOutputImage::PixelType> >  Superclass;
+  typedef SmartPointer<Self>                                  Pointer;
+  typedef SmartPointer<const Self>                            ConstPointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Runtime information support. */
+  itkTypeMacro(FlexibleVectorCastImageFilter, 
+               UnaryFunctorImageFilter);
+
+protected:
+  FlexibleVectorCastImageFilter() {}
+  virtual ~FlexibleVectorCastImageFilter() {}
+
+private:
+  FlexibleVectorCastImageFilter(const Self&); //purposely not implemented
+  void operator=(const Self&); //purposely not implemented
+
+};
+
+} // end namespace itk
+
+
+#endif