/*========================================================================= Program: Tensor ToolKit - TTK Module: $URL$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt 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 _itk_TensorImageToVectorImage_txx_ #define _itk_TensorImageToVectorImage_txx_ #include "itkTensorImageToVectorImage.h" #include #include namespace itk { template void TensorImageToVectorImage ::BeforeThreadedGenerateData() { if( InputPixelType::NDegreesOfFreedom != OutputPixelType::GetVectorDimension() ) { throw itk::ExceptionObject (__FILE__,__LINE__,"Error: Tensor and vector dimensions do not match."); } // Images const TInputImage * input = this->GetInput(); TOutputImage * output = this->GetOutput(); // Copy image geometry output->SetRegions( input->GetLargestPossibleRegion() ); output->SetOrigin( input->GetOrigin() ); output->SetSpacing( input->GetSpacing() ); output->SetDirection( input->GetDirection() ); } template void TensorImageToVectorImage ::DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) { typedef ImageRegionIterator IteratorOutputType; typedef ImageRegionConstIterator IteratorInputType; IteratorOutputType itOut(this->GetOutput(), outputRegionForThread); IteratorInputType itIn (this->GetInput(), outputRegionForThread); while( !itOut.IsAtEnd() ) { InputPixelType T = itIn.Get(); OutputPixelType V; for( unsigned int i=0; i( T.GetNthComponentAsVector (i) ); } itOut.Set (V); ++itOut; ++itIn; } } } // end of namespace #endif