X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkInvertVFFilter.txx;h=684b35545add887b43a3827a6efd9ce8d71577d0;hb=29c90b5fbd7ecd5d8375e02b7a03734c4fdbc806;hp=ae6be89f8e85c424dbbc9c7a2c39bbc5f0947da3;hpb=2252420857d1554424d1f2c69ea68547bc759678;p=clitk.git diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index ae6be89..684b355 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -74,8 +74,6 @@ protected: ~HelperClass1() {}; //the actual processing - void GenerateInputRequestedRegion(); - void GenerateOutputInformation(); void BeforeThreadedGenerateData(); void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); @@ -101,33 +99,6 @@ HelperClass1::HelperClass1() m_ThreadSafe=false; } -//========================================================================================================================= -//Set input image params -template -void HelperClass1::GenerateInputRequestedRegion() -{ - //std::cout << "HelperClass1::GenerateInputRequestedRegion - IN" << std::endl; - - typename InputImageType::Pointer inputPtr = const_cast< InputImageType * >(this->GetInput()); - inputPtr->SetRequestedRegion(inputPtr->GetLargestPossibleRegion()); - - //std::cout << "HelperClass1::GenerateInputRequestedRegion - OUT" << std::endl; -} - -//========================================================================================================================= -//Set output image params -template -void HelperClass1::GenerateOutputInformation() -{ - //std::cout << "HelperClass1::GenerateOutputInformation - IN" << std::endl; - Superclass::GenerateOutputInformation(); - - // it's the weight image that determines the size of the output - typename OutputImageType::Pointer outputPtr = this->GetOutput(); - outputPtr->SetLargestPossibleRegion( m_Weights->GetLargestPossibleRegion() ); - outputPtr->SetSpacing(m_Weights->GetSpacing()); -} - //========================================================================================================================= //Before threaded data template @@ -150,18 +121,13 @@ void HelperClass1::ThreadedGenerateData(const O //Get pointer to the output typename OutputImageType::Pointer outputPtr = this->GetOutput(); -/* outputPtr->SetLargestPossibleRegion( m_Weights->GetLargestPossibleRegion() ); - outputPtr->SetSpacing(m_Weights->GetSpacing());*/ - typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize(); - //std::cout << outputPtr->GetSpacing() << size << std::endl; + //typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize(); //Iterator over input - //typedef itk::ImageRegionConstIteratorWithIndex InputImageIteratorType; - typedef itk::ImageRegionConstIteratorWithIndex InputImageIteratorType; + typedef itk::ImageRegionConstIteratorWithIndex InputImageIteratorType; //define them over the outputRegionForThread - //InputImageIteratorType outputIt(inputPtr, outputRegionForThread); - InputImageIteratorType outputIt(outputPtr, outputPtr->GetLargestPossibleRegion()); + InputImageIteratorType inputIt(inputPtr, outputRegionForThread); //Initialize typename InputImageType::IndexType index; @@ -170,14 +136,14 @@ void HelperClass1::ThreadedGenerateData(const O typename OutputImageType::PointType opoint; typedef typename OutputImageType::PixelType DisplacementType; DisplacementType displacement; - outputIt.GoToBegin(); + inputIt.GoToBegin(); //define some temp variables signed long baseIndex[ImageDimension]; double distance[ImageDimension]; unsigned int dim, counter, upper; double totalOverlap,overlap; - typename OutputImageType::IndexType neighIndex, outIndex; + typename OutputImageType::IndexType neighIndex; //Find the number of neighbors unsigned int neighbors = 1 << ImageDimension; @@ -185,17 +151,13 @@ void HelperClass1::ThreadedGenerateData(const O //================================================================================================== //Loop over the output region and add the intensities from the input to the output and the weight to the weights //================================================================================================== - while( !outputIt.IsAtEnd() ) { + while( !inputIt.IsAtEnd() ) { // get the input image index - outIndex = outputIt.GetIndex(); - outputPtr->TransformIndexToPhysicalPoint( outIndex,opoint ); - for(unsigned int j = 0; j < ImageDimension; j++ ) ipoint[j] = opoint[j]; - inputPtr->TransformPhysicalPointToIndex(ipoint, index); + index = inputIt.GetIndex(); inputPtr->TransformIndexToPhysicalPoint( index,ipoint ); // get the required displacement - //displacement = outputIt.Get(); - displacement = inputPtr->GetPixel(index); + displacement = inputIt.Get(); // compute the required output image point for(unsigned int j = 0; j < ImageDimension; j++ ) opoint[j] = ipoint[j] + (double)displacement[j]; @@ -270,7 +232,7 @@ void HelperClass1::ThreadedGenerateData(const O } } - ++outputIt; + ++inputIt; } //std::cout << "HelperClass1::ThreadedGenerateData - OUT" << std::endl; @@ -429,41 +391,6 @@ InvertVFFilter::InvertVFFilter() m_Verbose=false; } -//========================================================================================================================= -//Set input image params -template -void InvertVFFilter::GenerateInputRequestedRegion() -{ - //std::cout << "InvertVFFilter::GenerateInputRequestedRegion - IN" << std::endl; - // call the superclass' implementation of this method - // Superclass::GenerateInputRequestedRegion(); - - typename InputImageType::Pointer inputPtr = const_cast< InputImageType * >(this->GetInput()); - inputPtr->SetRequestedRegion(inputPtr->GetLargestPossibleRegion()); - - //std::cout << "InvertVFFilter::GenerateInputRequestedRegion - OUT" << std::endl; -} - -//========================================================================================================================= -//Set output image params -template -void InvertVFFilter::GenerateOutputInformation() -{ - //std::cout << "InvertVFFilter::GenerateOutputInformation - IN" << std::endl; - Superclass::GenerateOutputInformation(); - - typename InputImageType::ConstPointer inputPtr=this->GetInput(); - typename WeightsImageType::RegionType region = inputPtr->GetLargestPossibleRegion(); - region.SetSize(m_OutputSize); - - typename OutputImageType::Pointer outputPtr = this->GetOutput(); - outputPtr->SetRegions( region ); - outputPtr->SetSpacing(m_OutputSpacing); - outputPtr->SetOrigin(inputPtr->GetOrigin()); - - //std::cout << "InvertVFFilter::GenerateOutputInformation - OUT" << std::endl; -} - //========================================================================================================================= //Update template void InvertVFFilter::GenerateData() @@ -473,16 +400,13 @@ template void InvertVFFilterGetInput(); typename WeightsImageType::RegionType region = inputPtr->GetLargestPossibleRegion(); - //region.SetSize(size); - region.SetSize(m_OutputSize); //Allocate the weights typename WeightsImageType::Pointer weights=WeightsImageType::New(); weights->SetOrigin(inputPtr->GetOrigin()); weights->SetRegions(region); - weights->SetSpacing(m_OutputSpacing); weights->Allocate(); - //weights->SetSpacing(inputPtr->GetSpacing()); + weights->SetSpacing(inputPtr->GetSpacing()); //=========================================================================== //Inversion is divided in in two loops, for each we will call a threaded helper class @@ -513,8 +437,7 @@ template void InvertVFFilterSetRegions(region); mutex->Allocate(); - //mutex->SetSpacing(inputPtr->GetSpacing()); - mutex->SetSpacing(m_OutputSpacing); + mutex->SetSpacing(inputPtr->GetSpacing()); helper1->SetMutexImage(mutex); if (m_Verbose) std::cout <<"Inverting using a thread-safe algorithm" < void InvertVFFilterGetSpacing() << temp->GetLargestPossibleRegion().GetSize() << std::endl; - //std::cout << weights->GetSpacing() << weights->GetLargestPossibleRegion().GetSize() << std::endl; helper2->SetInput(temp); helper2->SetWeights(weights); helper2->SetEdgePaddingValue(m_EdgePaddingValue);