X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkInvertVFFilter.txx;h=684b35545add887b43a3827a6efd9ce8d71577d0;hb=595624eb4297e747630105d45017de69733caef2;hp=6bda75eb0d2b65ba4a21b6f438862201c6fffd14;hpb=a6957c4825e83c61b977ec316dd841878617ffbd;p=clitk.git diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index 6bda75e..684b355 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -17,6 +17,7 @@ ===========================================================================**/ #ifndef __clitkInvertVFFilter_txx #define __clitkInvertVFFilter_txx + namespace { @@ -74,7 +75,7 @@ protected: //the actual processing void BeforeThreadedGenerateData(); - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); //member data typename WeightsImageType::Pointer m_Weights; @@ -103,6 +104,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,15 +113,15 @@ void HelperClass1::BeforeThreadedGenerateData() //========================================================================================================================= //update the output for the outputRegionForThread template -void HelperClass1::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) +void HelperClass1::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) { - + //std::cout << "HelperClass1::ThreadedGenerateData - IN" << std::endl; //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); //Get pointer to the output typename OutputImageType::Pointer outputPtr = this->GetOutput(); - typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize(); + //typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize(); //Iterator over input typedef itk::ImageRegionConstIteratorWithIndex InputImageIteratorType; @@ -129,7 +131,7 @@ 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; @@ -147,7 +149,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 @@ -178,7 +180,7 @@ void HelperClass1::ThreadedGenerateData(const O upper = counter; // each bit indicates upper/lower neighbour // get neighbor index and overlap fraction - for( dim = 0; dim < 3; dim++ ) { + for( dim = 0; dim < ImageDimension; dim++ ) { if ( upper & 1 ) { neighIndex[dim] = baseIndex[dim] + 1; overlap *= distance[dim]; @@ -233,6 +235,7 @@ void HelperClass1::ThreadedGenerateData(const O ++inputIt; } + //std::cout << "HelperClass1::ThreadedGenerateData - OUT" << std::endl; } @@ -282,7 +285,7 @@ protected: //the actual processing - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); //member data @@ -308,9 +311,10 @@ template HelperClass2 void HelperClass2::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) +template void HelperClass2::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ) { - + //std::cout << "HelperClass2::ThreadedGenerateData - IN" << std::endl; + //Get pointer to the input typename InputImageType::ConstPointer inputPtr = this->GetInput(); @@ -360,6 +364,9 @@ template void HelperClass2::InvertVFFilter() m_Verbose=false; } - //========================================================================================================================= //Update template 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); - PixelType zero = itk::NumericTraits::Zero; - + 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());