]> Creatis software - clitk.git/blobdiff - itk/clitkInvertVFFilter.txx
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / itk / clitkInvertVFFilter.txx
index 600775c04a1ef6c28f9442e0e1122b79e348f78e..b74958fb597a83dc9b3f559936973b340ee6874d 100644 (file)
@@ -17,6 +17,7 @@
 ===========================================================================**/
 #ifndef __clitkInvertVFFilter_txx
 #define __clitkInvertVFFilter_txx
+
 namespace
 {
 
@@ -74,7 +75,11 @@ protected:
 
   //the actual processing
   void BeforeThreadedGenerateData();
+#if ITK_VERSION_MAJOR >= 4
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
+#else
+  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
+#endif
 
   //member data
   typename  WeightsImageType::Pointer m_Weights;
@@ -103,6 +108,7 @@ HelperClass1<InputImageType, OutputImageType>::HelperClass1()
 template<class InputImageType, class OutputImageType >
 void HelperClass1<InputImageType, OutputImageType>::BeforeThreadedGenerateData()
 {
+  //std::cout << "HelperClass1::BeforeThreadedGenerateData - IN" << std::endl;
   //Since we will add, put to zero!
   this->GetOutput()->FillBuffer(itk::NumericTraits<double>::Zero);
   this->GetWeights()->FillBuffer(itk::NumericTraits<double>::Zero);
@@ -111,9 +117,13 @@ void HelperClass1<InputImageType, OutputImageType>::BeforeThreadedGenerateData()
 //=========================================================================================================================
 //update the output for the outputRegionForThread
 template<class InputImageType, class OutputImageType>
+#if ITK_VERSION_MAJOR >= 4
 void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId )
+#else
+void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
+#endif
 {
-
+  //std::cout << "HelperClass1::ThreadedGenerateData - IN" << std::endl;
   //Get pointer to the input
   typename InputImageType::ConstPointer inputPtr = this->GetInput();
 
@@ -129,7 +139,7 @@ void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const O
 
   //Initialize
   typename InputImageType::IndexType index;
-  itk::ContinuousIndex<double,ImageDimension> contIndex;
+  itk::ContinuousIndex<double,ImageDimension> contIndex, inContIndex;
   typename InputImageType::PointType ipoint;
   typename OutputImageType::PointType opoint;
   typedef typename OutputImageType::PixelType DisplacementType;
@@ -147,7 +157,7 @@ void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const O
   unsigned int neighbors =  1 << ImageDimension;
 
   //==================================================================================================
-  //Loop over the region and add the intensities to the output and the weight to the weights
+  //Loop over the output region and add the intensities from the input to the output and the weight to the weights
   //==================================================================================================
   while( !inputIt.IsAtEnd() ) {
     // get the input image index
@@ -233,6 +243,7 @@ void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const O
     ++inputIt;
   }
 
+  //std::cout << "HelperClass1::ThreadedGenerateData - OUT" << std::endl;
 }
 
 
@@ -282,8 +293,11 @@ protected:
 
 
   //the actual processing
+#if ITK_VERSION_MAJOR >= 4
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
-
+#else
+  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
+#endif
 
   //member data
   typename     WeightsImageType::Pointer m_Weights;
@@ -308,9 +322,14 @@ template<class InputImageType, class OutputImageType > HelperClass2<InputImageTy
 
 //=========================================================================================================================
 //update the output for the outputRegionForThread
+#if ITK_VERSION_MAJOR >= 4
 template<class InputImageType, class OutputImageType > void HelperClass2<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId )
+#else
+template<class InputImageType, class OutputImageType > void HelperClass2<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
+#endif
 {
-
+  //std::cout << "HelperClass2::ThreadedGenerateData - IN" << std::endl;
+  
   //Get pointer to the input
   typename InputImageType::ConstPointer inputPtr = this->GetInput();
 
@@ -360,6 +379,9 @@ template<class InputImageType, class OutputImageType > void HelperClass2<InputIm
     ++inputIt;
 
   }//end while
+  
+  //std::cout << "HelperClass2::ThreadedGenerateData - OUT" << std::endl;
+  
 }//end member
 
 
@@ -384,24 +406,19 @@ InvertVFFilter<InputImageType, OutputImageType>::InvertVFFilter()
   m_Verbose=false;
 }
 
-
 //=========================================================================================================================
 //Update
 template <class InputImageType, class OutputImageType> void InvertVFFilter<InputImageType, OutputImageType>::GenerateData()
 {
+  //std::cout << "InvertVFFilter::GenerateData - IN" << std::endl;
 
   //Get the properties of the input
   typename InputImageType::ConstPointer inputPtr=this->GetInput();
-  typename WeightsImageType::RegionType region;
-  typename WeightsImageType::RegionType::SizeType size=inputPtr->GetLargestPossibleRegion().GetSize();
-  region.SetSize(size);
-  typename OutputImageType::IndexType start;
-  for (unsigned int i=0; i< ImageDimension; i++) start[i]=0;
-  region.SetIndex(start);
-
+  typename WeightsImageType::RegionType region = inputPtr->GetLargestPossibleRegion();
 
   //Allocate the weights
   typename WeightsImageType::Pointer weights=WeightsImageType::New();
+  weights->SetOrigin(inputPtr->GetOrigin());
   weights->SetRegions(region);
   weights->Allocate();
   weights->SetSpacing(inputPtr->GetSpacing());