X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkInvertVFFilter.txx;h=e26fed7c77c6b7cac148e970adce1491587742bd;hb=b133f36e1414bcf74518050a4a8e36d32d642981;hp=0c443ca8e4812764371fda4520cb3f0cbe73b021;hpb=0793c4dd3d451bb9bdc00e3172fa792d1ddaa8dc;p=clitk.git diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index 0c443ca..e26fed7 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -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::HelperClass1() template void HelperClass1::BeforeThreadedGenerateData() { + //std::cout << "HelperClass1::BeforeThreadedGenerateData - IN" << std::endl; //Since we will add, put to zero! this->GetOutput()->FillBuffer(itk::NumericTraits::Zero); this->GetWeights()->FillBuffer(itk::NumericTraits::Zero); @@ -111,9 +117,13 @@ void HelperClass1::BeforeThreadedGenerateData() //========================================================================================================================= //update the output for the outputRegionForThread template +#if ITK_VERSION_MAJOR >= 4 +void HelperClass1::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) +#else void HelperClass1::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) +#endif { - +// std::cout << "HelperClass1::ThreadedGenerateData - IN " << threadId << std::endl; //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); @@ -129,13 +139,15 @@ void HelperClass1::ThreadedGenerateData(const O //Initialize typename InputImageType::IndexType index; - itk::ContinuousIndex contIndex; + itk::ContinuousIndex contIndex, inContIndex; typename InputImageType::PointType ipoint; typename OutputImageType::PointType opoint; typedef typename OutputImageType::PixelType DisplacementType; DisplacementType displacement; inputIt.GoToBegin(); + typename OutputImageType::SizeType size = outputPtr->GetLargestPossibleRegion().GetSize(); + //define some temp variables signed long baseIndex[ImageDimension]; double distance[ImageDimension]; @@ -147,7 +159,7 @@ void HelperClass1::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 @@ -187,8 +199,10 @@ void HelperClass1::ThreadedGenerateData(const O overlap *= 1.0 - distance[dim]; } upper >>= 1; - } + if (neighIndex[dim] >= size[dim]) + neighIndex[dim] = size[dim] - 1; + } //Set neighbor value only if overlap is not zero @@ -233,6 +247,7 @@ void HelperClass1::ThreadedGenerateData(const O ++inputIt; } +// std::cout << "HelperClass1::ThreadedGenerateData - OUT " << threadId << std::endl; } @@ -282,8 +297,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; @@ -302,14 +320,22 @@ protected: //Empty constructor template HelperClass2::HelperClass2() { - m_EdgePaddingValue=itk::NumericTraits::Zero; + PixelType zero; + for(unsigned int i=0;i ::Zero; } //========================================================================================================================= //update the output for the outputRegionForThread +#if ITK_VERSION_MAJOR >= 4 +template void HelperClass2::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) +#else template void HelperClass2::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) +#endif { +// std::cout << "HelperClass2::ThreadedGenerateData - IN " << threadId << std::endl; //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); @@ -360,6 +386,9 @@ template void HelperClass2 InvertVFFilter::InvertVFFilter() { - m_EdgePaddingValue=itk::NumericTraits::Zero; //no other reasonable value? + + //m_EdgePaddingValue=itk::NumericTraits::Zero; //no other reasonable value? + PixelType zero; + for(unsigned int i=0;i void InvertVFFilter::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()); @@ -455,6 +484,7 @@ template void InvertVFFilterSetNumberOfThreads(m_NumberOfThreads); helper2->SetInput(temp); helper2->SetWeights(weights); helper2->SetEdgePaddingValue(m_EdgePaddingValue); @@ -465,6 +495,8 @@ template void InvertVFFilterSetNthOutput(0, helper2->GetOutput()); + + //std::cout << "InvertVFFilter::GenerateData - OUT" << std::endl; }